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
feat: simple AST for search #1175
Conversation
Signed-off-by: Vladislav Oleshko <vlad@dragonflydb.io>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feel free to disregard any comments you don't like!
cc26d47
to
c398dd8
Compare
Signed-off-by: Vladislav Oleshko <vlad@dragonflydb.io>
I hope @chakaz will be able to help here. |
I'm afraid I've never done anything related to lex, so I'm useless on that area. Perhaps ChatGPT has some experience? :| |
Signed-off-by: Vladislav Oleshko <vlad@dragonflydb.io>
Me neither 🙂 But its fairly simple so far
I asked it, but its not an expert there. Though you can ask it about how to do smth (for example setting precedence for operator without a real token) I've added some more tests to check for correctness |
Co-authored-by: Roy Jacobson <roi.jacobson1@gmail.com> Signed-off-by: Vladislav <vladislav.oleshko@gmail.com>
@@ -58,6 +75,18 @@ class SearchParserTest : public ::testing::Test { | |||
ASSERT_TRUE(caught); \ | |||
} | |||
|
|||
#define CHECK_ALL(...) \ | |||
{ \ | |||
for (auto input : {__VA_ARGS__}) \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a big deal, but I'd prefer to see separate check statements for each input in the test itself. I would be easier to debug as well (we get the line number, and no macros to manually unroll :)
You could, if you want to, add a custom matcher to print the DebugExpr(), but I actually think that it's not as useful if we remove the macros.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The line number is preserved, that's why I use a macro. You have all the info you need.
DebugExpr(), but I actually think that it's not as useful if we remove the macros.
DebugExpr is always useful because it shows you the tree built by the parser
Signed-off-by: Vladislav Oleshko <vlad@dragonflydb.io>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Simplest possible AST for: term, not, and, or