On Thu, 2008-09-18 at 01:06 -0400, Ilya Sterin wrote:
> I'm having an issue with what seems to be very simple grammar...
Please read the "5 minute introduction to ANTLR" on the wike page. This
will explain how to write sch a simple grammar. All your rules are lexer
rules and you are not catering for whitespace, some of your lexer rules
overlap others and so on. These are all basic mistakes that everyone
makes, but a bit of reading on the wiki will get you through it.
Jim
>
> The CREATECOMMAND is parsing correctly...
>
> Here is what I use for validation...
>
> create jar named "alex.jar"
>
> I get a NoViableAltException for the TYPE definition
>
> The grammar file is below...
>
>
> //////// alex.g ////////
>
> grammar alex;
>
> tokens {
> BUILD='build';
> FROM='from';
> TO='to';
> CREATE='create';
> NAMED='named';
> }
>
> COMMAND : BUILDCOMMAND CREATECOMMAND;
>
> BUILDCOMMAND : BUILD (SOURCE | DESTINATION)+;
> CREATECOMMAND : CREATE TYPE (NAME | SOURCE | DESTINATION)+;
>
> SOURCE : FROM FILE;
> DESTINATION : TO FILE;
>
> TYPE : ('jar' | 'war');
>
> NAME : NAMED FILE;
>
> FILE : '"' FILENAME '"';
> FILENAME : ('a'..'z'|'A'..'Z'|'0'..'9'|'.')+;
>
> List: http://www.antlr.org:8080/mailman/listinfo/antlr-interest
> Unsubscribe:
> http://www.antlr.org:8080/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
-~----------~----~----~----~------~----~------~--~---
List: http://www.antlr.org:8080/mailman/listinfo/antlr-interest
Unsubscribe:
http://www.antlr.org:8080/mailman/options/antlr-interest/your-email-address