Another tool is the roqet tool, which is packaged in rasqal . This is a command line tool that returns a processed tree. For instance:
roqet -i laqrs -d structure -n -e "SELECT * WHERE {?xa ?y OPTIONAL {?xa ?z}}"
will be displayed ..
Query: query verb: SELECT query bound variables (3): x, y, z query Group graph pattern[0] { sub-graph patterns (2) { Basic graph pattern[1]
Looking at your comment in another answer, I don't think this is what you need. And I donβt think you will find an answer looking at the SPARQL parser. The evaluation of an object (or triple pattern) in a query takes place inside Query Engines , which in well-designed systems is isolated from query parsing.
For example, in 4store, you can see the 4s-query command with the -vvv parameter (very verbose), where you will see the output of how the query was executed and how the substitutions were performed for each evaluation of the three templates.
source share