[antlr-interest] query regarding lexer
john at jacelridge.com
Sat Apr 19 13:32:38 PDT 2008
commandline : command Blank argument ; // allows for other commands
than just 'command'
command : CMD ;
arguments : (command | Blank | Anything)* ;
CMD : 'command'
Anything : ~NewLine ;
NewLine : '\r' '\n'? | '\n' ;
That might be what you need.
On Apr 19, 2008, at 4:12 PM, elango m wrote:
> I need to neglect other lexer rules when I encounter a lexical token.
> The following snippet works for me. But I am sure there should be a
> better way of doing this.
> commandline : CMD ' ' CMD_ARG;
> CMD : 'command'
> CMD_ARG : ('a'..'z' | 'A'..'Z' | '0'..'9' | ' ' | '/')* ;
> Ex :
> command blah blah blah blah..
> should parse resulting two tokens 1) command and 2) rest of the
> string (blah blah blah blah..). this can include any special character
> Any help will be greatly appreciated.
More information about the antlr-interest