Skip to content
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

Come up with a parser-based solution for SPARQL query modification #205

Open
lu-pl opened this issue Jan 24, 2025 · 3 comments
Open

Come up with a parser-based solution for SPARQL query modification #205

lu-pl opened this issue Jan 24, 2025 · 3 comments
Assignees
Labels
refactor Implementation changes that preserve external interfaces and the behavior of the software.

Comments

@lu-pl
Copy link
Contributor

lu-pl commented Jan 24, 2025

Since there is no proper/applicable SPARQL query builder solution available for Python, SPARQL query modification in RDFProxy currently has to rely on regexes. Obviously, this is a huge pain.

A much more stable, reliable and sane approach of doing dynamic query modification would be to modify a parse tree instead of strings. So it would be really nice if somebody (me) came up with a parser capable of dynamic parse tree modification. RDFLib's SPARQL parser is built with pyparsing, so this is likely not an option.

@lu-pl lu-pl added the refactor Implementation changes that preserve external interfaces and the behavior of the software. label Jan 24, 2025
@lu-pl lu-pl self-assigned this Jan 24, 2025
@lu-pl
Copy link
Contributor Author

lu-pl commented Jan 24, 2025

I am of the opinion that a lark parser would be a good solution, lark has neat Transformer and Visitor abstractions for operations on the parse tree and is generally really powerful. Also, lark's grammar syntax is very close to EBNF.

@lu-pl
Copy link
Contributor Author

lu-pl commented Jan 27, 2025

larql is an attempt to create a Lark parser for SPARQL 1.1. It tests against w3c rdf-tests, currently 1/3 of the tests are failing, almost all of them concern Update Requests. Working on it.

@lu-pl
Copy link
Contributor Author

lu-pl commented Jan 30, 2025

update: the remaining failing tests are often about SPARQL semantics, not its syntax. So larql will probably have to provide a thin-ish wrapper for semantic pre- and post processing of parsed queries.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactor Implementation changes that preserve external interfaces and the behavior of the software.
Projects
None yet
Development

No branches or pull requests

1 participant