-
Notifications
You must be signed in to change notification settings - Fork 565
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
trig Parser now raises SyntaxError, when finding nested graphs #2468
Conversation
I havent checked if the Syntaxerror should be subclassed. |
pre-commit.ci autofix |
for more information, see https://pre-commit.ci
Thanks for the PR @WhiteGobo - I will check it in a bit more detail a bit later tonight but it looks good at a glance. One concern may be that people prefer more lax parsers, but that can go too far [ref], and in this case, I definitely would much rather have the default be compliant with the spec and if someone wants it more lax we can consider adding an option to control parser behaviour to make it more lax; however, it is hard to see who would want it in this case. |
For reference, this is the test file in question: rdflib/test/data/suites/w3c/trig/trig-graph-bad-07.trig Lines 1 to 9 in 6f53455
|
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.
I'm going to fix the two issues I noted in comments on your branch.
Raise exception earlier and use `self.BadSyntax` for raising it.
done now. |
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 for the fix, I'm not sure what was happening with the triples when nested graphs were encountered, but it could not have been good.
I will merge later this week if there is no more feedback.
Thx for the review. Ive felt really lost, when working on the Trig- and Notation3-Parser. I worked more with trial and error, than thinking:) Im much more confident with the parsers, that are written with pyparsing. |
We really should get rid of the hand-written parsers, I don't like working on it either. I think using https://github.com/lark-parser/lark would be best, as that allows generating parsers that don't need any runtime dependencies, but PyParsing is already a lot easier. |
Raise an error when nested graphs occur in TriG. With this change, the <http://www.w3.org/2013/TriGTests/#trig-graph-bad-07> test passes. --------- Co-authored-by: WhiteGobo <richardfechner@posteo.net> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Iwan Aucamp <aucampia@gmail.com>
Summary of changes
When loading trig-graph-bad-07.trig an exception should be raised.
I implemented a normal SyntaxError for this occasion.
The xfail for the corresponding test was removed.
Checklist
the same change.
so maintainers can fix minor issues and keep your PR up to date.