[antlr-interest] Grammar problem with ~
fridi
fridi70 at gmx.de
Tue Jun 26 14:22:15 PDT 2012
Hi all,
I have a grammar that I have to extend in order to meet changes in the
files we have to parse.
There is a code (which can be an int or a letter followed by int ) that
is followed by a description.
i.e.
3007508 This is the description of the code
3024400 A/B bla bla bla & bla
A1234 This is another description
B4711 asdf ghjz-kk with Test w/o
I am interested in the code only and I tried something like
in parser
(
INT REST
)+
in lexer
REST
:
~('\n' | '\r')
;
which works for some instances with the code as int, but not for a code
that starts with a letter because my rule for REST now consumes other
tokens.
I have used the "all except NL" approach for some other comments to read
until NL, but there was always a constant string at the beginning of the
line so that the rule didn't consume any other part of my text. I think
that REST is to common and it might kill my other rules.
Is there any other way to parse the descriptions?
Any help is very appreciated,
fridi
More information about the antlr-interest
mailing list