mirror of
https://github.com/chaisql/chai.git
synced 2025-11-03 01:33:31 +08:00
Add parentheses expression
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user