MCPcopy
hub / github.com/kashav/fsql / readQuery

Method readQuery

tokenizer/tokenizer.go:196–232  ·  view source on GitHub ↗

readQuery reads a full string until reaching a closing parentheses. Counts opening parens to ensure that balance is maintained.

()

Source from the content-addressed store, hash-verified

194// readQuery reads a full string until reaching a closing parentheses. Counts
195// opening parens to ensure that balance is maintained.
196func (t *Tokenizer) readQuery() string {
197 var query string
198
199 var count = 1
200 for count > 0 {
201 for unicode.IsSpace(t.current()) {
202 t.input = t.input[1:]
203 }
204
205 word := fmt.Sprintf("%s", t.readWord())
206
207 if t.current() == -1 {
208 break
209 }
210
211 if t.current() == '(' {
212 count++
213 word = "("
214 } else if t.current() == ')' {
215 count--
216 if count <= 0 {
217 query += word
218 break
219 }
220 word = ")"
221 } else if t.currentIs('\'', '`') {
222 word += string(t.current())
223 } else {
224 word += " "
225 }
226
227 query += word
228 t.input = t.input[1:]
229 }
230
231 return query
232}
233
234// readUnitl reads the input starting at start, until reaching a rune in runes.
235func (t *Tokenizer) readUntil(runes ...rune) string {

Callers 2

NextMethod · 0.95
TestTokenizer_ReadQueryFunction · 0.80

Calls 3

currentMethod · 0.95
readWordMethod · 0.95
currentIsMethod · 0.95

Tested by 1

TestTokenizer_ReadQueryFunction · 0.64