MCPcopy Create free account
hub / github.com/cogentcore/core / MatchLex

Method MatchLex

parse/parser/state.go:179–190  ·  view source on GitHub ↗

MatchLex is our optimized matcher method, matching tkey depth as well

(lx *lexer.Lex, tkey token.KeyToken, isCat, isSubCat bool, cp lexer.Pos)

Source from the content-addressed store, hash-verified

177
178// MatchLex is our optimized matcher method, matching tkey depth as well
179func (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.

Callers 3

FindTokenMethod · 0.95
MatchTokenMethod · 0.95
FindTokenReverseMethod · 0.95

Calls 2

CatMethod · 0.45
SubCatMethod · 0.45

Tested by

no test coverage detected