Skip to content
Snippets Groups Projects
Commit be583d96 authored by Adam Wardynski's avatar Adam Wardynski
Browse files

Ignore ambiguity warning in ML_COMMENT. It works OK

This is how they do it on the web, really. It works as expected and matches any flavor of newline (Win, Unix, Mac) despite the ambiguity that "\n\r" can be matched by two subrules, in the end it will be properly matched just by one rule. Also, grammar can be k=2 for lexer.
parent f97a6d15
No related merge requests found
......@@ -911,7 +911,7 @@ options {
exportVocab = ANTLRExpr;
charVocabulary = '\3'..'\377';
testLiterals = false;
k = 3;
k = 2;
}
STRING
......@@ -1075,10 +1075,18 @@ options {
paraphrase = "Multi line comment";
}
: "/*"
({ LA(2)!='/' }? '*'
| ('\r' '\n') => '\r' '\n' {newline();}
| '\r' {newline();}
| '\n' {newline();}
( /* This actually works OK despite the ambiguity that
'\r' '\n' can be matched in one alternative or by matching
'\r' in one iteration and '\n' in another.. But
this is really matched just by one rule per (...)*
loop iteration, so it's OK.
This is exactly how they do it all over the web - just
turn off the warning for this particular token.*/
options { generateAmbigWarnings=false; }
: { LA(2)!='/' }? '*'
| '\r' '\n' { newline(); }
| '\r' { newline(); }
| '\n' { newline(); }
| ~('*'|'\n'|'\r')
)*
"*/"
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment