mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-04-11 03:00:13 -04:00
slight simplification of the if-else grammar rules
This commit is contained in:
@@ -604,20 +604,16 @@
|
|||||||
// The most basic form of *if* is a condition and an action. The following
|
// 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
|
// if-related rules are broken up along these lines in order to avoid
|
||||||
// ambiguity.
|
// ambiguity.
|
||||||
IfStart: [
|
IfBlock: [
|
||||||
o("IF Expression Block", function() {
|
o("IF Expression Block", function() {
|
||||||
return new IfNode($2, $3);
|
return new IfNode($2, $3);
|
||||||
}), o("UNLESS Expression Block", function() {
|
}), o("UNLESS Expression Block", function() {
|
||||||
return new IfNode($2, $3, {
|
return new IfNode($2, $3, {
|
||||||
invert: true
|
invert: true
|
||||||
});
|
});
|
||||||
}), o("IfStart ELSE IF Expression Block", function() {
|
}), o("IfBlock ELSE IF Expression Block", function() {
|
||||||
return $1.addElse((new IfNode($4, $5)).forceStatement());
|
return $1.addElse((new IfNode($4, $5)).forceStatement());
|
||||||
})
|
}), o("IfBlock ELSE Block", function() {
|
||||||
],
|
|
||||||
// An **IfStart** can optionally be followed by an else block.
|
|
||||||
IfBlock: [
|
|
||||||
o("IfStart"), o("IfStart ELSE Block", function() {
|
|
||||||
return $1.addElse($3);
|
return $1.addElse($3);
|
||||||
})
|
})
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -481,16 +481,11 @@ grammar: {
|
|||||||
# The most basic form of *if* is a condition and an action. The following
|
# 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
|
# if-related rules are broken up along these lines in order to avoid
|
||||||
# ambiguity.
|
# ambiguity.
|
||||||
IfStart: [
|
IfBlock: [
|
||||||
o "IF Expression Block", -> new IfNode $2, $3
|
o "IF Expression Block", -> new IfNode $2, $3
|
||||||
o "UNLESS Expression Block", -> new IfNode $2, $3, {invert: true}
|
o "UNLESS Expression Block", -> new IfNode $2, $3, {invert: true}
|
||||||
o "IfStart ELSE IF Expression Block", -> $1.addElse (new IfNode($4, $5)).forceStatement()
|
o "IfBlock ELSE IF Expression Block", -> $1.addElse (new IfNode($4, $5)).forceStatement()
|
||||||
]
|
o "IfBlock ELSE Block", -> $1.addElse $3
|
||||||
|
|
||||||
# An **IfStart** can optionally be followed by an else block.
|
|
||||||
IfBlock: [
|
|
||||||
o "IfStart"
|
|
||||||
o "IfStart ELSE Block", -> $1.addElse $3
|
|
||||||
]
|
]
|
||||||
|
|
||||||
# The full complement of *if* expressions, including postfix one-liner
|
# The full complement of *if* expressions, including postfix one-liner
|
||||||
|
|||||||
Reference in New Issue
Block a user