MCPcopy Create free account
hub / github.com/brimdata/super / expr

Method expr

compiler/sfmt/ast.go:71–292  ·  view source on GitHub ↗
(e ast.Expr, parent string)

Source from the content-addressed store, hash-verified

69}
70
71func (c *canon) expr(e ast.Expr, parent string) {
72 switch e := e.(type) {
73 case nil:
74 c.write("null")
75 case *ast.AggFuncExpr:
76 var distinct string
77 if e.Distinct {
78 distinct = "distinct "
79 }
80 c.write("%s(%s", e.Name, distinct)
81 if e.Expr != nil {
82 c.expr(e.Expr, "")
83 }
84 c.write(")")
85 if e.Filter != nil {
86 c.write(" filter ")
87 c.expr(e.Filter, "")
88 }
89 case *ast.SQLAsExpr:
90 c.expr(e.Expr, "")
91 if e.Label != nil {
92 c.write(" as %s", e.Label.Name)
93 }
94 case *ast.Primitive:
95 c.literal(*e)
96 case *ast.IDExpr:
97 c.write(e.Name)
98 case *ast.DoubleQuoteExpr:
99 c.write("%q", e.Text)
100 case *ast.UnaryExpr:
101 c.write(e.Op)
102 c.expr(e.Operand, "not")
103 case *ast.BinaryExpr:
104 c.binary(e, parent)
105 case *ast.CondExpr:
106 c.write("(")
107 c.expr(e.Cond, "")
108 c.write(") ? ")
109 c.expr(e.Then, "")
110 c.write(" : ")
111 c.expr(e.Else, "")
112 case *ast.CallExpr:
113 c.funcRefAsCall(e.Func)
114 c.write("(")
115 c.exprs(e.Args)
116 c.write(")")
117 case *ast.CaseExpr:
118 c.write("case")
119 if e.Expr != nil {
120 c.write(" ")
121 c.expr(e.Expr, "")
122 }
123 for _, when := range e.Whens {
124 c.write(" when ")
125 c.expr(when.Cond, "")
126 c.write(" then ")
127 c.expr(when.Then, "")
128 }

Callers 15

ASTExprFunction · 0.95
assignmentMethod · 0.95
exprsMethod · 0.95
funcRefAsCallMethod · 0.95
lambdaMethod · 0.95
arrayElemsMethod · 0.95
binaryMethod · 0.95
declMethod · 0.95
opMethod · 0.95
sqlQueryBodyMethod · 0.95
funcOrExprsMethod · 0.95
fromSourceMethod · 0.95

Calls 14

binaryMethod · 0.95
funcRefAsCallMethod · 0.95
exprsMethod · 0.95
arrayElemsMethod · 0.95
seqMethod · 0.95
QuotedNameFunction · 0.92
QuotedStringFunction · 0.92
literalMethod · 0.80
retMethod · 0.80
typMethod · 0.65
writeMethod · 0.45
openMethod · 0.45

Tested by

no test coverage detected