Move newline handling down into parser.
This lets us make it a grammar feature and not a lexer trick. Newlines are explicitly ignored in some parts of the grammar. This lets, for example, things like "|" ignore the newline when used as an operator, but not when used as a parameter delimiter in a block argument.
This commit is contained in:
@@ -4,7 +4,3 @@ if (false) IO.print("bad") else IO.print("good") // expect: good
|
||||
|
||||
// Allow block body.
|
||||
if (false) null else { IO.print("block") } // expect: block
|
||||
|
||||
// Newline after "else".
|
||||
if (false) IO.print("bad") else
|
||||
IO.print("good") // expect: good
|
||||
|
||||
@@ -8,7 +8,3 @@ if (true) { IO.print("block") } // expect: block
|
||||
// Assignment in if condition.
|
||||
var a = false
|
||||
if (a = true) IO.print(a) // expect: true
|
||||
|
||||
// Newline after "if".
|
||||
if
|
||||
(true) IO.print("good") // expect: good
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
if (true) "ok" else // expect error
|
||||
@@ -0,0 +1,2 @@
|
||||
if // expect error
|
||||
(true) IO.print("bad")
|
||||
Reference in New Issue
Block a user