diff --git a/lib/grammar.js b/lib/grammar.js index 187eebb0..65ac4c6c 100644 --- a/lib/grammar.js +++ b/lib/grammar.js @@ -604,20 +604,16 @@ // The most basic form of *if* is a condition and an action. The following // if-related rules are broken up along these lines in order to avoid // ambiguity. - IfStart: [ + IfBlock: [ o("IF Expression Block", function() { return new IfNode($2, $3); }), o("UNLESS Expression Block", function() { return new IfNode($2, $3, { invert: true }); - }), o("IfStart ELSE IF Expression Block", function() { + }), o("IfBlock ELSE IF Expression Block", function() { return $1.addElse((new IfNode($4, $5)).forceStatement()); - }) - ], - // An **IfStart** can optionally be followed by an else block. - IfBlock: [ - o("IfStart"), o("IfStart ELSE Block", function() { + }), o("IfBlock ELSE Block", function() { return $1.addElse($3); }) ], diff --git a/src/grammar.coffee b/src/grammar.coffee index b26b31b1..6c82d941 100644 --- a/src/grammar.coffee +++ b/src/grammar.coffee @@ -481,16 +481,11 @@ grammar: { # The most basic form of *if* is a condition and an action. The following # if-related rules are broken up along these lines in order to avoid # ambiguity. - IfStart: [ + IfBlock: [ o "IF Expression Block", -> new IfNode $2, $3 o "UNLESS Expression Block", -> new IfNode $2, $3, {invert: true} - o "IfStart ELSE IF Expression Block", -> $1.addElse (new IfNode($4, $5)).forceStatement() - ] - - # An **IfStart** can optionally be followed by an else block. - IfBlock: [ - o "IfStart" - o "IfStart ELSE Block", -> $1.addElse $3 + o "IfBlock ELSE IF Expression Block", -> $1.addElse (new IfNode($4, $5)).forceStatement() + o "IfBlock ELSE Block", -> $1.addElse $3 ] # The full complement of *if* expressions, including postfix one-liner