| 804 | } |
| 805 | |
| 806 | func (c *cc) convertUnaryExpr(n *parser.Expr_unaryContext) ast.Node { |
| 807 | op := n.Unary_operator() |
| 808 | if op == nil { |
| 809 | return c.convert(n.Expr()) |
| 810 | } |
| 811 | |
| 812 | // Get the inner expression |
| 813 | expr := c.convert(n.Expr()) |
| 814 | |
| 815 | // Check the operator type |
| 816 | if opCtx, ok := op.(*parser.Unary_operatorContext); ok { |
| 817 | if opCtx.NOT_() != nil { |
| 818 | // NOT expression |
| 819 | return &ast.BoolExpr{ |
| 820 | Boolop: ast.BoolExprTypeNot, |
| 821 | Args: &ast.List{ |
| 822 | Items: []ast.Node{expr}, |
| 823 | }, |
| 824 | } |
| 825 | } |
| 826 | if opCtx.MINUS() != nil { |
| 827 | // Negative number: -expr |
| 828 | return &ast.A_Expr{ |
| 829 | Name: &ast.List{Items: []ast.Node{&ast.String{Str: "-"}}}, |
| 830 | Rexpr: expr, |
| 831 | } |
| 832 | } |
| 833 | if opCtx.PLUS() != nil { |
| 834 | // Positive number: +expr (just return expr) |
| 835 | return expr |
| 836 | } |
| 837 | if opCtx.TILDE() != nil { |
| 838 | // Bitwise NOT: ~expr |
| 839 | return &ast.A_Expr{ |
| 840 | Name: &ast.List{Items: []ast.Node{&ast.String{Str: "~"}}}, |
| 841 | Rexpr: expr, |
| 842 | } |
| 843 | } |
| 844 | } |
| 845 | |
| 846 | return expr |
| 847 | } |
| 848 | |
| 849 | func (c *cc) convertParam(n *parser.Expr_bindContext) ast.Node { |
| 850 | if n.NUMBERED_BIND_PARAMETER() != nil { |