init initializes the matcher.
(prog *syntax.Prog)
| 126 | |
| 127 | // init initializes the matcher. |
| 128 | func (m *matcher) init(prog *syntax.Prog) error { |
| 129 | m.prog = prog |
| 130 | m.dstate = make(map[string]*dstate) |
| 131 | |
| 132 | m.z1.q.Init(uint32(len(prog.Inst))) |
| 133 | m.z2.q.Init(uint32(len(prog.Inst))) |
| 134 | |
| 135 | m.addq(&m.z1.q, uint32(prog.Start), syntax.EmptyBeginLine|syntax.EmptyBeginText) |
| 136 | m.z1.flag = flagBOL | flagBOT |
| 137 | m.start = m.cache(&m.z1) |
| 138 | |
| 139 | m.z1.q.Reset() |
| 140 | m.addq(&m.z1.q, uint32(prog.Start), syntax.EmptyBeginLine) |
| 141 | m.z1.flag = flagBOL |
| 142 | m.startLine = m.cache(&m.z1) |
| 143 | |
| 144 | return nil |
| 145 | } |
| 146 | |
| 147 | // stepEmpty steps runq to nextq expanding according to flag. |
| 148 | func (m *matcher) stepEmpty(runq, nextq *sparse.Set, flag syntax.EmptyOp) { |