[lua] Fix parsing of short/long comments

This commit is contained in:
Andreas Dangel 2022-09-24 17:13:29 +02:00
parent 05c30a1053
commit dcd8ff0ac0
No known key found for this signature in database
GPG Key ID: 93450DF2DF9A3FA3
2 changed files with 16 additions and 6 deletions

View File

@ -469,11 +469,11 @@ CLOSE_PARENS
;
NL
: '\r\n' | '\r' | '\n'
| '\u0085' // <Next Line CHARACTER (U+0085)>'
| '\u2028' //'<Line Separator CHARACTER (U+2028)>'
| '\u2029' //'<Paragraph Separator CHARACTER (U+2029)>'
;
: '\r\n' | '\r' | '\n'
| '\u0085' // <Next Line CHARACTER (U+0085)>'
| '\u2028' //'<Line Separator CHARACTER (U+2028)>'
| '\u2029' //'<Paragraph Separator CHARACTER (U+2029)>'
;
COMMA
: ','
@ -525,6 +525,11 @@ HexDigit
: [0-9a-fA-F]
;
fragment
StartingSingleCommentLineInputCharacter
: ~[[\r\n\u0085\u2028\u2029]
;
fragment
SingleLineInputCharacter
: ~[\r\n\u0085\u2028\u2029]
@ -535,7 +540,7 @@ COMMENT
;
LINE_COMMENT
: '--' SingleLineInputCharacter* -> channel(HIDDEN)
: '--' (NL | StartingSingleCommentLineInputCharacter SingleLineInputCharacter*) -> channel(HIDDEN)
;
WS

View File

@ -44,4 +44,9 @@ public class LuaTokenizerTest extends CpdTextComparisonTest {
public void testRegression() {
doTest("luauTypes");
}
@Test
public void testComment() {
doTest("comment");
}
}