-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Closed
Description
When files having '\r' as newlines are parsed, the line numbers and the character positions in line do not correctly reflect the situation. For instance:
Grammar:
grammar Hello; // Define a grammar called Hello
r : 'hello' ID ; // match keyword hello followed by an identifier
ID : [a-z]+ ; // match lower-case identifiers
WS : [ \t\r\n]+ -> skip ; // skip spaces, tabs, newlines, \r (Windows)
Input file: input.txt
Output:
grun Hello r -tokens input.txt
[@0,0:4='hello',<'hello'>,1:0]
[@1,7:11='parrt',<ID>,1:7]
[@2,12:11='<EOF>',<EOF>,1:12]
2nd and 3rd token don't lie on the 1st line. The parser is failing to recognize CR as newline.
Seems to relate to this part of the code.
Metadata
Metadata
Assignees
Labels
No labels