[antlr-interest] how to "eat" something in the parser?
Martin Kortmann
email at kortmann.de
Thu Aug 2 08:23:27 PDT 2007
Hi,
My parser grows and the problems also ;-)
The fileformat that i would like to parse is divided
into sections, each limited by an start and stop symbol.
I like to ignore some of this sections an tried the
following construction:
grammar test;
// start rule
projectfile
: (section | eatthis)*
;
section : START 'section'
Parameter=INT
END 'section'
;
eatthis : START 'eatthis'
.*
END 'eatthis'
;
START : 'start';
END : 'end';
INT : ('0'..'9')+;
WS : (' '|'\t'|'\r'|'\n')+ {$channel=HIDDEN;};
Testinput is:
start section
1
end section
start eatthis
this ist some text to ignore (blubb) [0] {};
end eatthis
start section
2
end section
The first problem: "eatthis" doesnt work :-(
The second Problem, if it would work, then it should
also work for text like
start eatthis
start innersection
start some_other
forget about everything between start and stop eatthis.
end some_other
end innersection
end eatthis
whould someone so nice and put me into the right direction?
Thanks Martin
More information about the antlr-interest
mailing list