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

Function lexCommand

conf/lex.go:467–490  ·  view source on GitHub ↗

lexCommand lexes a single command. Commands can either be unquoted and on a single line, or quoted and span multiple lines.

(l *lexer)

Source from the content-addressed store, hash-verified

465// lexCommand lexes a single command. Commands can either be unquoted and on a
466// single line, or quoted and span multiple lines.
467func lexCommand(l *lexer) stateFn {
468 for {
469 n := l.next()
470 if n == '\n' {
471 l.errorf("empty command specification")
472 return nil
473 } else if any(n, quotes) {
474 err := l.acceptQuotedString(n)
475 if err != nil {
476 l.errorf("%s", err)
477 return nil
478 }
479 l.emit(itemQuotedString)
480 return lexInside
481 } else if any(n, spaces) {
482 l.acceptRun(spaces)
483 l.emit(itemSpace)
484 } else {
485 l.acceptLine(true)
486 l.emit(itemBareString)
487 return lexInside
488 }
489 }
490}

Callers

nothing calls this directly

Calls 7

anyFunction · 0.85
acceptQuotedStringMethod · 0.80
emitMethod · 0.80
acceptRunMethod · 0.80
acceptLineMethod · 0.80
nextMethod · 0.45
errorfMethod · 0.45

Tested by

no test coverage detected