MCPcopy
hub / github.com/sqldef/sqldef / Scan

Method Scan

parser/token.go:725–947  ·  view source on GitHub ↗

Scan scans the tokenizer for the next token and returns the token type and an optional value.

()

Source from the content-addressed store, hash-verified

723// Scan scans the tokenizer for the next token and returns
724// the token type and an optional value.
725func (tkn *Tokenizer) Scan() (int, string) {
726 if tkn.specialComment != nil {
727 // Enter specialComment scan mode.
728 // for scanning such kind of comment: /*! MySQL-specific code */
729 specialComment := tkn.specialComment
730 tok, val := specialComment.Scan()
731 if tok != 0 {
732 // return the specialComment scan result as the result
733 return tok, val
734 }
735 // leave specialComment scan mode after all stream consumed.
736 tkn.specialComment = nil
737 }
738 if tkn.lastChar == 0 {
739 tkn.next()
740 }
741
742 tkn.skipBlank()
743 switch ch := tkn.lastChar; {
744 case isIdentifierFirstChar(ch):
745 tkn.next()
746 if ch == 'X' || ch == 'x' {
747 if tkn.lastChar == '\'' {
748 tkn.next()
749 return tkn.scanHex()
750 }
751 }
752 if ch == 'B' || ch == 'b' {
753 if tkn.lastChar == '\'' {
754 tkn.next()
755 return tkn.scanBitLiteral()
756 }
757 }
758 if ch == 'N' {
759 if tkn.lastChar == '\'' {
760 if tkn.mode == ParserModeMssql {
761 tkn.next()
762 return tkn.scanString('\'', UNICODE_STRING)
763 }
764 }
765 }
766 isDbSystemVariable := false
767 if ch == '@' && tkn.lastChar == '@' {
768 isDbSystemVariable = true
769 }
770 return tkn.scanIdentifier(ch, isDbSystemVariable)
771 case isAsciiDigit(ch):
772 return tkn.scanNumber(false)
773 case ch == ':':
774 return tkn.scanBindVar()
775 case ch == ';' && tkn.multi:
776 return 0, ""
777 default:
778 tkn.next()
779 switch ch {
780 case eofChar:
781 return 0, ""
782 case '=', ',', ';', '(', ')', '[', ']', '+', '*', '%', '^', '~':

Callers 15

LexMethod · 0.95
scanCommentType2Method · 0.95
peekTokenMethod · 0.95
peekTwoTokensMethod · 0.95
extractEnumValueCommentsFunction · 0.95
extractTableCommentFunction · 0.95
extractColumnCommentsFunction · 0.95
extractIndexCommentsFunction · 0.95
supportsConperiodMethod · 0.80
tableNamesMethod · 0.80
partitionChildTablesMethod · 0.80

Calls 15

nextMethod · 0.95
skipBlankMethod · 0.95
scanHexMethod · 0.95
scanBitLiteralMethod · 0.95
scanStringMethod · 0.95
scanIdentifierMethod · 0.95
scanNumberMethod · 0.95
scanBindVarMethod · 0.95
scanLiteralIdentifierMethod · 0.95
scanCommentType1Method · 0.95
scanCommentType2Method · 0.95