trig Parser now raises SyntaxError, when finding nested graphs by WhiteGobo · Pull Request #2468 · RDFLib/rdflib (original) (raw)

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 andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation15 Commits3 Checks0 Files changed

Conversation

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters

[ Show hidden characters]({{ revealButtonHref }})

WhiteGobo

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

@WhiteGobo

I havent checked if the Syntaxerror should be subclassed.

@coveralls

Coverage Status

coverage: 90.901% (+0.01%) from 90.891% when pulling a6ca291 on WhiteGobo:trig-xfail-no-nested-graphs into 8582691 on RDFLib:main.

@aucampia

@pre-commit-ci

aucampia

@aucampia

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.

@aucampia

aucampia

aucampia

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.

@aucampia

Raise exception earlier and use self.BadSyntax for raising it.

@aucampia

I'm going to fix the two issues I noted in comments on your branch.

done now.

aucampia

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.

@WhiteGobo

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.

@aucampia

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.

This was referenced

Jul 6, 2023

aucampia added a commit to aucampia/rdflib that referenced this pull request

Aug 17, 2023

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

@WhiteGobo WhiteGobo deleted the trig-xfail-no-nested-graphs branch

September 24, 2023 19:53

Labels

ready to merge

The PR will be merged soon if no further feedback is provided.

review wanted

This indicates that the PR is ready for review