MCPcopy
hub / github.com/hashicorp/hcl / recoverOver

Method recoverOver

hclsyntax/parser.go:2123–2139  ·  view source on GitHub ↗

recoverOver seeks forward in the token stream until it finds a block starting with TokenType "start", then finds the corresponding end token, leaving the peeker pointed at the token after that end token. The given token type _must_ be a bracketer. For example, if the given start token is TokenOBrac

(start TokenType)

Source from the content-addressed store, hash-verified

2121// the next brace-delimited block encountered, or at EOF if no such block
2122// is found or it is unclosed.
2123func (p *parser) recoverOver(start TokenType) {
2124 end := p.oppositeBracket(start)
2125
2126 // find the opening bracket first
2127Token:
2128 for {
2129 tok := p.Read()
2130 switch tok.Type {
2131 case start, TokenEOF:
2132 break Token
2133 }
2134 }
2135
2136 // Now use our existing recover function to locate the _end_ of the
2137 // container we've found.
2138 p.recover(end)
2139}
2140
2141func (p *parser) recoverAfterBodyItem() {
2142 p.recovery = true

Callers 1

Calls 3

oppositeBracketMethod · 0.95
recoverMethod · 0.95
ReadMethod · 0.45

Tested by

no test coverage detected