MCPcopy Create free account
hub / github.com/foxcpp/maddy / NextBlock

Method NextBlock

framework/config/lexer/dispenser.go:130–153  ·  view source on GitHub ↗

NextBlock can be used as the condition of a for loop to load the next token as long as it opens a block or is already in a block. It returns true if a token was loaded, or false when the block's closing curly brace was loaded and thus the block ended. Nested blocks are not supported.

()

Source from the content-addressed store, hash-verified

128// was loaded and thus the block ended. Nested blocks are
129// not supported.
130func (d *Dispenser) NextBlock() bool {
131 if d.nesting > 0 {
132 d.Next()
133 if d.Val() == "}" {
134 d.nesting--
135 return false
136 }
137 return true
138 }
139 if !d.NextArg() { // block must open on same line
140 return false
141 }
142 if d.Val() != "{" {
143 d.cursor-- // roll back if not opening brace
144 return false
145 }
146 d.Next()
147 if d.Val() == "}" {
148 // Open and then closed right away
149 return false
150 }
151 d.nesting++
152 return true
153}
154
155// Val gets the text of the current token. If there is no token
156// loaded, it returns empty string.

Callers 1

TestDispenser_NextBlockFunction · 0.95

Calls 3

NextMethod · 0.95
ValMethod · 0.95
NextArgMethod · 0.95

Tested by 1

TestDispenser_NextBlockFunction · 0.76