[antlr-interest] token paraphrasing without rule
Steffen Schuemann
s.schuemann at pobox.com
Thu May 27 12:50:03 PDT 2004
I have a rather strange rule in my lexer (excerpt):
tokens {
SSEP;
SBLOCK;
EBLOCK;
}
WS : WS_ ( (NL_ (NL_|WS_)*) {_ttype=SSEP;}
('{' (NL_|WS_)* {_ttype=SBLOCK;}
|'}' (WS_)* {_ttype=EBLOCK;})?
)?
| (NL_ (NL_|WS_)*) {_ttype=SSEP;}
('{' (NL_|WS_)* {_ttype=SBLOCK;}
|'}' (WS_)* {_ttype=EBLOCK;}
)?
| '{' {_ttype=SBLOCK;} (NL_|WS_)*
| '}' {_ttype=EBLOCK;} (WS_)*
;
WS_ and NL_ are protected rules checking for whitespace or newlines,
but I think they are unnecessary for understanding.
My problem is, that I don't know, how to paraphrase the tokens SSEP,
SBLOCK and EBLOCK, as they have no own rules. I found, that I coud use
SBLOCK="{"; in the tokens block, but that leads to artifacts in
generated error messages, as seen here:
line 12:30: expecting "{", found 'f92'
As you see, all normal tokens are enclosed in single quotes, that
"hack" leads to double quotes. Is there another way of paraphrasing
tokens or will I have to live with that?
Thanks!
Steffen
PS: Maybe, my way of implementing that rule is the strange result of
my limited understanding of antlr, but I just started working
with it, after using other tools for some time.
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/antlr-interest/
<*> To unsubscribe from this group, send an email to:
antlr-interest-unsubscribe at yahoogroups.com
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list