Non-parsing functions Find looks for rules in the tree that contain given string in Rule or Name fields
(find string)
| 1694 | |
| 1695 | // Find looks for rules in the tree that contain given string in Rule or Name fields |
| 1696 | func (pr *Rule) Find(find string) []*Rule { |
| 1697 | var res []*Rule |
| 1698 | pr.WalkDown(func(k tree.Node) bool { |
| 1699 | pri := k.(*Rule) |
| 1700 | if strings.Contains(pri.Rule, find) || strings.Contains(pri.Name, find) { |
| 1701 | res = append(res, pri) |
| 1702 | } |
| 1703 | return true |
| 1704 | }) |
| 1705 | return res |
| 1706 | } |
| 1707 | |
| 1708 | // WriteGrammar outputs the parser rules as a formatted grammar in a BNF-like format |
| 1709 | // it is called recursively |