[antlr-interest] Getting text from variable length matches?
elias_biris <elias at biris.freeserve.co.uk>
elias at biris.freeserve.co.uk
Fri Dec 13 06:31:57 PST 2002
I am sure that this has been discussed in the past, but my searches in
the archives and the faq did not come up with a quick response:
In my C++ parser I have rules that match 1+ or 0+ or 0/1 things ie
rule1 returns [string final_match]
: l1:LEXER_TOKEN_A (rule2)+ l2:LEXER_TOKEN_A
rule2 returns [string match]
: l3:LEXER_TOKEN_B (l4:LEXER_TOKEN_C)?
| l5:LEXER_TOKEN_B (l6:LEXER_TOKEN_D)*
Ambiguities and antlr-syntax errors aside (the above just give a
flavor of the thing I want to do, they do not make a syntacticaly
correct grammar spec), how can I get the strings matched by the ()+,
()*, or ()? patterns above? Do I have to build the strings using the
labels for handles to getText(), or is there an easier (more direct)
way to do this? I am doing this all in C++ but I would be open to
suggestions from Java people if they have any tips.
All tips will be gratefully appreciated :-)
Kind regards
Elias
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list