Removed unprocessed values on a for loop from the grammar.

This commit is contained in:
Tim Jones 2010-03-29 07:32:01 +13:00
parent 6df50399a9
commit 6e0e0767f9
3 changed files with 127 additions and 80 deletions

View File

@ -187,6 +187,7 @@
return new SplatNode($1); return new SplatNode($1);
}) })
], ],
// Variables and properties that can be assigned to.
SimpleAssignable: [o("Identifier", function() { SimpleAssignable: [o("Identifier", function() {
return new ValueNode($1); return new ValueNode($1);
}), o("Value Accessor", function() { }), o("Value Accessor", function() {
@ -285,6 +286,7 @@
return $2.new_instance(); return $2.new_instance();
}), o("Super") }), o("Super")
], ],
// Binds a function call to a context and/or arguments.
Curry: [o("Value <- Arguments", function() { Curry: [o("Value <- Arguments", function() {
return new CurryNode($1, $3); return new CurryNode($1, $3);
}) })
@ -448,7 +450,7 @@
}) })
], ],
// The source of a comprehension is an array or object with an optional filter // The source of a comprehension is an array or object with an optional filter
// clause. If it's an array comprehension, you can also choose to step throug // clause. If it's an array comprehension, you can also choose to step through
// in fixed-size increments. // in fixed-size increments.
ForSource: [o("IN Expression", function() { ForSource: [o("IN Expression", function() {
return { return {
@ -459,12 +461,34 @@
source: $2, source: $2,
object: true object: true
}; };
}), o("ForSource WHEN Expression", function() { }), o("IN Expression WHEN Expression", function() {
$1.filter = $3; return {
return $1; source: $2,
}), o("ForSource BY Expression", function() { filter: $4
$1.step = $3; };
return $1; }), o("OF Expression WHEN Expression", function() {
return {
source: $2,
filter: $4,
object: true
};
}), o("IN Expression BY Expression", function() {
return {
source: $2,
step: $4
};
}), o("IN Expression WHEN Expression BY Expression", function() {
return {
source: $2,
filter: $4,
step: $6
};
}), o("IN Expression BY Expression WHEN Expression", function() {
return {
source: $2,
step: $4,
filter: $6
};
}) })
], ],
// The CoffeeScript switch/when/else block replaces the JavaScript // The CoffeeScript switch/when/else block replaces the JavaScript

File diff suppressed because one or more lines are too long

View File

@ -195,6 +195,7 @@ grammar: {
o "Expression . . .", -> new SplatNode $1 o "Expression . . .", -> new SplatNode $1
] ]
# Variables and properties that can be assigned to.
SimpleAssignable: [ SimpleAssignable: [
o "Identifier", -> new ValueNode $1 o "Identifier", -> new ValueNode $1
o "Value Accessor", -> $1.push $2 o "Value Accessor", -> $1.push $2
@ -278,6 +279,7 @@ grammar: {
o "Super" o "Super"
] ]
# Binds a function call to a context and/or arguments.
Curry: [ Curry: [
o "Value <- Arguments", -> new CurryNode $1, $3 o "Value <- Arguments", -> new CurryNode $1, $3
] ]
@ -420,13 +422,16 @@ grammar: {
] ]
# The source of a comprehension is an array or object with an optional filter # The source of a comprehension is an array or object with an optional filter
# clause. If it's an array comprehension, you can also choose to step throug # clause. If it's an array comprehension, you can also choose to step through
# in fixed-size increments. # in fixed-size increments.
ForSource: [ ForSource: [
o "IN Expression", -> {source: $2} o "IN Expression", -> {source: $2}
o "OF Expression", -> {source: $2, object: true} o "OF Expression", -> {source: $2, object: true}
o "ForSource WHEN Expression", -> $1.filter: $3; $1 o "IN Expression WHEN Expression", -> {source: $2, filter: $4}
o "ForSource BY Expression", -> $1.step: $3; $1 o "OF Expression WHEN Expression", -> {source: $2, filter: $4, object: true}
o "IN Expression BY Expression", -> {source: $2, step: $4}
o "IN Expression WHEN Expression BY Expression", -> {source: $2, filter: $4; step: $6}
o "IN Expression BY Expression WHEN Expression", -> {source: $2, step: $4, filter: $6}
] ]
# The CoffeeScript switch/when/else block replaces the JavaScript # The CoffeeScript switch/when/else block replaces the JavaScript