MCPcopy Index your code
hub / github.com/Shopify/go-lua / scan

Method scan

scanner.go:412–504  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

410}
411
412func (s *scanner) scan() token {
413 const comment, str = true, false
414 for {
415 switch c := s.current; c {
416 case '\n', '\r':
417 s.incrementLineNumber()
418 case ' ', '\f', '\t', '\v':
419 s.advance()
420 case '-':
421 if s.advance(); s.current != '-' {
422 return token{t: '-'}
423 }
424 if s.advance(); s.current == '[' {
425 if sep := s.skipSeparator(); sep >= 0 {
426 _ = s.readMultiLine(comment, sep)
427 break
428 }
429 s.buffer.Reset()
430 }
431 for !isNewLine(s.current) && s.current != endOfStream {
432 s.advance()
433 }
434 case '[':
435 if sep := s.skipSeparator(); sep >= 0 {
436 return token{t: tkString, s: s.readMultiLine(str, sep)}
437 } else if s.buffer.Reset(); sep == -1 {
438 return token{t: '['}
439 }
440 s.scanError("invalid long string delimiter", tkString)
441 case '=':
442 if s.advance(); s.current != '=' {
443 return token{t: '='}
444 }
445 s.advance()
446 return token{t: tkEq}
447 case '<':
448 if s.advance(); s.current != '=' {
449 return token{t: '<'}
450 }
451 s.advance()
452 return token{t: tkLE}
453 case '>':
454 if s.advance(); s.current != '=' {
455 return token{t: '>'}
456 }
457 s.advance()
458 return token{t: tkGE}
459 case '~':
460 if s.advance(); s.current != '=' {
461 return token{t: '~'}
462 }
463 s.advance()
464 return token{t: tkNE}
465 case ':':
466 if s.advance(); s.current != ':' {
467 return token{t: ':'}
468 }
469 s.advance()

Callers 4

nextMethod · 0.95
lookAheadMethod · 0.95
parseNumberMethod · 0.95
testScannerFunction · 0.95

Calls 11

incrementLineNumberMethod · 0.95
advanceMethod · 0.95
skipSeparatorMethod · 0.95
readMultiLineMethod · 0.95
scanErrorMethod · 0.95
readStringMethod · 0.95
saveAndAdvanceMethod · 0.95
checkNextMethod · 0.95
readNumberMethod · 0.95
reservedOrNameMethod · 0.95
isNewLineFunction · 0.85

Tested by 1

testScannerFunction · 0.76