[antlr-interest] Matching nested actions
Emond Papegaaij
e.papegaaij at student.utwente.nl
Thu Jun 22 00:32:52 PDT 2006
Hello,
I'm trying to match nested actions as ANTLR does. For this I've copied the
following rule from the ANTLR v2 documentation (with a minor modification to
get rid of the ambiguity warning):
ACTION
: '{' ( ACTION | ~('}'|'{') )* '}'
;
This works fine with the alpha v3 version I've got from Terence 2 days ago
(note that it does not work with ea10). However I want this token to be
protected and use it from another token:
ACTION: NESTED_ACTION;
protected NESTED_ACTION
: '{' ( NESTED_ACTION | ~('}'|'{') )* '}'
;
This does not change anything to the token, or does it? However ANTLR now
gives me:
tpl3.g:1:10: Alternative 1: after matching input such as '{''{''{''{''{'
decision cannot predict what comes next due to recursion overflow to
NESTED_ACTION from NESTED_ACTION
tpl3.g:1:10: Alternative 2: after matching input such as '{''{''{''{''{'
decision cannot predict what comes next due to recursion overflow to
NESTED_ACTION from NESTED_ACTION
tpl3.g:8:11: The following token definitions are unreachable: NESTED_ACTION
(ea10 only gives the last warning)
The grammar still works as before. Why is ANTLR giving these warnings?
Best regards,
Emond Papegaaij
More information about the antlr-interest
mailing list