At 16:35 2/12/2009, qinglangee wrote:
>
>prog: (command)+ ;
>command : (function |var)+;
>function : (Letter)+',';
>var : (Letter)+;
>Letter : 'A'..'Z';
>WS : ( '\t'|' '|'\r'|'\n'|'\u000C' )+ { $channel = HIDDEN; } ;
[...]
>[11:14:04] warning(200): cub.g:4:25: Decision can match input
such
>as "Letter" using multiple alternatives: 1, 2, 3
>As a result, alternative(s) 3,2 were disabled for that input
>[11:14:04] error(201): cub.g:4:25: The following alternatives
can
>never be matched: 2
The problem is that both the function and var rules have a common
left prefix (Letter+); the only distinguishing feature is whether
it's followed by a comma or not. So when you're saying that
"command" can consist of either "function" or "var", it's not
possible to define static lookahead to disambiguate that case.
You can either force explicit lookahead (this doesn't always
work):
command : ( (function) => function
| var
)+
;
Or refactor the rules to eliminate the ambiguity:
command : ( Letter+ ','? )+ ;
Note however that since you're hiding whitespace in the lexer, the
input "HELLO" and "HE L LO" will be treated as
identical. This may or may not be what you want.
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.