[antlr-interest] Dealing with issues in non-greedy (.)* rules
Marc-André Laverdière
ma_laver at ciise.concordia.ca
Tue Jun 12 07:30:10 PDT 2007
Hmm... I had to put this issue aside for a certain time, but now I'm
back on it.
I still have no idea what to do to make this work! If (.)+ won't do it,
what will? I can't believe that Antlr isn't dealing with a random blob.
BTW, I'm generating code with AntlrWorks... is there any bug in its code
generation vs the command-line utility?
Thanks in advance for the help!
Gavin Lambert wrote:
> At 02:47 15/05/2007, Marc-André Laverdière wrote:
> >line 21:30 no viable alternative at character '['
> >line 21:32 no viable alternative at character ']'
> >line 21:77 no viable alternative at character ';'
> [...]
> >Which means that certain characters are not accepted. Acutally,
> >when I print the resulting token, these are missing!
> >
> >I don't even have a lexer rule that mentions ';'!
> >What am I doing wrong? I'm working with k=2. Should I crank it up
> >for that rule?
>
> Actually, that's probably exactly what you're doing wrong :)
>
> The parser cannot and does not deal directly with characters. Any
> characters you want to be able to recognise in the stream must be
> converted into tokens, whether through lexer rules or a tokens block,
> and whether individually or grouped.
>
> (There is a shortcut syntax that makes it look like the parser can deal
> with characters, but in reality that just results in internally
> generating tokens, which you have less control over.)
>
--
Marc-André LAVERDIÈRE, B. Eng., M. A. Sc. (in progress)
Computer Security Laboratory - Laboratoire de sécurité informatique
CIISE, Université Concordia University, Montréal, Québec, Canada
www.ciise.concordia.ca
/"\
\ / ASCII Ribbon Campaign
X against HTML e-mail
/ \
"Perseverance must finish its work so that you may be mature and
complete, not lacking anything." -James 1:4
More information about the antlr-interest
mailing list