MCPcopy
hub / github.com/cortesi/modd / parseBlock

Method parseBlock

conf/parse.go:216–265  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

214}
215
216func (p *parser) parseBlock() *Block {
217 block := &Block{}
218 block.Include, block.Exclude, block.NoCommonFilter = p.collectPatterns()
219 nxt := p.next()
220 if nxt.typ != itemLeftParen {
221 p.errorf("expected block open parentheses, got %q", nxt.val)
222 }
223Loop:
224 for {
225 nxt = p.next()
226 switch nxt.typ {
227 case itemInDir:
228 options := p.collectValues(itemBareString)
229 if len(options) > 0 {
230 p.errorf("indir takes no options")
231 }
232 p.mustNext(itemColon)
233 dir := prepValue(p.mustNext(itemBareString, itemQuotedString))
234 if block.InDir != "" {
235 p.errorf("indir can only be used once per block")
236 }
237 block.InDir = dir
238 case itemDaemon:
239 options := p.collectValues(itemBareString)
240 p.mustNext(itemColon)
241 err := block.addDaemon(
242 prepValue(p.mustNext(itemBareString, itemQuotedString)),
243 options,
244 )
245 if err != nil {
246 p.errorf("%s", err)
247 }
248 case itemPrep:
249 options := p.collectValues(itemBareString)
250 p.mustNext(itemColon)
251 err := block.addPrep(
252 prepValue(p.mustNext(itemBareString, itemQuotedString)),
253 options,
254 )
255 if err != nil {
256 p.errorf("%s", err)
257 }
258 case itemRightParen:
259 break Loop
260 default:
261 p.errorf("unexpected input: %s", nxt.val)
262 }
263 }
264 return block
265}
266
267// Parse parses a string, and returns a completed Config
268func Parse(name string, text string) (*Config, error) {

Callers 1

parseMethod · 0.95

Calls 8

collectPatternsMethod · 0.95
nextMethod · 0.95
errorfMethod · 0.95
collectValuesMethod · 0.95
mustNextMethod · 0.95
addDaemonMethod · 0.95
addPrepMethod · 0.95
prepValueFunction · 0.85

Tested by

no test coverage detected