I try to parse this part of the text
: 20: test : 254: Apte: 21: Rest ...
: 20:
and : 21:
are special tags, because those lines Let's start : 254:
should be the 'normal' text, because it does not start on a new line.
I should have the result
(20, 'test: 254: \ naapje') (21, 'left')
Lines are either eliminated by either \ r \ n
or \ n
I tried to ignore the white space from the beginning, but then I match the '254:' tag. So I have to do something that uses white space information.
What I want to be able to do is something like this:
laser grammar MT9740_lexer; InTagNewLine: '\ r \ n' ~ ':'; ReadNewLine: '\ r \ n';
But the first will consume:
How can I still make these tokens? Or is there a clever approach?
I understand that you are searching for some laser rules to match the beginning of a line, this Likers rule You should notify: 20: or: 21: appearing only at the beginning of a line
SOL: {getCharPositionInLine () == 0}? ':' [0- 9] + ':';
The rules of your parser can then search the SOL token before parsing the remaining line.
Comments
Post a Comment