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

Method SetRuleMap

parse/parser/rule.go:209–220  ·  view source on GitHub ↗

SetRuleMap is called on the top-level Rule and initializes the RuleMap

(ps *State)

Source from the content-addressed store, hash-verified

207
208// SetRuleMap is called on the top-level Rule and initializes the RuleMap
209func (pr *Rule) SetRuleMap(ps *State) {
210 RuleMap = map[string]*Rule{}
211 pr.WalkDown(func(k tree.Node) bool {
212 pri := k.(*Rule)
213 if epr, has := RuleMap[pri.Name]; has {
214 ps.Error(lexer.PosZero, fmt.Sprintf("Parser Compile: multiple rules with same name: %v and %v", pri.Path(), epr.Path()), pri)
215 } else {
216 RuleMap[pri.Name] = pri
217 }
218 return true
219 })
220}
221
222// CompileAll is called on the top-level Rule to compile all nodes
223// it calls SetRuleMap first.

Callers 2

CompileAllMethod · 0.95
CompileAllMethod · 0.95

Calls 3

WalkDownMethod · 0.80
ErrorMethod · 0.65
PathMethod · 0.45

Tested by 1

CompileAllMethod · 0.76