mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-02-16 10:34:55 -05:00
one more bit to pass -- futzing with the if/else chains
This commit is contained in:
@@ -412,7 +412,11 @@ grammar: {
|
||||
# The most basic form of "if".
|
||||
IfBlock: [
|
||||
o "IF Expression Block", -> new IfNode($2, $3)
|
||||
o "IF Expression Block ElsIfs", -> (new IfNode($2, $3)).add_else($4)
|
||||
]
|
||||
|
||||
IfChain: [
|
||||
o "IfBlock", -> $1
|
||||
o "IfBlock ElsIfs", -> $1.add_else($2)
|
||||
]
|
||||
|
||||
ElsIf: [
|
||||
@@ -427,8 +431,8 @@ grammar: {
|
||||
|
||||
# The full complement of if blocks, including postfix one-liner ifs and unlesses.
|
||||
If: [
|
||||
o "IfBlock", -> $1
|
||||
o "IfBlock ELSE Block", -> $1.add_else($3)
|
||||
o "IfChain", -> $1
|
||||
o "IfChain ELSE Block", -> $1.add_else($3)
|
||||
o "Expression IF Expression", -> new IfNode($3, Expressions.wrap([$1]), null, {statement: true})
|
||||
o "Expression UNLESS Expression", -> new IfNode($3, Expressions.wrap([$1]), null, {statement: true, invert: true})
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user