[antlr-interest] Parsing VB-like Language Part 1: REM
Matthew Douglass
mdouglass at exapted.com
Tue Jun 24 09:05:09 PDT 2003
I'm fairly new to antlr, having written only one parser (that was
heavily borrowed from the java.g example). I am working on parsing a
VB-like language, and am having problems with comments that start with
rem. They are, obviously I'm sure, causing non-determinism warnings
with my IDENT definitions. I have found a way to fix it, by doing the
rem parsing inside the IDENT literal using a semantic predicate (I think
that's the right term) as follows:
IDENT
options {testLiterals=true;}
: ( ("rem" WS_NONBREAKING) => "rem" WS_NONBREAKING
(~('\n'|'\r'))* ('\n'|'\r'('\n')?) {$setType(Token.SKIP); newline();}
| ('a'..'z'|'_') ('a'..'z'|'_'|'0'..'9')* (TYPE_CHARACTER)?
)
;
But my understanding is that this would slow down my lexing quite a bit
-- is there a better way to do this? Or should I just not worry about it?
Thanks for any advice you can offer,
Matthew Douglass
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list