>
> Hi all
>
> Im having some problems with a simple grammar that I have defined. The
> grammar is as follows:
>
> grammar RvMessage;
>
> START_MSG: '{';
> END_MSG: '}';
>
> parse     :     message+ EOF;
>
> message : START_MSG field+ END_MSG;
>
> field : name '=' value;
>
> fragment LOWER: 'a'..'z';
> fragment UPPER: 'A'..'Z';
> LETTER: LOWER | UPPER;
>
> fragment DIGIT: '0'..'9';
>
> name : LETTER (LETTER | DIGIT | '_')*;
>
> NEWLINE: ('\r'? '\n')+ { $channel=HIDDEN; };
>
> fragment SPACE: ' ' | '\t';
> WHITESPACE: SPACE+ { $channel = HIDDEN; };
>
> fragment NONCONTROL_CHAR: LETTER | DIGIT | SYMBOL | SPACE;
>
> fragment SYMBOL: '!' | '#'..'/' | ':'..'@' | '['..'`' | '{'..'~';
>
> STRING_LITERAL : '"' NONCONTROL_CHAR* '"';
> string : STRING_LITERAL;
> SIGN: '+' | '-';
>
> FLOAT: INTEGER '.' DIGIT+;
> INTEGER: '0' | SIGN? '1'..'9' DIGIT*;
> int : INTEGER;
> float : FLOAT;
>
> value : (string | int | float | message);
>
>
> And it can parse simple inputs like the following with no problems:
>
> {
> a=1
> b=2
> c="dddd"
> d=3.14159
> e= { a=1 }
> f={a=1 b=2 c="1111111111"}
> g="hello" h="world"
> }
>
>
> But an input like the following throws it:
>
> {
> foo_bar_1=1
> }
>
> I get NoViableAltException: no viable alternative at input '1'. The issue
> seems to be variable names (the 'name' rule in my grammar above) that
> contain a digit - even though I have defined this as part of the generating
> rule. Can anyone see if there is anything glaringly obvious in my grammar
> that would prevent the above from working? Im pretty new to Antlr, so any
> help is much appreciated.
>
> Thanks!
> -- Rory
>
>
>

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