Gerald Rosenberg <[EMAIL PROTECTED]> írta:
> At 04:36 PM 10/31/2008, =?ISO-8859-2?Q?Imre_Andr=E1s?= wrote:
>
> >--- unreachable.g --------------------
> >grammar unreachable;
> >
> >ID : ('a'..'z'|'A'..'Z')+ ;
>
> ....
>
> >sequence returns [String value]: 'SEQUENCE' WS* '{' WS*
> >e=rightValue {$value=$e.value;} (WS* ',' WS* e=rightValue {$value +=
> >$e.value;})* WS* '}' {return $value;};
>
> The unreacheable compile analysis-time error is likely due to the
> fact that ID will consume all alpha characters, leaving no way to
> match the literal 'SEQUENCE'.
>
> BTW, since you are skip()ing whitespace, you can remove the WS* from
> the parser rules with no affect.
>
> ady got rid of the unreachable error based on Terence's comments. However,
> you have a point that the ID and SEQUENCE are ambigous. Interpreting A ::=
> SEQUENCE{ SEQUENCE } gives a MismatchedTokenException, though parsing
> continues after a resync.
I put SEQUENCE : 'SEQUENCE' in the grammar, and modified the sequence rule to
use it. Now it does not compile because of the ambiguity.
Now how can I explicitly tell that SEQUENCE is a keyword, and not a valid ID?
Thanks,
András
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
List: http://www.antlr.org:8080/mailman/listinfo/antlr-interest
Unsubscribe:
http://www.antlr.org:8080/mailman/options/antlr-interest/your-email-address