Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Permitting rhs properties in filters #161

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion optimade.md
Original file line number Diff line number Diff line change
Expand Up @@ -1287,8 +1287,22 @@ In addition to the standard equality and inequality operators, matching of parti

OPTIONAL features:

The following comparison operators are OPTIONAL:

* `identfier LIKE x`

* `identfier UNLIKE x`

* Support for x to be an identifier, rather than a string is OPTIONAL.

If implemented, the "LIKE" operator MUST behave as the correspoding standard SQL operator. In particular,
The `x` string MUST be interpreted as a pattern where an underscore character ('_', ASCII DEC 95, HEX 5F)
matches any single character and a percent character ('%', ASCII DEC 37, HEX 25) matches an arbitrary
sequence of characters (including zero characters).

If operator "UNLIKE" is supported, the bahavior of this oprtator MUST be the negation of the "LIKE" operator; i.e.
an expression `(property UNLIKE "value")" must behave exactly as `(NOT (property LIKE "value"))`.

Examples:

* `chemical_formula_anonymous CONTAINS "C2" AND chemical_formula_anonymous STARTS WITH "A2"`
Expand Down Expand Up @@ -2188,7 +2202,11 @@ ValueOpRhs = Operator, Value ;

KnownOpRhs = IS, ( KNOWN | UNKNOWN ) ;

FuzzyStringOpRhs = CONTAINS, String | STARTS, [ WITH ], String | ENDS, [ WITH ], String ;
StringProperty = String | Property ;
(* Support for Property tokens in StringProperty is optional *)

FuzzyStringOpRhs = CONTAINS, StringProperty | STARTS, [ WITH ], StringProperty | ENDS, [ WITH ], StringProperty |
LIKE, StringProperty | NOT, LIKE, StringProperty | UNLIKE, StringProperty ;

SetOpRhs = HAS, ( [ Operator ], Value | ALL, ValueList | ANY, ValueList | ONLY, ValueList ) ;
(* Note: support for ONLY in SetOpRhs is OPTIONAL *)
Expand Down Expand Up @@ -2236,6 +2254,9 @@ ALL = 'A', 'L', 'L', [Spaces] ;
ONLY = 'O', 'N', 'L', 'Y', [Spaces] ;
ANY = 'A', 'N', 'Y', [Spaces] ;

LIKE = 'L', 'I', 'K', 'E', [Spaces];
UNLIKE = 'U', 'N', 'L', 'I', 'K', 'E', [Spaces];

(* OperatorComparison operator tokens: *)

Operator = ( '<', [ '=' ] | '>', [ '=' ] | '=' | '!', '=' ), [Spaces] ;
Expand Down
1 change: 1 addition & 0 deletions tests/cases/Filter_072.inp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
chemical_formula LIKE "H2 O2"
1 change: 1 addition & 0 deletions tests/cases/Filter_072.opt
1 change: 1 addition & 0 deletions tests/cases/Filter_073.inp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
chemical_formula NOT LIKE "C6 H12 O6"
1 change: 1 addition & 0 deletions tests/cases/Filter_073.opt
1 change: 1 addition & 0 deletions tests/cases/Filter_074.inp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
chemical_formula UNLIKE "C6 H12 O6"
1 change: 1 addition & 0 deletions tests/cases/Filter_074.opt
2 changes: 2 additions & 0 deletions tests/cases/Filter_075.inp
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
chemical_formula UNLIKE another_formula

1 change: 1 addition & 0 deletions tests/cases/Filter_075.opt
1 change: 1 addition & 0 deletions tests/cases/Filter_076.inp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"C2 H2" LIKE formula
1 change: 1 addition & 0 deletions tests/cases/Filter_076.opt
4 changes: 3 additions & 1 deletion tests/outputs/Filter_019.out
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ Filter(9999)
Space(9999)
TOKEN_1(9999): " ", line: 1, col: 26
Error: in tests/cases/Filter_019.inp: line 1:
unexpected token "4", expected """
unexpected token "4", expected one of """, "a", "b", "c", "d",
"e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q",
"r", "s", "t", "u", "v", "w", "x", "y", "z", or "_"

chemical_formula CONTAINS 42
^
4 changes: 3 additions & 1 deletion tests/outputs/Filter_020.out
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ Filter(9999)
Space(9999)
TOKEN_1(9999): " ", line: 1, col: 26
Error: in tests/cases/Filter_020.inp: line 1:
unexpected token "S", expected """
unexpected token "S", expected one of """, "a", "b", "c", "d",
"e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q",
"r", "s", "t", "u", "v", "w", "x", "y", "z", or "_"

chemical_formula CONTAINS STARTS "Al"
^
101 changes: 52 additions & 49 deletions tests/outputs/Filter_021.out
Original file line number Diff line number Diff line change
Expand Up @@ -55,22 +55,23 @@ Filter(9999)
Spaces(9999)
Space(9999)
TOKEN_1(9999): " ", line: 1, col: 26
String(9999)
TOKEN_3(9999): """, line: 1, col: 27
EscapedChar(9999)
UnescapedChar(9999)
Letter(9999)
UppercaseLetter(9999)
TOKEN_33(9999): "A", line: 1, col: 28
EscapedChar(9999)
UnescapedChar(9999)
Letter(9999)
LowercaseLetter(9999)
TOKEN_76(9999): "l", line: 1, col: 29
TOKEN_3(9999): """, line: 1, col: 30
Spaces(9999)
Space(9999)
TOKEN_1(9999): " ", line: 1, col: 31
StringProperty(9999)
String(9999)
TOKEN_3(9999): """, line: 1, col: 27
EscapedChar(9999)
UnescapedChar(9999)
Letter(9999)
UppercaseLetter(9999)
TOKEN_33(9999): "A", line: 1, col: 28
EscapedChar(9999)
UnescapedChar(9999)
Letter(9999)
LowercaseLetter(9999)
TOKEN_76(9999): "l", line: 1, col: 29
TOKEN_3(9999): """, line: 1, col: 30
Spaces(9999)
Space(9999)
TOKEN_1(9999): " ", line: 1, col: 31
AND(9999)
TOKEN_33(9999): "A", line: 1, col: 32
TOKEN_46(9999): "N", line: 1, col: 33
Expand Down Expand Up @@ -130,22 +131,23 @@ Filter(9999)
Spaces(9999)
Space(9999)
TOKEN_1(9999): " ", line: 1, col: 59
String(9999)
TOKEN_3(9999): """, line: 1, col: 60
EscapedChar(9999)
UnescapedChar(9999)
Letter(9999)
UppercaseLetter(9999)
TOKEN_33(9999): "A", line: 1, col: 61
EscapedChar(9999)
UnescapedChar(9999)
Letter(9999)
LowercaseLetter(9999)
TOKEN_76(9999): "l", line: 1, col: 62
TOKEN_3(9999): """, line: 1, col: 63
Spaces(9999)
Space(9999)
TOKEN_1(9999): " ", line: 1, col: 64
StringProperty(9999)
String(9999)
TOKEN_3(9999): """, line: 1, col: 60
EscapedChar(9999)
UnescapedChar(9999)
Letter(9999)
UppercaseLetter(9999)
TOKEN_33(9999): "A", line: 1, col: 61
EscapedChar(9999)
UnescapedChar(9999)
Letter(9999)
LowercaseLetter(9999)
TOKEN_76(9999): "l", line: 1, col: 62
TOKEN_3(9999): """, line: 1, col: 63
Spaces(9999)
Space(9999)
TOKEN_1(9999): " ", line: 1, col: 64
AND(9999)
TOKEN_33(9999): "A", line: 1, col: 65
TOKEN_46(9999): "N", line: 1, col: 66
Expand Down Expand Up @@ -203,20 +205,21 @@ Filter(9999)
Spaces(9999)
Space(9999)
TOKEN_1(9999): " ", line: 1, col: 90
String(9999)
TOKEN_3(9999): """, line: 1, col: 91
EscapedChar(9999)
UnescapedChar(9999)
Letter(9999)
UppercaseLetter(9999)
TOKEN_33(9999): "A", line: 1, col: 92
EscapedChar(9999)
UnescapedChar(9999)
Letter(9999)
LowercaseLetter(9999)
TOKEN_76(9999): "l", line: 1, col: 93
TOKEN_3(9999): """, line: 1, col: 94
Spaces(9999)
Space(9999)
nl(9999)
SPECIAL_1(9999): "(...)", line: 1, col: 95
StringProperty(9999)
String(9999)
TOKEN_3(9999): """, line: 1, col: 91
EscapedChar(9999)
UnescapedChar(9999)
Letter(9999)
UppercaseLetter(9999)
TOKEN_33(9999): "A", line: 1, col: 92
EscapedChar(9999)
UnescapedChar(9999)
Letter(9999)
LowercaseLetter(9999)
TOKEN_76(9999): "l", line: 1, col: 93
TOKEN_3(9999): """, line: 1, col: 94
Spaces(9999)
Space(9999)
nl(9999)
SPECIAL_1(9999): "(...)", line: 1, col: 95
9 changes: 6 additions & 3 deletions tests/outputs/Filter_022.out
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,12 @@ Filter(9999)
Spaces(9999)
Space(9999)
TOKEN_1(9999): " ", line: 1, col: 18
FuzzyStringOpRhs(9999)
UNLIKE(9999)
TOKEN_53(9999): "U", line: 1, col: 19
TOKEN_46(9999): "N", line: 1, col: 20
Error: in tests/cases/Filter_022.inp: line 1:
unexpected token "U", expected one of "<", ">", "=", "!", "I",
"C", "S", "E", "H", or ":"
unexpected token "K", expected "L"

prototype_formula UNKNOWN
^
^
2 changes: 1 addition & 1 deletion tests/outputs/Filter_023.out
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Filter(9999)
TOKEN_1(9999): " ", line: 1, col: 9
Error: in tests/cases/Filter_023.inp: line 1:
unexpected token "f", expected one of "<", ">", "=", "!", "I",
"C", "S", "E", "H", or ":"
"C", "S", "E", "L", "N", "U", "H", or ":"

chemical formula IS KNOWN 42
^
Expand Down
2 changes: 1 addition & 1 deletion tests/outputs/Filter_024.out
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Filter(9999)
TOKEN_1(9999): " ", line: 1, col: 17
Error: in tests/cases/Filter_024.inp: line 1:
unexpected token "K", expected one of "<", ">", "=", "!", "I",
"C", "S", "E", "H", or ":"
"C", "S", "E", "L", "N", "U", "H", or ":"

chemical_formula KNOWN
^
8 changes: 5 additions & 3 deletions tests/outputs/Filter_028.out
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@ Filter(9999)
Spaces(9999)
Space(9999)
TOKEN_1(9999): " ", line: 1, col: 9
FuzzyStringOpRhs(9999)
LIKE(9999)
TOKEN_44(9999): "L", line: 1, col: 10
Error: in tests/cases/Filter_028.inp: line 1:
unexpected token "L", expected one of "<", ">", "=", "!", "I",
"C", "S", "E", "H", or ":"
unexpected token "E", expected "I"

elements LENGTH 42
^
^
56 changes: 29 additions & 27 deletions tests/outputs/Filter_059.out
Original file line number Diff line number Diff line change
Expand Up @@ -57,21 +57,22 @@ Filter(9999)
Spaces(9999)
Space(9999)
TOKEN_1(9999): " ", line: 1, col: 27
String(9999)
TOKEN_3(9999): """, line: 1, col: 28
EscapedChar(9999)
UnescapedChar(9999)
Letter(9999)
UppercaseLetter(9999)
TOKEN_35(9999): "C", line: 1, col: 29
EscapedChar(9999)
UnescapedChar(9999)
Digit(9999)
TOKEN_18(9999): "2", line: 1, col: 30
TOKEN_3(9999): """, line: 1, col: 31
Spaces(9999)
Space(9999)
TOKEN_1(9999): " ", line: 1, col: 32
StringProperty(9999)
String(9999)
TOKEN_3(9999): """, line: 1, col: 28
EscapedChar(9999)
UnescapedChar(9999)
Letter(9999)
UppercaseLetter(9999)
TOKEN_35(9999): "C", line: 1, col: 29
EscapedChar(9999)
UnescapedChar(9999)
Digit(9999)
TOKEN_18(9999): "2", line: 1, col: 30
TOKEN_3(9999): """, line: 1, col: 31
Spaces(9999)
Space(9999)
TOKEN_1(9999): " ", line: 1, col: 32
AND(9999)
TOKEN_33(9999): "A", line: 1, col: 33
TOKEN_46(9999): "N", line: 1, col: 34
Expand Down Expand Up @@ -141,15 +142,16 @@ Filter(9999)
Spaces(9999)
Space(9999)
TOKEN_1(9999): " ", line: 1, col: 66
String(9999)
TOKEN_3(9999): """, line: 1, col: 67
EscapedChar(9999)
UnescapedChar(9999)
Letter(9999)
UppercaseLetter(9999)
TOKEN_33(9999): "A", line: 1, col: 68
EscapedChar(9999)
UnescapedChar(9999)
Digit(9999)
TOKEN_18(9999): "2", line: 1, col: 69
TOKEN_3(9999): """, line: 1, col: 70
StringProperty(9999)
String(9999)
TOKEN_3(9999): """, line: 1, col: 67
EscapedChar(9999)
UnescapedChar(9999)
Letter(9999)
UppercaseLetter(9999)
TOKEN_33(9999): "A", line: 1, col: 68
EscapedChar(9999)
UnescapedChar(9999)
Digit(9999)
TOKEN_18(9999): "2", line: 1, col: 69
TOKEN_3(9999): """, line: 1, col: 70
56 changes: 29 additions & 27 deletions tests/outputs/Filter_060.out
Original file line number Diff line number Diff line change
Expand Up @@ -55,21 +55,22 @@ Filter(9999)
Spaces(9999)
Space(9999)
TOKEN_1(9999): " ", line: 1, col: 25
String(9999)
TOKEN_3(9999): """, line: 1, col: 26
EscapedChar(9999)
UnescapedChar(9999)
Letter(9999)
UppercaseLetter(9999)
TOKEN_34(9999): "B", line: 1, col: 27
EscapedChar(9999)
UnescapedChar(9999)
Digit(9999)
TOKEN_18(9999): "2", line: 1, col: 28
TOKEN_3(9999): """, line: 1, col: 29
Spaces(9999)
Space(9999)
TOKEN_1(9999): " ", line: 1, col: 30
StringProperty(9999)
String(9999)
TOKEN_3(9999): """, line: 1, col: 26
EscapedChar(9999)
UnescapedChar(9999)
Letter(9999)
UppercaseLetter(9999)
TOKEN_34(9999): "B", line: 1, col: 27
EscapedChar(9999)
UnescapedChar(9999)
Digit(9999)
TOKEN_18(9999): "2", line: 1, col: 28
TOKEN_3(9999): """, line: 1, col: 29
Spaces(9999)
Space(9999)
TOKEN_1(9999): " ", line: 1, col: 30
AND(9999)
TOKEN_33(9999): "A", line: 1, col: 31
TOKEN_46(9999): "N", line: 1, col: 32
Expand Down Expand Up @@ -137,15 +138,16 @@ Filter(9999)
Spaces(9999)
Space(9999)
TOKEN_1(9999): " ", line: 1, col: 62
String(9999)
TOKEN_3(9999): """, line: 1, col: 63
EscapedChar(9999)
UnescapedChar(9999)
Letter(9999)
UppercaseLetter(9999)
TOKEN_36(9999): "D", line: 1, col: 64
EscapedChar(9999)
UnescapedChar(9999)
Digit(9999)
TOKEN_18(9999): "2", line: 1, col: 65
TOKEN_3(9999): """, line: 1, col: 66
StringProperty(9999)
String(9999)
TOKEN_3(9999): """, line: 1, col: 63
EscapedChar(9999)
UnescapedChar(9999)
Letter(9999)
UppercaseLetter(9999)
TOKEN_36(9999): "D", line: 1, col: 64
EscapedChar(9999)
UnescapedChar(9999)
Digit(9999)
TOKEN_18(9999): "2", line: 1, col: 65
TOKEN_3(9999): """, line: 1, col: 66
Loading