Skip to content

Commit

Permalink
parser: parseBinaryExpr check tuple
Browse files Browse the repository at this point in the history
  • Loading branch information
visualfc committed Jul 4, 2022
1 parent ba0cf41 commit 8c96f79
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions parser/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -2026,20 +2026,26 @@ func (p *parser) parseBinaryExpr(lhs bool, prec1 int, allowTuple, allowCmd bool)
defer un(trace(p, "BinaryExpr"))
}

if x, isTuple = p.parseUnaryExpr(lhs, allowTuple, allowCmd); isTuple {
return
}
x, isTuple = p.parseUnaryExpr(lhs, allowTuple, allowCmd)
for {
op, oprec := p.tokPrec()
if oprec < prec1 {
return
}
if isTuple {
p.error(x.(*tupleExpr).opening, "tuple is not supported")
return
}
pos := p.expect(op)
if lhs {
p.resolve(x)
lhs = false
}
y, _ := p.parseBinaryExpr(false, oprec+1, false, false)
y, yIsTuple := p.parseBinaryExpr(false, oprec+1, true, false)
if yIsTuple {
p.error(y.(*tupleExpr).opening, "tuple is not supported")
return
}
x = &ast.BinaryExpr{X: p.checkExpr(x), OpPos: pos, Op: op, Y: p.checkExpr(y)}
}
}
Expand Down

0 comments on commit 8c96f79

Please sign in to comment.