MCPcopy Index your code
hub / github.com/google/mangle / VisitAppl

Method VisitAppl

parse/parse.go:529–561  ·  view source on GitHub ↗

VisitAppl visits a parse tree produced by MangleParser#Appl.

(ctx *gen.ApplContext)

Source from the content-addressed store, hash-verified

527
528// VisitAppl visits a parse tree produced by MangleParser#Appl.
529func (p Parser) VisitAppl(ctx *gen.ApplContext) any {
530 name := ctx.NAME().GetText()
531
532 if strings.HasPrefix(name, "fn:") {
533 // Either ast.Atom or ast.ApplyFn
534 var args []ast.BaseTerm
535 for _, e := range ctx.AllTerm() {
536 arg := p.Visit(e)
537 baseTerm, ok := arg.(ast.BaseTerm)
538 if !ok {
539 p.errors.Add(fmt.Sprintf("expected base term got %v", arg), e.GetStart().GetLine(), e.GetStart().GetColumn())
540 continue
541 }
542 args = append(args, baseTerm)
543 }
544 fnSym := ast.FunctionSym{name, len(args)}
545 return ast.ApplyFn{fnSym, args}
546 }
547
548 var args []ast.BaseTerm
549 for _, e := range ctx.AllTerm() {
550 arg := p.Visit(e)
551 baseTerm, ok := arg.(ast.BaseTerm)
552 if !ok {
553 p.errors.Add(fmt.Sprintf("expected base term got %v", arg), e.GetStart().GetLine(), e.GetStart().GetColumn())
554 args = append(args, ast.AnyBound)
555 continue
556 }
557 args = append(args, baseTerm)
558 }
559 predicateSym := ast.PredicateSym{ctx.NAME().GetText(), len(args)}
560 return ast.Atom{predicateSym, args}
561}
562
563// VisitMap visits a parse tree produced by MangleParser#Map.
564func (p Parser) VisitMap(ctx *gen.MapContext) any {

Callers 1

VisitMethod · 0.95

Calls 4

VisitMethod · 0.95
NAMEMethod · 0.65
AllTermMethod · 0.65
AddMethod · 0.65

Tested by

no test coverage detected