MCPcopy Create free account
hub / github.com/cogentcore/core / Init

Method Init

parse/parser/state.go:50–78  ·  view source on GitHub ↗

Init initializes the state at start of parsing

(src *lexer.File, ast *AST)

Source from the content-addressed store, hash-verified

48
49// Init initializes the state at start of parsing
50func (ps *State) Init(src *lexer.File, ast *AST) {
51 // fmt.Println("in init")
52 // if ps.Src != nil {
53 // fmt.Println("was:", ps.Src.Filename)
54 // }
55 // if src != nil {
56 // fmt.Println("new:", src.Filename)
57 // }
58 ps.Src = src
59 if ps.AST != nil && ps.AST.This != nil {
60 // fmt.Println("deleting old ast")
61 ps.AST.DeleteChildren()
62 }
63 ps.AST = ast
64 if ps.AST != nil && ps.AST.This != nil {
65 // fmt.Println("deleting new ast")
66 ps.AST.DeleteChildren()
67 }
68 ps.ClearAST()
69 ps.Syms.Reset()
70 ps.Scopes.Reset()
71 ps.Stack.Reset()
72 if ps.Src != nil {
73 ps.Pos, _ = ps.Src.ValidTokenPos(lexer.PosZero)
74 }
75 ps.Errs.Reset()
76 ps.Trace.Init()
77 ps.AllocRules()
78}
79
80func (ps *State) ClearAST() {
81 ps.Syms.ClearAST()

Callers

nothing calls this directly

Calls 6

ClearASTMethod · 0.95
AllocRulesMethod · 0.95
DeleteChildrenMethod · 0.80
ValidTokenPosMethod · 0.80
InitMethod · 0.65
ResetMethod · 0.45

Tested by

no test coverage detected