aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/query
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/query')
-rw-r--r--pkg/query/compiler.go4
-rw-r--r--pkg/query/lexer.go30
-rw-r--r--pkg/query/lexer_test.go2
-rw-r--r--pkg/query/parser.go14
-rw-r--r--pkg/query/parser_test.go2
5 files changed, 12 insertions, 40 deletions
diff --git a/pkg/query/compiler.go b/pkg/query/compiler.go
index 9edfeb5..1e946a6 100644
--- a/pkg/query/compiler.go
+++ b/pkg/query/compiler.go
@@ -99,10 +99,6 @@ func (s Statements) buildCompile(b *strings.Builder, delim string) ([]any, error
} else {
opStr = "!= "
}
- case OP_PIPE:
- opStr = "?op_pipe "
- case OP_ARG:
- opStr = "?op_arg "
default:
return nil, &CompileError{
fmt.Sprintf("unexpected query.opType %#v", op),
diff --git a/pkg/query/lexer.go b/pkg/query/lexer.go
index a421fbc..79b6f0f 100644
--- a/pkg/query/lexer.go
+++ b/pkg/query/lexer.go
@@ -22,16 +22,14 @@ const (
TOK_CLAUSE_END
// statement tokens
- TOK_OP_NEG // negation
- TOK_OP_EQ // equal
- TOK_OP_AP // approximate/fuzzy
- TOK_OP_NE // not equal
- TOK_OP_LT // less than
- TOK_OP_LE // less than or equal
- TOK_OP_GE // greater than or equal
- TOK_OP_GT // greaterthan
- TOK_OP_PIPE // external pipe
- TOK_OP_ARG // external arg
+ TOK_OP_NEG // negation
+ TOK_OP_EQ // equal
+ TOK_OP_AP // approximate/fuzzy
+ TOK_OP_NE // not equal
+ TOK_OP_LT // less than
+ TOK_OP_LE // less than or equal
+ TOK_OP_GE // greater than or equal
+ TOK_OP_GT // greaterthan
// categories
TOK_CAT_PATH
TOK_CAT_TITLE
@@ -79,10 +77,6 @@ func (tokType queryTokenType) String() string {
return "Greater Than or Equal"
case TOK_OP_GT:
return "Greater Than"
- case TOK_OP_PIPE:
- return "Pipe External Command"
- case TOK_OP_ARG:
- return "Argument External Command"
case TOK_CAT_PATH:
return "Filepath Category"
case TOK_CAT_TITLE:
@@ -132,7 +126,7 @@ func (t queryTokenType) isCategory() bool {
return t.Any(TOK_CAT_PATH, TOK_CAT_TITLE, TOK_CAT_AUTHOR, TOK_CAT_DATE, TOK_CAT_FILETIME, TOK_CAT_TAGS, TOK_CAT_LINKS, TOK_CAT_META)
}
func (t queryTokenType) isOperation() bool {
- return t.Any(TOK_OP_EQ, TOK_OP_AP, TOK_OP_NE, TOK_OP_LT, TOK_OP_LE, TOK_OP_GE, TOK_OP_GT, TOK_OP_PIPE, TOK_OP_ARG)
+ return t.Any(TOK_OP_EQ, TOK_OP_AP, TOK_OP_NE, TOK_OP_LT, TOK_OP_LE, TOK_OP_GE, TOK_OP_GT)
}
func (t queryTokenType) isValue() bool {
return t == TOK_VAL_STR || t == TOK_VAL_DATETIME
@@ -227,8 +221,6 @@ func tokenizeOperation(s string) Token {
switch s {
case "!=":
t.Type = TOK_OP_NE
- case "!+":
- t.Type = TOK_OP_ARG
case "<=":
t.Type = TOK_OP_LE
case ">=":
@@ -241,8 +233,6 @@ func tokenizeOperation(s string) Token {
t.Type = TOK_OP_LT
case ">":
t.Type = TOK_OP_GT
- case "!":
- t.Type = TOK_OP_PIPE
}
return t
@@ -331,7 +321,7 @@ func TokensStringify(tokens []Token) string {
func init() {
negPattern := `(?<negation>-?)`
categoryPattern := `(?<category>T|p(?:ath)?|a(?:uthor)?|d(?:ate)?|f(?:iletime)?|t(?:ags|itle)?|l(?:inks)?|m(?:eta)?)`
- opPattern := `(?<operator>!=|!+|<=|>=|=|:|~|<|>|!)`
+ opPattern := `(?<operator>!=|<=|>=|=|:|~|<|>)`
valPattern := `(?<value>".*?"|\S*[^\s\)])`
statementPattern := `(?<statement>` + negPattern + categoryPattern + opPattern + valPattern + `)`
unknownPattern := `(?<unknown>\S*".*?"[^\s)]*|\S*[^\s\)])`
diff --git a/pkg/query/lexer_test.go b/pkg/query/lexer_test.go
index fb329ba..5888902 100644
--- a/pkg/query/lexer_test.go
+++ b/pkg/query/lexer_test.go
@@ -22,8 +22,6 @@ const (
TOK_OP_LE = query.TOK_OP_LE
TOK_OP_GE = query.TOK_OP_GE
TOK_OP_GT = query.TOK_OP_GT
- TOK_OP_PIPE = query.TOK_OP_PIPE
- TOK_OP_ARG = query.TOK_OP_ARG
TOK_CAT_TITLE = query.TOK_CAT_TITLE
TOK_CAT_AUTHOR = query.TOK_CAT_AUTHOR
TOK_CAT_DATE = query.TOK_CAT_DATE
diff --git a/pkg/query/parser.go b/pkg/query/parser.go
index 53681f6..0b33a37 100644
--- a/pkg/query/parser.go
+++ b/pkg/query/parser.go
@@ -36,8 +36,6 @@ const (
OP_LE // less than or equal
OP_GE // greater than or equal
OP_GT // greater than
- OP_PIPE // external pipe
- OP_ARG // external arg
)
type clauseOperator int16
@@ -190,10 +188,6 @@ func (t opType) String() string {
return "Greater Than or Equal"
case OP_GT:
return "Greater Than"
- case OP_PIPE:
- return "Pipe External Command"
- case OP_ARG:
- return "Argument External Command"
default:
return "Invalid"
}
@@ -240,10 +234,6 @@ func tokToOp(t queryTokenType) opType {
return OP_GE
case TOK_OP_GT:
return OP_GT
- case TOK_OP_PIPE:
- return OP_PIPE
- case TOK_OP_ARG:
- return OP_ARG
default:
return OP_UNKNOWN
}
@@ -251,7 +241,7 @@ func tokToOp(t queryTokenType) opType {
// Apply negation to a statements operator
func (s *Statement) Simplify() {
- if s.Negated && s.Operator != OP_PIPE && s.Operator != OP_ARG && s.Operator != OP_AP {
+ if s.Negated && s.Operator != OP_AP {
s.Negated = false
switch s.Operator {
case OP_EQ:
@@ -517,7 +507,7 @@ func Parse(tokens []Token) (*Clause, error) {
stmt := Statement{Category: tokToCat(token.Type)}
clause.Statements = append(clause.Statements, stmt)
}
- case TOK_OP_EQ, TOK_OP_AP, TOK_OP_NE, TOK_OP_LT, TOK_OP_LE, TOK_OP_GE, TOK_OP_GT, TOK_OP_PIPE, TOK_OP_ARG:
+ case TOK_OP_EQ, TOK_OP_AP, TOK_OP_NE, TOK_OP_LT, TOK_OP_LE, TOK_OP_GE, TOK_OP_GT:
if !prevToken.Type.isCategory() {
return nil, &TokenError{
got: token,
diff --git a/pkg/query/parser_test.go b/pkg/query/parser_test.go
index e3ab971..5f68006 100644
--- a/pkg/query/parser_test.go
+++ b/pkg/query/parser_test.go
@@ -26,8 +26,6 @@ const (
OP_LE = query.OP_LE
OP_GE = query.OP_GE
OP_GT = query.OP_GT
- OP_PIPE = query.OP_PIPE
- OP_ARG = query.OP_ARG
)
func TestParse(t *testing.T) {