[antlr-interest] Lexer question
John B. Brodie
jbb at acm.org
Thu Jul 27 08:17:08 PDT 2006
>I would try something like this:
>
>In the Lexer:
>
>INTEGER: ('0'..'9')+;
>
>In the parser:
>
>integer: INTEGER;
>double: INTEGER '.' (INTEGER)?;
>
>Or to be a bit fancier, try this:
>...snipped...
Unfortunately doing this in the parser will permit embedded whitespace in
the double.
That is, assuming whitespace is $setType(SKIP) in the lexer, `1 . 2` is now
a valid double - or perhaps even worse:
1
// a comment
.
is also valid (again assuming the lexer is SKIP'ing whitespace and comments).
More information about the antlr-interest
mailing list