-
Notifications
You must be signed in to change notification settings - Fork 145
Fix unbalanced paren #966
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
base: main
Are you sure you want to change the base?
Fix unbalanced paren #966
Conversation
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.
Thanks! directly tracking paren balance makes sense. I wonder if my alternative implementation may be better to explore given the simplicity of it and it maybe capturing other bad expressions https://github.com/sourcegraph/zoekt/pull/569/files WDYT?
Happy to go along with this change after the feedback is resolved though.
@keegancsmith I was simply in awe when I saw the simplicity of the solution, but since the last draft was in 2023 and you were a bit skeptical about your solution as well, I figured I might propose an alternative for you to compare the two and check which was the better fit. Your solution works perfectly fine. I've also resolved the requested changes. We can go along with any one of them 🙂. |
aaaaw thanks :) TBH I just completely forgot about that PR since it was just a quick hack. I still don't know if it makes sense. Given I am in an end of week mood, I will dive a bit into the code to see if it makes sense. Will get back to you today. |
@BlackBuck thanks for motivating me to look into this again. I read the code and did some more testing, and I think the approach in #569 is solid. I reckon we should prefer that approach given its simplicity and it can cover other potential situation we don't parse the full query string (although from reading the code this is the only one I saw). |
LGTM 👍 |
This PR addresses #547. Previously, due to a mix of local and recursive tracking of parentheses balance,
(
and)
were not parsed correctly (especially)
).Changes Made
parenBalance
variable to track parentheses across all expressions and sub-expressions.parseExprList()
to accept a pointer toparenBalance
parseExprList()
to use a pointer to the globalparenBalance
This takes the parentheses logic, which previously existed only in
nextToken
, and moves it up to theParse
function.