one more bit to pass -- futzing with the if/else chains

This commit is contained in:
Jeremy Ashkenas
2010-02-12 23:35:03 -05:00
parent ee1c9b284a
commit 066ee52615
7 changed files with 36 additions and 27 deletions

View File

@@ -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})
]