fix |
This commit is contained in:
parent
cc604bea49
commit
d0005d9ccd
|
|
@ -123,7 +123,7 @@ export class Parser {
|
|||
|
||||
// check for parens function call
|
||||
// ex: (ref my-func) my-arg
|
||||
if (expr.type.is('ParenExpr') && !this.isExprEnd())
|
||||
if (expr.type.is('ParenExpr') && !this.isExprEnd() && !this.is($T.Operator, '|'))
|
||||
expr = this.functionCall(expr)
|
||||
|
||||
// if dotget is followed by binary operator, continue parsing as binary expression
|
||||
|
|
|
|||
|
|
@ -176,6 +176,43 @@ describe('pipe expressions', () => {
|
|||
Identifier echo
|
||||
`)
|
||||
})
|
||||
|
||||
test('parenthesized expressions can be piped', () => {
|
||||
expect(`(1 + 2) | echo`).toMatchTree(`
|
||||
PipeExpr
|
||||
ParenExpr
|
||||
BinOp
|
||||
Number 1
|
||||
Plus +
|
||||
Number 2
|
||||
operator |
|
||||
FunctionCallOrIdentifier
|
||||
Identifier echo
|
||||
`)
|
||||
})
|
||||
|
||||
test('complex parenthesized expressions with pipes', () => {
|
||||
expect(`((math.random) * 10 + 1) | math.floor`).toMatchTree(`
|
||||
PipeExpr
|
||||
ParenExpr
|
||||
BinOp
|
||||
BinOp
|
||||
ParenExpr
|
||||
FunctionCallOrIdentifier
|
||||
DotGet
|
||||
IdentifierBeforeDot math
|
||||
Identifier random
|
||||
Star *
|
||||
Number 10
|
||||
Plus +
|
||||
Number 1
|
||||
operator |
|
||||
FunctionCallOrIdentifier
|
||||
DotGet
|
||||
IdentifierBeforeDot math
|
||||
Identifier floor
|
||||
`)
|
||||
})
|
||||
})
|
||||
|
||||
describe('pipe continuation', () => {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user