On 27/10/2023 17:58, Justin wrote:
Hello, Is it possible to allow qparse to preserve comments?
No - the parser skips them.
e.g. it currently does not: ``` justin@parens:/tmp$ cat a.rq select * where { ?s ?p ?o # comment here } justin@parens:/tmp$ ~/Downloads/apache-jena-4.7.0/bin/qparse --query a.rq SELECT * WHERE { ?s ?p ?o } ``` If comment lines (starting with #) are too tricky to work with what about something like Clojure's `comment` e.g. ``` (comment (range 5)) ``` That way the "comment" is still part of the AST tree. Maybe there could be a magic predicate that gets ignored? ``` [] ex:comment "comment here" . ```
If the comment is between syntax elements, then, yes, an "ElementComment" could be added.
Some positions are within syntax elements: { ?s # Some comment ?p ?o } and don't have a natural place to go in the AST. Andy c.f. Pragmas.