Change annotations parsing in bodies of operators
This change only matters in cases of if/when/for/while having braceless blocks Annotations on them are parsed now as on block-level expressions, i.e. they're attached to the whole expression
This commit is contained in:
@@ -4,8 +4,13 @@
|
||||
See [Control structures](control-flow.html)
|
||||
*/
|
||||
|
||||
controlStructureBody
|
||||
: block
|
||||
: blockLevelExpression
|
||||
;
|
||||
|
||||
if
|
||||
: "if" "(" expression ")" expression SEMI? ("else" expression)?
|
||||
: "if" "(" expression ")" controlStructureBody SEMI? ("else" controlStructureBody)?
|
||||
;
|
||||
|
||||
try
|
||||
@@ -27,13 +32,13 @@ loop
|
||||
;
|
||||
|
||||
for
|
||||
: "for" "(" annotations (multipleVariableDeclarations | variableDeclarationEntry) "in" expression ")" expression
|
||||
: "for" "(" annotations (multipleVariableDeclarations | variableDeclarationEntry) "in" expression ")" controlStructureBody
|
||||
;
|
||||
|
||||
while
|
||||
: "while" "(" expression ")" expression
|
||||
: "while" "(" expression ")" controlStructureBody
|
||||
;
|
||||
|
||||
doWhile
|
||||
: "do" expression "while" "(" expression ")"
|
||||
: "do" controlStructureBody "while" "(" expression ")"
|
||||
;
|
||||
|
||||
@@ -172,6 +172,10 @@ declaration
|
||||
|
||||
statement
|
||||
: declaration
|
||||
: blockLevelExpression
|
||||
;
|
||||
|
||||
blockLevelExpression
|
||||
: annotations expression
|
||||
;
|
||||
|
||||
|
||||
@@ -12,12 +12,12 @@ when
|
||||
|
||||
// TODO : consider empty after ->
|
||||
whenEntry
|
||||
: whenCondition{","} "->" expression SEMI
|
||||
: "else" "->" expression SEMI
|
||||
: whenCondition{","} "->" controlStructureBody SEMI
|
||||
: "else" "->" controlStructureBody SEMI
|
||||
;
|
||||
|
||||
whenCondition
|
||||
: expression
|
||||
: ("in" | "!in") expression
|
||||
: ("is" | "!is") isRHS
|
||||
;
|
||||
;
|
||||
|
||||
Reference in New Issue
Block a user