[antlr-interest] C# code generation errors
Gavin Lambert
antlr at mirality.co.nz
Fri May 1 12:55:14 PDT 2009
At 06:32 2/05/2009, Bill Steer wrote:
>INT : (DIGIT)+ ;
>FLOAT : INT
> | INT '.' INT
> | '.' INT
>;
>CONSTANT: FLOAT
> | FLOAT ('e' | 'E') ('+' | '-')? INT
>;
[...]
>IDENT : LETTER (LETTER | DIGIT)* ;
>REGISTER: IDENT ('!'IDENT)* ;
You're quite likely to run into parsing trouble with these rule
defintions. Remember that lexer rules are executed without parser
context; ANTLR will choose a rule based solely on what the input
looks like, so having multiple top-level lexer rules that accept
exactly the same input isn't really a good idea.
You should probably merge and left-factor these rules, and modify
the parser rules to eg. accept either an INT or a FLOAT token in
contexts where it is expecting a FLOAT, and an IDENT or REGISTER
where it is expecting a REGISTER. (And the distinction between
FLOAT and CONSTANT doesn't make much sense to me. Shouldn't that
be part of FLOAT?)
More information about the antlr-interest
mailing list