v2: make array append `<<` right associative

pull/3929/head
Joe Conigliaro 2020-03-04 02:05:16 +11:00
parent 147ecc5e17
commit 063ca3b644
1 changed files with 13 additions and 0 deletions

View File

@ -828,6 +828,19 @@ pub fn (p mut Parser) expr(precedence int) (ast.Expr,table.Type) {
typ: typ typ: typ
} }
} }
// `arr << 'a'` | `arr << 'a' + 'b'`
else if p.tok.kind == .left_shift {
tok := p.tok
p.next()
mut right := ast.Expr{}
right, typ = p.expr(precedence-1)
node = ast.InfixExpr{
left: node
right: right
op: tok.kind
pos: tok.position()
}
}
else if p.tok.kind.is_infix() { else if p.tok.kind.is_infix() {
node,typ = p.infix_expr(node) node,typ = p.infix_expr(node)
} }