SetRuleMap is called on the top-level Rule and initializes the RuleMap
(ps *State)
| 207 | |
| 208 | // SetRuleMap is called on the top-level Rule and initializes the RuleMap |
| 209 | func (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. |