adding 'unless' blocks

This commit is contained in:
Jeremy Ashkenas 2010-04-27 19:35:15 -04:00
parent 92af641827
commit b746c9018e
4 changed files with 77 additions and 59 deletions

View File

@ -594,6 +594,10 @@
IfStart: [
o("IF Expression Block", function() {
return new IfNode($2, $3);
}), o("UNLESS Expression Block", function() {
return new IfNode($2, $3, null, {
invert: true
});
}), o("IfStart ElsIf", function() {
return $1.add_else($2);
})

File diff suppressed because one or more lines are too long

View File

@ -488,6 +488,7 @@ grammar: {
# ambiguity.
IfStart: [
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
]

View File

@ -33,3 +33,12 @@ else
27
ok result is 27
# Testing unless.
result: unless true
10
else
11
ok result is 11