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

Function lexPatterns

conf/lex.go:327–364  ·  view source on GitHub ↗

stateFns lexPatterns reads and emits consecutive file patterns. Strings can be interspersed with comments.

(l *lexer)

Source from the content-addressed store, hash-verified

325// lexPatterns reads and emits consecutive file patterns. Strings can be
326// interspersed with comments.
327func lexPatterns(l *lexer) stateFn {
328 for {
329 n := l.eatSpaceAndComments()
330 if n == eof {
331 l.emit(itemEOF)
332 return nil
333 } else if n == '!' {
334 pk := l.next()
335 if any(pk, quotes) {
336 err := l.acceptQuotedString(pk)
337 if err != nil {
338 l.errorf("%s", err)
339 return nil
340 }
341 l.emit(itemQuotedString)
342 } else if !any(pk, bareStringDisallowed) {
343 l.acceptBareString()
344 l.emit(itemBareString)
345 } else {
346 l.errorf("! must be followed by a string")
347 return nil
348 }
349 } else if any(n, quotes) {
350 err := l.acceptQuotedString(n)
351 if err != nil {
352 l.errorf("%s", err)
353 return nil
354 }
355 l.emit(itemQuotedString)
356 } else if !any(n, bareStringDisallowed) {
357 l.acceptBareString()
358 l.emit(itemBareString)
359 } else {
360 l.backup()
361 return lexBlockStart
362 }
363 }
364}
365
366// lexVariables reads a block of variable declarations.
367func lexVariables(l *lexer) stateFn {

Callers

nothing calls this directly

Calls 8

anyFunction · 0.85
eatSpaceAndCommentsMethod · 0.80
emitMethod · 0.80
acceptQuotedStringMethod · 0.80
acceptBareStringMethod · 0.80
backupMethod · 0.80
nextMethod · 0.45
errorfMethod · 0.45

Tested by

no test coverage detected