-
Notifications
You must be signed in to change notification settings - Fork 55
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
Refactor expression handling #292
Conversation
Okay @bkamins, @nalimilan this PR is ready for a review. Basically, I was tired of having very complicated code for parsing. I also had the column selection methods hard-coded, which resulted in a lot of brittle code. I also standardized the parsing, so that Overall I'm happy with this. But I understand this is a hard thing for you to review since it's very technical. One point to highlight: I use the following pattern
To check if something is a column expression, I check if the output is |
is |
Yes - it is hard to follow as the changes are small and scattered. But it is nice that all tests pass 😄. What I would recommend. Can you please add a testset testing
|
No, I need to add back in warning messages. Okay, I will add a test set just for parsing. |
Okay I have added new tests that should give a clearer idea of the rules for expression handling. Ready for a review! One thing: The functions |
i = @protect $1 | ||
@test i == 1 | ||
|
||
n = @protect "hello" |
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.
so without $
only symbol is accepted? What is the result of:
@protect Symbol("x")
?
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.
That will give a Symbol
, you can't get a column through Symbol("x")
. I will add this to the tests to clarify.
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.
Just a few minor comments.
|
||
If the input is a valid column identifier, i.e. | ||
a `QuoteNode` or an expression beginning with | ||
`$DOLLAR`, returns the underlying identifier. |
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.
Doesn't this work?
`$DOLLAR`, returns the underlying identifier. | |
`\$`, returns the underlying identifier. |
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.
No, it shows up as a backslash inside the auto-generated docs. This was the only solution that seemed to not cause runtime errors from interpolation and also not cause problems in the html of the docs.
Co-authored-by: Milan Bouchet-Valat <[email protected]>
Okay, will merge this after CI and then turn to the AsTable stuff |
Actually, I will wait for an approval. With a single approval I will merge. |
Thanks! |
This PR re-factors the expression handling. As a result it's now simpler, fewer LOC, and has more abstractions so the code is less fragile.