This commit is contained in:
Jeremy Ashkenas 2011-01-10 23:19:31 -05:00
parent 44355f8eef
commit 9b3197c6e8
4 changed files with 18 additions and 8 deletions

View File

@ -481,12 +481,12 @@
return $1.addElse(new If($4, $5, {
type: $3
}));
}), o('IfBlock ELSE Block', function() {
return $1.addElse($3);
})
],
If: [
o('IfBlock'), o('Statement POST_IF Expression', function() {
o('IfBlock'), o('IfBlock ELSE Block', function() {
return $1.addElse($3);
}), o('Statement POST_IF Expression', function() {
return new If($3, Expressions.wrap([$1]), {
type: $2,
statement: true

File diff suppressed because one or more lines are too long

View File

@ -483,13 +483,13 @@ grammar =
IfBlock: [
o 'IF Expression Block', -> new If $2, $3, type: $1
o 'IfBlock ELSE IF Expression Block', -> $1.addElse new If $4, $5, type: $3
o 'IfBlock ELSE Block', -> $1.addElse $3
]
# The full complement of *if* expressions, including postfix one-liner
# *if* and *unless*.
If: [
o 'IfBlock'
o 'IfBlock ELSE Block', -> $1.addElse $3
o 'Statement POST_IF Expression', -> new If $3, Expressions.wrap([$1]), type: $2, statement: true
o 'Expression POST_IF Expression', -> new If $3, Expressions.wrap([$1]), type: $2, statement: true
]

View File

@ -45,3 +45,13 @@ eq λ, 5
test "don't accidentally stringify keywords", ->
ok (-> this == 'this')() is false
test "#1026", ->
cantCompile '''
if a
b
else
c
else
d
'''