Gale Paeper wrote:
While working on a MacPascal dialect to GPC porting project, I was surprised to encounter preprocessor errors in conditional compilation directives where the conditional expression directly or indirectly (i.e., a macro expansion) contained $ hex constants. A short example (thanks Afriaan):
program dollars; {$definec dollars $1} {$ifc dollars = 1} {$endc} begin end.
Compiling yields the error:
dollars.pas:3: conditional expression: parse error
If one changes {$definec dollars $1} to {$definec dollars 1}, it compiles with no problem.
After some futher testing and digging into the gpcpp.c source code, it looks like the preprocessor doesn't support $ hex constants in conditional expressions for conditional compilation directives.
That's right. Neither EP 16#1 constants yet.
When I'll reimplement the preprocessor based on the Pascal lexer as planned, this support will come for free. In the meantime all work on the existing preprocessor will eventually be wasted when it's replaced.
That said, if you (or someone else) would like to add support for `$' for now, feel free to do so. The relevant code is in gpcpp.c: yylex (): "if (*lexptr >= '0' && *lexptr <= '9') ..."
Frank