MCPcopy
hub / github.com/google/mangle / VisitLetStmt

Method VisitLetStmt

parse/parse.go:386–395  ·  view source on GitHub ↗

VisitLetStmt visits a parse tree produced by MangleParser#letStmt.

(ctx *gen.LetStmtContext)

Source from the content-addressed store, hash-verified

384
385// VisitLetStmt visits a parse tree produced by MangleParser#letStmt.
386func (p Parser) VisitLetStmt(ctx *gen.LetStmtContext) any {
387 v := ast.Variable{ctx.VARIABLE().GetText()}
388 rhs := p.Visit(ctx.Term()).(ast.Term)
389 apply, ok := rhs.(ast.ApplyFn)
390 if !ok {
391 p.errors.Add(fmt.Sprintf("expected fn application got %v", rhs), ctx.Term().GetStart().GetLine(), ctx.Term().GetStart().GetColumn())
392 return ast.TransformStmt{&v, ast.ApplyFn{ast.FunctionSym{"fn:b0rk", 0}, nil}}
393 }
394 return ast.TransformStmt{&v, apply}
395}
396
397// VisitLiteralOrFml visits a parse tree produced by literalOrFml
398func (p Parser) VisitLiteralOrFml(ctx *gen.LiteralOrFmlContext) any {

Callers 1

VisitMethod · 0.95

Calls 4

VisitMethod · 0.95
VARIABLEMethod · 0.65
TermMethod · 0.65
AddMethod · 0.65

Tested by

no test coverage detected