Add parentheses expression

This commit is contained in:
Asdine El Hrychy
2020-07-19 15:11:14 +02:00
parent 6203af7dc9
commit 347e3c7f03
2 changed files with 21 additions and 2 deletions

View File

@@ -209,8 +209,14 @@ func (p *Parser) parseUnaryExpr() (expr.Expr, error) {
p.Unscan()
return p.parseExprList(scanner.LSBRACKET, scanner.RSBRACKET)
case scanner.LPAREN:
p.Unscan()
return p.parseExprList(scanner.LPAREN, scanner.RPAREN)
e, _, err := p.ParseExpr()
if err != nil {
return nil, err
}
if tok, pos, lit := p.ScanIgnoreWhitespace(); tok != scanner.RPAREN {
return nil, newParseError(scanner.Tokstr(tok, lit), []string{")"}, pos)
}
return expr.Parentheses{E: e}, nil
default:
return nil, newParseError(scanner.Tokstr(tok, lit), []string{"identifier", "string", "number", "bool"}, pos)
}