Adding skipto the rule does not do what I expect. Here's the grammar for a pair of tokens, separated by a comma and a space. I made one version where the comma is marked skipand the other where it is missing:
grammar Commas;
COMMA: ', ';
COMMASKIP: ', ' -> skip;
DATA: ~[, \n]+;
withoutSkip: data COMMA data '\n';
withSkip: data COMMASKIP data '\n';
data: DATA;
Testing the rule without skipworks as expected:
$ echo 'a, b' | grun Commas withoutSkip -tree
(withoutSkip (data a) , (data b) \n)
With skipan error message appears:
$ echo 'a, b' | grun Commas withSkip -tree
line 1:1 mismatched input ', ' expecting COMMASKIP
(withSkip (data a) , b \n)
If I comment on the rules COMMAand withoutSkip, I get the following:
$ echo 'a, b' | grun Commas withSkip -tree
line 1:3 missing ', ' at 'b'
(withSkip (data a) <missing ', '> (data b) \n)
I am trying to get output that has only decimal data tokens, like this:
(withSkip (data a) (data b) \n)
What am I doing wrong?
source
share