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

Method Out

parse/parser/trace.go:108–149  ·  view source on GitHub ↗

Out outputs a trace message -- returns true if actually output

(ps *State, pr *Rule, step Steps, pos lexer.Pos, scope lexer.Reg, ast *AST, msg string)

Source from the content-addressed store, hash-verified

106
107// Out outputs a trace message -- returns true if actually output
108func (pt *TraceOptions) Out(ps *State, pr *Rule, step Steps, pos lexer.Pos, scope lexer.Reg, ast *AST, msg string) bool {
109 if !pt.On {
110 return false
111 }
112 if !pt.CheckRule(pr.Name) {
113 return false
114 }
115 switch step {
116 case Match:
117 if !pt.Match {
118 return false
119 }
120 case SubMatch:
121 if !pt.SubMatch {
122 return false
123 }
124 case NoMatch:
125 if !pt.NoMatch {
126 return false
127 }
128 case Run:
129 if !pt.Run {
130 return false
131 }
132 case RunAct:
133 if !pt.RunAct {
134 return false
135 }
136 }
137 tokSrc := pos.String() + `"` + string(ps.Src.TokenSrc(pos)) + `"`
138 plev := ast.ParentLevel(ps.AST)
139 ind := ""
140 for i := 0; i < plev; i++ {
141 ind += "\t"
142 }
143 fmt.Fprintf(pt.OutWrite, "%v%v:\t %v\t %v\t tok: %v\t scope: %v\t ast: %v\n", ind, pr.Name, step, msg, tokSrc, scope, ast.Path())
144 if pt.ScopeSrc {
145 scopeSrc := ps.Src.TokenRegSrc(scope)
146 fmt.Fprintf(pt.OutWrite, "%v\t%v\n", ind, scopeSrc)
147 }
148 return true
149}
150
151// CopyOpts copies just the options
152func (pt *TraceOptions) CopyOpts(ot *TraceOptions) {

Callers 12

setReturnsMethod · 0.45
tstFunction · 0.45
ParseMethod · 0.45
ScopeMethod · 0.45
MatchMethod · 0.45
MatchOnlyToksMethod · 0.45
MatchMixedMethod · 0.45
MatchNoToksMethod · 0.45
MatchGroupMethod · 0.45
DoRulesMethod · 0.45
DoRulesRevBinExpMethod · 0.45
DoActMethod · 0.45

Calls 6

CheckRuleMethod · 0.95
TokenSrcMethod · 0.80
ParentLevelMethod · 0.80
TokenRegSrcMethod · 0.80
StringMethod · 0.65
PathMethod · 0.45

Tested by 1

tstFunction · 0.36