checkRecursion returns true and trips the recursion limit if depth exceeds the configured limit. The parser bounds two depths separately against maxRecursionDepth: - recursionDepth tracks syntactic expression nesting: each parenthesized expression, list, map or struct element, call argument, index
(depth int)
| 173 | // by recursionDepth) do not add to it. Because operator and selector chains are parsed |
| 174 | // iteratively, this depth is computed bottom-up and checked as each node is built. |
| 175 | func (p *prattParserWorker) checkRecursion(depth int) bool { |
| 176 | if depth > p.maxRecursionDepth { |
| 177 | if !p.recursionLimitExceeded { |
| 178 | p.recursionLimitExceeded = true |
| 179 | p.errors.internalError(fmt.Sprintf("expression recursion limit exceeded: %d", p.maxRecursionDepth)) |
| 180 | p.peekTok = token{kind: tokEnd, start: p.length, end: p.length} |
| 181 | } |
| 182 | return true |
| 183 | } |
| 184 | return false |
| 185 | } |
| 186 | |
| 187 | func (p *prattParserWorker) nextSignificantToken() token { |
| 188 | if p.isRecoveryLimitExceeded() { |
no test coverage detected