mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-02-16 18:44:56 -05:00
Added Unix-like piping. Allows chaining of function calls where every succeeding call receives as first argument the result of all preceding expressions.
This commit is contained in:
@@ -73,6 +73,7 @@ grammar: {
|
||||
# of many other rules, making them somewhat circular.
|
||||
Expression: [
|
||||
o "Value"
|
||||
o "Pipe"
|
||||
o "Call"
|
||||
o "Curry"
|
||||
o "Code"
|
||||
@@ -259,6 +260,13 @@ grammar: {
|
||||
o "INDENT AssignList , OUTDENT", -> $2
|
||||
]
|
||||
|
||||
# Unix-like pipe for chained function calls. Reverts to `OpNode` for bitwise
|
||||
# operations.
|
||||
Pipe: [
|
||||
o "Expression | Expression", -> new PipeNode $1, $3
|
||||
o "Expression | || Expression", -> new PipeNode $1, $4, true
|
||||
]
|
||||
|
||||
# The three flavors of function call: normal, object instantiation with `new`,
|
||||
# and calling `super()`
|
||||
Call: [
|
||||
@@ -491,7 +499,6 @@ grammar: {
|
||||
o "Expression >> Expression", -> new OpNode '>>', $1, $3
|
||||
o "Expression >>> Expression", -> new OpNode '>>>', $1, $3
|
||||
o "Expression & Expression", -> new OpNode '&', $1, $3
|
||||
o "Expression | Expression", -> new OpNode '|', $1, $3
|
||||
o "Expression ^ Expression", -> new OpNode '^', $1, $3
|
||||
|
||||
o "Expression <= Expression", -> new OpNode '<=', $1, $3
|
||||
|
||||
Reference in New Issue
Block a user