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

Function lexVariables

conf/lex.go:367–400  ·  view source on GitHub ↗

lexVariables reads a block of variable declarations.

(l *lexer)

Source from the content-addressed store, hash-verified

365
366// lexVariables reads a block of variable declarations.
367func lexVariables(l *lexer) stateFn {
368 for {
369 n := l.eatSpaceAndComments()
370 if n == '@' {
371 l.acceptWord()
372 l.emit(itemVarName)
373 n = l.maybeSpace()
374 if n == '=' {
375 l.emit(itemEquals)
376 }
377 n = l.maybeSpace()
378 if n == eof {
379 l.errorf("unterminated variable assignment")
380 return nil
381 } else if any(n, quotes) {
382 err := l.acceptQuotedString(n)
383 if err != nil {
384 l.errorf("%s", err)
385 return nil
386 }
387 l.emit(itemQuotedString)
388 } else if !any(n, bareStringDisallowed) {
389 l.acceptLine(true)
390 l.emit(itemBareString)
391 } else {
392 l.errorf("= must be followed by a string")
393 return nil
394 }
395 } else {
396 l.backup()
397 return lexPatterns
398 }
399 }
400}
401
402func lexTop(l *lexer) stateFn {
403 return lexVariables

Callers

nothing calls this directly

Calls 9

anyFunction · 0.85
eatSpaceAndCommentsMethod · 0.80
acceptWordMethod · 0.80
emitMethod · 0.80
maybeSpaceMethod · 0.80
acceptQuotedStringMethod · 0.80
acceptLineMethod · 0.80
backupMethod · 0.80
errorfMethod · 0.45

Tested by

no test coverage detected