mirror of
https://github.com/jashkenas/coffeescript.git
synced 2022-11-09 12:23:24 -05:00
adding 'unless' blocks
This commit is contained in:
parent
92af641827
commit
b746c9018e
4 changed files with 77 additions and 59 deletions
|
@ -594,6 +594,10 @@
|
||||||
IfStart: [
|
IfStart: [
|
||||||
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() {
|
||||||
|
return new IfNode($2, $3, null, {
|
||||||
|
invert: true
|
||||||
|
});
|
||||||
}), o("IfStart ElsIf", function() {
|
}), o("IfStart ElsIf", function() {
|
||||||
return $1.add_else($2);
|
return $1.add_else($2);
|
||||||
})
|
})
|
||||||
|
|
122
lib/parser.js
122
lib/parser.js
File diff suppressed because one or more lines are too long
|
@ -488,6 +488,7 @@ grammar: {
|
||||||
# ambiguity.
|
# ambiguity.
|
||||||
IfStart: [
|
IfStart: [
|
||||||
o "IF Expression Block", -> new IfNode $2, $3
|
o "IF Expression Block", -> new IfNode $2, $3
|
||||||
|
o "UNLESS Expression Block", -> new IfNode $2, $3, null, {invert: true}
|
||||||
o "IfStart ElsIf", -> $1.add_else $2
|
o "IfStart ElsIf", -> $1.add_else $2
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
@ -33,3 +33,12 @@ else
|
||||||
27
|
27
|
||||||
|
|
||||||
ok result is 27
|
ok result is 27
|
||||||
|
|
||||||
|
|
||||||
|
# Testing unless.
|
||||||
|
result: unless true
|
||||||
|
10
|
||||||
|
else
|
||||||
|
11
|
||||||
|
|
||||||
|
ok result is 11
|
||||||
|
|
Loading…
Add table
Reference in a new issue