aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/query
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/query')
-rw-r--r--pkg/query/lexer.go2
-rw-r--r--pkg/query/lexer_test.go11
2 files changed, 13 insertions, 0 deletions
diff --git a/pkg/query/lexer.go b/pkg/query/lexer.go
index a53f0b4..4d875fb 100644
--- a/pkg/query/lexer.go
+++ b/pkg/query/lexer.go
@@ -339,5 +339,7 @@ func init() {
clausePattern := clauseStart + `\s*` + clauseOpPattern + `\s*(?:` + statementPattern + `|` + unknownPattern + `)\s*` + clauseEnd + `\s*`
LexRegexPattern = clausePattern
+ // FIXME: fails to match start of clauses with no values
+ // ex: (and (or ... )) fails
LexRegex = regexp.MustCompile(LexRegexPattern)
}
diff --git a/pkg/query/lexer_test.go b/pkg/query/lexer_test.go
index d931b96..e88c637 100644
--- a/pkg/query/lexer_test.go
+++ b/pkg/query/lexer_test.go
@@ -94,6 +94,17 @@ func TestLex(t *testing.T) {
{Type: TOK_CLAUSE_END},
{Type: TOK_CLAUSE_END},
}},
+ {"consecutive clause starts", "a:a (or (and a:b a:c) a:d)", []Token{
+ {Type: TOK_CLAUSE_START}, {TOK_CLAUSE_AND, "and"},
+ {TOK_CAT_AUTHOR, "a"}, {TOK_OP_AP, ":"}, {TOK_VAL_STR, "a"},
+ {Type: TOK_CLAUSE_START}, {TOK_CLAUSE_OR, "or"},
+ {Type: TOK_CLAUSE_START}, {TOK_CLAUSE_AND, "and"},
+ {TOK_CAT_AUTHOR, "a"}, {TOK_OP_AP, ":"}, {TOK_VAL_STR, "b"},
+ {TOK_CAT_AUTHOR, "a"}, {TOK_OP_AP, ":"}, {TOK_VAL_STR, "c"},
+ {Type: TOK_CLAUSE_END},
+ {TOK_CAT_AUTHOR, "a"}, {TOK_OP_AP, ":"}, {TOK_VAL_STR, "d"},
+ {Type: TOK_CLAUSE_END},
+ }},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {