MatchLex is our optimized matcher method, matching tkey depth as well
(lx *lexer.Lex, tkey token.KeyToken, isCat, isSubCat bool, cp lexer.Pos)
| 177 | |
| 178 | // MatchLex is our optimized matcher method, matching tkey depth as well |
| 179 | func (ps *State) MatchLex(lx *lexer.Lex, tkey token.KeyToken, isCat, isSubCat bool, cp lexer.Pos) bool { |
| 180 | if lx.Token.Depth != tkey.Depth { |
| 181 | return false |
| 182 | } |
| 183 | if !(lx.Token.Token == tkey.Token || (isCat && lx.Token.Token.Cat() == tkey.Token) || (isSubCat && lx.Token.Token.SubCat() == tkey.Token)) { |
| 184 | return false |
| 185 | } |
| 186 | if tkey.Key == "" { |
| 187 | return true |
| 188 | } |
| 189 | return tkey.Key == lx.Token.Key |
| 190 | } |
| 191 | |
| 192 | // FindToken looks for token in given region, returns position where found, false if not. |
| 193 | // Only matches when depth is same as at reg.St start at the start of the search. |
no test coverage detected