Antlr doesn't like it when there are multiple ways to match nothing. It 
says there's an error in my grammar because the second "alternative" 
(which is another way to match nothing) will never match.
Antlr can enter the optional (...)? element and match nothing, or skip 
the optional element, thus matching nothing.

example:

naughty_rule
     :    Start (A? List*)? End
     ;
Start    :    'start';
A    :    'aaa';
End    :    'end';
List    :    'list';

Rewritten so Antlr is happy
good_rule
     :    Start End
     |    Start A List* End
     |    Start List+ End
     ;

While I can rewrite my grammar easily enough, it seems odd that Antlr 
doesn't recognize that it's trying to match nothing in two different 
ways, so who cares if it can't match the second alternative. That 
shouldn't be an error. If it's a warning, I could understand that. To 
make it the user rewrite their code into something less legible seems to 
be opposite of the usual 'Antlr way'. Although I guess this would 
require making the code a little more complicated to detect this special 
case, so perhaps this was already considered.

Cheers
Daniel

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.

Reply via email to