[antlr-interest] Lexer ambiguities

shmuel siegel antlr at shmuelhome.mine.nu
Mon Feb 11 09:14:25 PST 2008


Mark Volkmann wrote:
> I can't get your ideas above to work. If you tested this, can you send
> us your complete grammar file?
>
> Here is my grammar with your ideas incorporated.
>
> grammar NumberValue;
>
> file: (line terminator)*;
> line: a | b;
> a: (value | NUMBER) unit;
> b: value NAME;
>
> unit: 'kg' | 'lb';
> value: '0' | '1';
>
> NUMBER: '0'..'9'+;
> NAME: ('!'..'/' | ':'..'~' | '!'..'~')+;
>
> terminator: NEWLINE | EOF;
> NEWLINE: ('\r'? '\n')+;
> WHITESPACE: (' ' | '\t')+ { $channel = HIDDEN; };
>
> Here is my input.
>
> 1Mark
> 19kg
>
>   
Close. Try:

NAME: ('!'..'/' | ':'..'~' ) ('!'..'~')*;





More information about the antlr-interest mailing list