AllocRules allocate the match, nonmatch rule state in correspondence with the src state
()
| 100 | |
| 101 | // AllocRules allocate the match, nonmatch rule state in correspondence with the src state |
| 102 | func (ps *State) AllocRules() { |
| 103 | nlines := ps.Src.NLines() |
| 104 | if nlines == 0 { |
| 105 | return |
| 106 | } |
| 107 | if len(ps.Src.Lexs) != nlines { |
| 108 | return |
| 109 | } |
| 110 | ps.Matches = make([][]MatchStack, nlines) |
| 111 | ntot := 0 |
| 112 | for ln := 0; ln < nlines; ln++ { |
| 113 | sz := len(ps.Src.Lexs[ln]) |
| 114 | if sz > 0 { |
| 115 | ps.Matches[ln] = make([]MatchStack, sz) |
| 116 | ntot += sz |
| 117 | } |
| 118 | } |
| 119 | ps.NonMatches = make(ScopeRuleSet, ntot*10) |
| 120 | } |
| 121 | |
| 122 | // Error adds a parsing error at given lex token position |
| 123 | func (ps *State) Error(pos lexer.Pos, msg string, rule *Rule) { |