summaryrefslogtreecommitdiff
path: root/internal/mapr/token.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/mapr/token.go')
-rw-r--r--internal/mapr/token.go35
1 files changed, 18 insertions, 17 deletions
diff --git a/internal/mapr/token.go b/internal/mapr/token.go
index 77362f7..f287dbc 100644
--- a/internal/mapr/token.go
+++ b/internal/mapr/token.go
@@ -14,22 +14,7 @@ type token struct {
quotesStripped bool
}
-func (t token) isKeyword() bool {
- if !t.isBareword {
- return false
- }
- for _, keyword := range keywords {
- if strings.ToLower(t.str) == keyword {
- return true
- }
- }
- return false
-}
-
-func (t token) String() string {
- return t.str
-}
-
+// tokenize parses a query string into tokens.
func tokenize(queryStr string) []token {
var tokens []token
for i, part := range strings.Split(queryStr, "\"") {
@@ -68,7 +53,7 @@ func tokensConsume(tokens []token) ([]token, []token) {
if length == 0 {
continue
}
- if t.str[0] == '`' && t.str[length-1] == '`' {
+ if length >= 2 && t.str[0] == '`' && t.str[length-1] == '`' {
stripped := t.str[1 : length-1]
//dlog.Common.Trace("stripped", stripped)
t := token{
@@ -105,3 +90,19 @@ func tokensConsumeOptional(tokens []token, optional string) []token {
}
return tokens
}
+
+func (t token) isKeyword() bool {
+ if !t.isBareword {
+ return false
+ }
+ for _, keyword := range keywords {
+ if strings.ToLower(t.str) == keyword {
+ return true
+ }
+ }
+ return false
+}
+
+func (t token) String() string {
+ return t.str
+}