mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-05-03 03:00:14 -04:00
disallow multiple else blocks in if/guard syntax
This commit is contained in:
@@ -510,9 +510,10 @@ grammar =
|
||||
# if-related rules are broken up along these lines in order to avoid
|
||||
# ambiguity.
|
||||
IfBlock: [
|
||||
o 'IF INDENT GuardBlock OUTDENT', -> $3.type = $1; $3
|
||||
o 'IF Expression Block', -> new If $2, $3, type: $1
|
||||
o 'IfBlock ELSE IF Expression Block', -> $1.addElse new If $4, $5, type: $3
|
||||
o 'IF INDENT GuardBlock OUTDENT', -> $3.type = $1; $3
|
||||
o 'IF INDENT GuardBlock ELSE Block OUTDENT',-> $3.type = $1; $3.addElse $5; $3
|
||||
]
|
||||
|
||||
# The guard-style form of *if*, where each expression serves as the truthy
|
||||
@@ -520,7 +521,6 @@ grammar =
|
||||
GuardBlock: [
|
||||
o 'Expression Block', -> new If $1, $2
|
||||
o 'GuardBlock TERMINATOR Expression Block', -> $1.addElse new If $3, $4
|
||||
o 'GuardBlock ELSE Block', -> $1.addElse $3
|
||||
]
|
||||
|
||||
# The full complement of *if* expressions, including postfix one-liner
|
||||
|
||||
Reference in New Issue
Block a user