-
Notifications
You must be signed in to change notification settings - Fork 157
Fix parser to reject incomplete reductions like ([, ({, (( #3139
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: master
Are you sure you want to change the base?
Conversation
|
Can you give an example where |
|
... and where is a problem with the comma? |
src/tests/syntax_errors.pl
Outdated
| % Test that (( produces syntax error | ||
| test("(( should produce syntax_error", ( | ||
| catch( | ||
| (read_from_chars("((}.", _), false), |
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.
This example is not very convincing, since it always produced a syntax error (for whatever reason). So what is its point?
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.
multitasking error, stand by
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.
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.
(... divergent branches, git status says I should do git pull)
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.
perhaps looking at the combined testing branch would be better:
https://github.com/jjtolton/scryer-prolog/tree/combined-testing
That has digits, this, and double bars
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.
(... divergent branches,
git statussays I should dogit pull)
Forget it, your combined branch is it!
src/tests/syntax_errors.pl
Outdated
| % Test that {( produces syntax error (already tested in ISO conformity) | ||
| test("{( should produce syntax_error", ( | ||
| catch( | ||
| (read_from_chars("{(}.", _), false), |
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.
idem
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.
Fixes mthom#3138 The parser was incorrectly accepting expressions like ([ and ({ as valid syntax, parsing them as atoms instead of rejecting them as incomplete reductions. This fix adds checks in reduce_brackets() to reject when an opening parenthesis is followed by: - Opening bracket [ - Opening curly brace { Note: (, and (( were already correctly rejected by existing checks. This brings the behavior in line with how curly braces work, where {[ and {( correctly produce syntax errors. Added tests in src/tests/syntax_errors.pl to verify the fix and prevent regressions.
Closes: #3138