[antlr-interest] One weird, one (hopefully) simple problem
.. . from a newbie
Robert Colquhoun
rjc at trump.net.au
Tue Jan 28 22:48:16 PST 2003
Hello,
At 08:22 AM 28/01/2003 -0800, mzukowski at yci.com wrote:
>I think those two problems could be solved with a filter between the lexer
>and parser. Consider this approach:
>
>buffer a whole line
>upon recognizing a newline, work backwards to see if there was a comment at
>the end of the line by looking for '*', '!', or "REM". If you see a ';'
>then stop looking for a comment
>discard the comment
>
>now do a similar thing for a label following a ';'
>
>What do you think?
The problem is that half the time the lexer chokes on the comments before
they can reach the parser or intermediate filter.
For example the '?' character is not used in the basic grammer anywhere but
is perfectly legal in the comments. Upon trying to lex the comments as if
it was a basic program you end with an exception ie: unexpected char: '?'
Obviously you could add a lexer rule in to handle that particular
character, but if say the basic program is written in a foreign language
pretty much any unicode character could be in there.
Would need some sort of catch all lexer rule which would match on
everything else except what's defined in the other rules.
- Robert
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list