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

@@ -485,8 +485,12 @@
// The most basic form of "if".
IfBlock: [o("IF Expression Block", function() {
return new IfNode($2, $3);
}), o("IF Expression Block ElsIfs", function() {
return (new IfNode($2, $3)).add_else($4);
})
],
IfChain: [o("IfBlock", function() {
return $1;
}), o("IfBlock ElsIfs", function() {
return $1.add_else($2);
})
],
ElsIf: [o("ELSEIF Expression Block", function() {
@@ -501,9 +505,9 @@
})
],
// The full complement of if blocks, including postfix one-liner ifs and unlesses.
If: [o("IfBlock", function() {
If: [o("IfChain", function() {
return $1;
}), o("IfBlock ELSE Block", function() {
}), o("IfChain ELSE Block", function() {
return $1.add_else($3);
}), o("Expression IF Expression", function() {
return new IfNode($3, Expressions.wrap([$1]), null, {