antlr3 - antlr, I can't seem to find how to match the rest of the line(including whitespace) -


I have a lesson "anything can be done on blah blah"

I want to match.

  on: ('o' | 'o') ('n') are my tokens, some, and "blah blah blah can be anything"  

| 'N'); Index: (option {greedy = false;}: esc |.) * WS: ('' | '\ t' | '' \ r '|' \ \ '\) + {$ channel = HIDDEN; }; ESC: '\' ('' '' '\' '|' \\ ');

And I usually want to throw the white space so that the channel is hidden but in this situation

myRule: ON INDEX REST;

But it is not certain whether the rest should be (and I'm sure if I want a fictional token or not).

Thank you, Dean

If I understand your problem correctly, So your grammar will be something like this (works correctly for your example):

  grammar so1; MyRule: Indices at rest; Rest: ~ '' '' '' \ N ') * at: (' o '|' o ') (' n '|' n '); Index: (magazine | Digit) +; WS: ('' | '\ t' | '\ r' | '' \ n ') + {$ channel = HIDDEN;}; Piece Digit: '0' .. '9'; Piece letter: ('a' .. 'z' | 'a' .. 'z' | '_');    

Comments