pdietrich@synstar.de wrote:
The exponentiation operator cannot be used in expressions for lower/upper bound of subrange definitions. The compiler issues two different error messages: If a unary minus is present, the error message is "parse error before **", otherwise it is "subrange bounds are not of the same type". There is also a lot "extra semicolon" messages for lines following the "parse error".
The result of the `**' operator is of type real, so it can't be used where an integer is expected. For integer exponentiation, you can use the `pow' operator. (That's like `/' and `div' for real/integer division.)
program test (output);
type utriple = 0..2**24-1; triple = -2**23..2**23-1; begin end.
F:\PROJECTS\ISIDATA\isidef>gpc -c test6.pas test6.pas:4: subrange bounds are not of the same type test6.pas:5: parse error before `**' test6.pas:5: extra semicolon
There is a real bug in GPC in that expressions can't be used as lower subrange bounds. We'd like to fix it, but it turns out to be very difficult with the parser we're using, so if anyone has experience with parsers and could help here...
As a workaround, you can declare a constant, so the following works:
program test (output);
const foo = -2 pow 23;
type utriple = 0..2 pow 24-1; triple = foo..2 pow 23-1; begin end.
Frank