slight simplification to if/else in the grammar.
This commit is contained in:
parent
0222d90fa3
commit
969740a263
|
@ -614,8 +614,8 @@
|
|||
return new IfNode($2, $3, {
|
||||
invert: true
|
||||
});
|
||||
}), o("IfStart ElsIf", function() {
|
||||
return $1.add_else($2);
|
||||
}), o("IfStart ELSE IF Expression Block", function() {
|
||||
return $1.add_else((new IfNode($4, $5)).force_statement());
|
||||
})
|
||||
],
|
||||
// An **IfStart** can optionally be followed by an else block.
|
||||
|
@ -624,12 +624,6 @@
|
|||
return $1.add_else($3);
|
||||
})
|
||||
],
|
||||
// An *else if* continuation of the *if* expression.
|
||||
ElsIf: [
|
||||
o("ELSE IF Expression Block", function() {
|
||||
return (new IfNode($3, $4)).force_statement();
|
||||
})
|
||||
],
|
||||
// The full complement of *if* expressions, including postfix one-liner
|
||||
// *if* and *unless*.
|
||||
If: [
|
||||
|
|
106
lib/parser.js
106
lib/parser.js
File diff suppressed because one or more lines are too long
|
@ -491,7 +491,7 @@ grammar: {
|
|||
IfStart: [
|
||||
o "IF Expression Block", -> new IfNode $2, $3
|
||||
o "UNLESS Expression Block", -> new IfNode $2, $3, {invert: true}
|
||||
o "IfStart ElsIf", -> $1.add_else $2
|
||||
o "IfStart ELSE IF Expression Block", -> $1.add_else (new IfNode($4, $5)).force_statement()
|
||||
]
|
||||
|
||||
# An **IfStart** can optionally be followed by an else block.
|
||||
|
@ -500,11 +500,6 @@ grammar: {
|
|||
o "IfStart ELSE Block", -> $1.add_else $3
|
||||
]
|
||||
|
||||
# An *else if* continuation of the *if* expression.
|
||||
ElsIf: [
|
||||
o "ELSE IF Expression Block", -> (new IfNode($3, $4)).force_statement()
|
||||
]
|
||||
|
||||
# The full complement of *if* expressions, including postfix one-liner
|
||||
# *if* and *unless*.
|
||||
If: [
|
||||
|
|
Loading…
Reference in New Issue