Init initializes the state at start of parsing
(src *lexer.File, ast *AST)
| 48 | |
| 49 | // Init initializes the state at start of parsing |
| 50 | func (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 | |
| 80 | func (ps *State) ClearAST() { |
| 81 | ps.Syms.ClearAST() |
nothing calls this directly
no test coverage detected