stepByte steps runq to nextq consuming c and then expanding according to flag. It returns true if a match ends immediately before c. c is either an input byte or endText.
(runq, nextq *sparse.Set, c int, flag syntax.EmptyOp)
| 156 | // It returns true if a match ends immediately before c. |
| 157 | // c is either an input byte or endText. |
| 158 | func (m *matcher) stepByte(runq, nextq *sparse.Set, c int, flag syntax.EmptyOp) (match bool) { |
| 159 | nextq.Reset() |
| 160 | m.addq(nextq, uint32(m.prog.Start), flag) |
| 161 | for _, id := range runq.Dense() { |
| 162 | i := &m.prog.Inst[id] |
| 163 | switch i.Op { |
| 164 | default: |
| 165 | continue |
| 166 | case syntax.InstMatch: |
| 167 | match = true |
| 168 | continue |
| 169 | case instByteRange: |
| 170 | if c == endText { |
| 171 | break |
| 172 | } |
| 173 | lo := int((i.Arg >> 8) & 0xFF) |
| 174 | hi := int(i.Arg & 0xFF) |
| 175 | ch := c |
| 176 | if i.Arg&argFold != 0 && 'a' <= ch && ch <= 'z' { |
| 177 | ch += 'A' - 'a' |
| 178 | } |
| 179 | if lo <= ch && ch <= hi { |
| 180 | m.addq(nextq, i.Out, flag) |
| 181 | } |
| 182 | } |
| 183 | } |
| 184 | return |
| 185 | } |
| 186 | |
| 187 | // addq adds id to the queue, expanding according to flag. |
| 188 | func (m *matcher) addq(q *sparse.Set, id uint32, flag syntax.EmptyOp) { |
no test coverage detected