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

Method MatchToken

parse/parser/state.go:220–227  ·  view source on GitHub ↗

MatchToken returns true if token matches at given position -- must be a valid position!

(tkey token.KeyToken, pos lexer.Pos)

Source from the content-addressed store, hash-verified

218// MatchToken returns true if token matches at given position -- must be
219// a valid position!
220func (ps *State) MatchToken(tkey token.KeyToken, pos lexer.Pos) bool {
221 tok := tkey.Token
222 isCat := tok.Cat() == tok
223 isSubCat := tok.SubCat() == tok
224 lx := ps.Src.LexAt(pos)
225 tkey.Depth = lx.Token.Depth
226 return ps.MatchLex(lx, tkey, isCat, isSubCat, pos)
227}
228
229// FindTokenReverse looks *backwards* for token in given region, with same depth as reg.Ed-1 end
230// where the search starts. Returns position where found, false if not.

Callers

nothing calls this directly

Calls 4

MatchLexMethod · 0.95
LexAtMethod · 0.80
CatMethod · 0.45
SubCatMethod · 0.45

Tested by

no test coverage detected