-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Closed
Description
I have the following grammar:
lexer grammar T;
ID: [a-z]+;
WS: [ \n] -> skip;
And the following input: "a" + newLine + "b" + newLine + "c"
- If newLine is \r\n, I got this:
[@0,0:0='a',<1>,1:0]
[@1,3:3='b',<1>,2:0]
[@2,6:6='c',<1>,3:0]
[@3,7:6='<EOF>',<-1>,3:1]
newLine == \n:
[@0,0:0='a',<1>,1:0]
[@1,2:2='b',<1>,2:0]
[@2,4:4='c',<1>,3:0]
[@3,5:4='<EOF>',<-1>,3:1]
newLine == \r:
[@0,0:0='a',<1>,1:0]
[@1,2:2='b',<1>,1:2]
[@2,4:4='c',<1>,1:4]
[@3,5:4='<EOF>',<-1>,1:5]
In last case line numer for all tokens is 1 and it's wrong. I suggest to support '\r' newLine character. Another variants described at Wikipedia, but they are too rarely used. Moreover '\r' newline supported by most part of modern editors (IDEA, Visual Studio, Notepad++ etc.).
IARI
Metadata
Metadata
Assignees
Labels
No labels