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

Method AllocRules

parse/parser/state.go:102–120  ·  view source on GitHub ↗

AllocRules allocate the match, nonmatch rule state in correspondence with the src state

()

Source from the content-addressed store, hash-verified

100
101// AllocRules allocate the match, nonmatch rule state in correspondence with the src state
102func (ps *State) AllocRules() {
103 nlines := ps.Src.NLines()
104 if nlines == 0 {
105 return
106 }
107 if len(ps.Src.Lexs) != nlines {
108 return
109 }
110 ps.Matches = make([][]MatchStack, nlines)
111 ntot := 0
112 for ln := 0; ln < nlines; ln++ {
113 sz := len(ps.Src.Lexs[ln])
114 if sz > 0 {
115 ps.Matches[ln] = make([]MatchStack, sz)
116 ntot += sz
117 }
118 }
119 ps.NonMatches = make(ScopeRuleSet, ntot*10)
120}
121
122// Error adds a parsing error at given lex token position
123func (ps *State) Error(pos lexer.Pos, msg string, rule *Rule) {

Callers 1

InitMethod · 0.95

Calls 1

NLinesMethod · 0.80

Tested by

no test coverage detected