MCPcopy Create free account
hub / github.com/dolthub/doltgresql / scan

Method scan

postgres/parser/parser/scan.go:106–425  ·  view source on GitHub ↗
(lval *sqlSymType)

Source from the content-addressed store, hash-verified

104}
105
106func (s *scanner) scan(lval *sqlSymType) {
107 lval.id = 0
108 lval.pos = int32(s.pos)
109 lval.str = "EOF"
110
111 for {
112 if comment, _, ok := s.skipWhitespace(lval, true); !ok {
113 return
114 } else if comment != "" {
115 lval.str = comment
116 lval.id = BLOCK_COMMENT
117 return
118 } else {
119 break
120 }
121 }
122
123 ch := s.next()
124 if ch == eof {
125 lval.pos = int32(s.pos)
126 return
127 }
128
129 lval.id = int32(ch)
130 lval.pos = int32(s.pos - 1)
131 lval.str = s.in[lval.pos:s.pos]
132
133 switch ch {
134 case '$':
135 // placeholder? $[0-9]+
136 if lex.IsDigit(s.peek()) {
137 s.scanPlaceholder(lval)
138 return
139 } else if s.scanDollarQuotedString(lval) {
140 lval.id = SCONST
141 return
142 }
143 return
144
145 case identQuote:
146 // "[^"]"
147 if s.scanString(lval, identQuote, false /* allowEscapes */, true /* requireUTF8 */) {
148 lval.id = IDENT
149 }
150 return
151
152 case singleQuote:
153 // '[^']'
154 if s.scanString(lval, ch, false /* allowEscapes */, true /* requireUTF8 */) {
155 lval.id = SCONST
156 }
157 return
158
159 case 'b':
160 // Bytes?
161 if s.peek() == singleQuote {
162 // b'[^']'
163 s.pos++

Callers 4

SplitFirstStatementFunction · 0.80
TokensFunction · 0.80
LastLexicalTokenFunction · 0.80
scanOneStmtMethod · 0.80

Calls 13

skipWhitespaceMethod · 0.95
nextMethod · 0.95
peekMethod · 0.95
scanPlaceholderMethod · 0.95
scanStringMethod · 0.95
scanIdentMethod · 0.95
scanBitStringMethod · 0.95
scanHexStringMethod · 0.95
scanNumberMethod · 0.95
peekNMethod · 0.95
IsDigitFunction · 0.92

Tested by

no test coverage detected