Hi all,
At the start of one parser rule I would like, as one alternative, to
match nearly any input ending before a certain character value. I would
like this to match as a single token if possible. I am not sure how to
achieve this, and have tried a number of things so far. Here is my best
shot so far:
elem
: DECL ';'
| ID '=' expr ';'
;
DECL: (DECL_CHAR+ ';') => DECL_CHAR+
;
fragment
DECL_CHAR
: ~(';'|'=')
;
Working with the above, ANTLR reports that tokens such as ID can never
be matched, since DECL matches them already. I had not thought this
would be the case with a syntactic predicate in front of the alternative.
So far, I have only had success by incorporating the end character into
the token, as follows. But I believe this will lead to the token
matching in other, unexpected places.
DECL: DECL_CHAR+ ';'
;
The important problem is that I don't want DECL to match at other parts
of the grammar.
TIA for any advice,
Ryan Twitchell
List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe:
http://www.antlr.org/mailman/options/antlr-interest/your-email-address
--
You received this message because you are subscribed to the Google Groups
"il-antlr-interest" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/il-antlr-interest?hl=en.