mirror of
https://github.com/apple/pkl.git
synced 2026-01-11 22:30:54 +01:00
Fix newline checks in parser (#1328)
This commit is contained in:
committed by
GitHub
parent
f4938dccca
commit
cc02b6b685
5
pkl-core/src/test/files/LanguageSnippetTests/input/errors/binopDifferentLine.pkl
vendored
Normal file
5
pkl-core/src/test/files/LanguageSnippetTests/input/errors/binopDifferentLine.pkl
vendored
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
binop_result: Int = 1
|
||||||
|
|
||||||
|
/*comment*/-
|
||||||
|
|
||||||
|
/*comment*/ 1
|
||||||
6
pkl-core/src/test/files/LanguageSnippetTests/output/errors/binopDifferentLine.err
vendored
Normal file
6
pkl-core/src/test/files/LanguageSnippetTests/output/errors/binopDifferentLine.err
vendored
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
–– Pkl Error ––
|
||||||
|
Invalid token at position. Expected a class, typealias, method, or property.
|
||||||
|
|
||||||
|
x | /*comment*/-
|
||||||
|
^
|
||||||
|
at binopDifferentLine (file:///$snippetsDir/input/errors/binopDifferentLine.pkl)
|
||||||
@@ -1811,11 +1811,13 @@ public class Parser {
|
|||||||
private FullToken forceNext() {
|
private FullToken forceNext() {
|
||||||
var tk = lexer.next();
|
var tk = lexer.next();
|
||||||
precededBySemicolon = false;
|
precededBySemicolon = false;
|
||||||
|
var newLines = lexer.newLinesBetween;
|
||||||
while (tk.isAffix()) {
|
while (tk.isAffix()) {
|
||||||
precededBySemicolon = precededBySemicolon || tk == Token.SEMICOLON;
|
precededBySemicolon = precededBySemicolon || tk == Token.SEMICOLON;
|
||||||
tk = lexer.next();
|
tk = lexer.next();
|
||||||
|
newLines += lexer.newLinesBetween;
|
||||||
}
|
}
|
||||||
return new FullToken(tk, lexer.span(), lexer.newLinesBetween);
|
return new FullToken(tk, lexer.span(), newLines);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Like next, but don't ignore comments
|
// Like next, but don't ignore comments
|
||||||
|
|||||||
@@ -93,6 +93,7 @@ class ParserComparisonTest {
|
|||||||
"stringError1.pkl",
|
"stringError1.pkl",
|
||||||
"annotationIsNotExpression2.pkl",
|
"annotationIsNotExpression2.pkl",
|
||||||
"amendsRequiresParens.pkl",
|
"amendsRequiresParens.pkl",
|
||||||
|
"errors/binopDifferentLine.pkl",
|
||||||
"errors/parser18.pkl",
|
"errors/parser18.pkl",
|
||||||
"errors/nested1.pkl",
|
"errors/nested1.pkl",
|
||||||
"errors/invalidCharacterEscape.pkl",
|
"errors/invalidCharacterEscape.pkl",
|
||||||
|
|||||||
Reference in New Issue
Block a user