Hi Boris,

Yes, we can extend the grammar to preserve comments as a separate parser to 
the canonical one. Removing unused prefixes can be implemented too. 

I've added both as issues on the GitHub 
repo https://github.com/Kurrawong/sparql/issues. Feel free to add any other 
use cases there that you think are useful.

In a couple of weeks, we will be getting a web UI of this online so users 
can test out and play around with the SPARQL formatter and validator. We 
will also add a CLI interface to the tool.

Cheers,

Edmond

On Wednesday, January 24, 2024 at 6:54:13 AM UTC+10 ni...@kurrawong.net 
wrote:

> Good questions there Boris that perhaps only Edmond can answer (he should 
> get this and can do so!).
>
> I imagine that both those things, if not already handled, could be added 
> to the code he's written since it parses the query and then uses custom 
> code to serialise. So the prefix removal step would be a straightforward 
> addition in query content analysis before the serialisation. Surely 
> comments just need new elements added to the grammar?
>
> Nick
>
> On Wednesday, 24 January 2024 at 2:53 AM, Boris Pelakh <pel...@gmail.com> 
> wrote:
>
> I like the idea of utilizing the SPARQL parser/serializer, but have a 
> couple of questions re:features
>
> 1. would it be able to preserve inline comments? The current Lark grammar 
> discards comments, but keeping them is a requirement.
> 2. would it be able to remove unused prefix declarations? Obviously that's 
> a nice-to-have
>
> On Mon, Jan 22, 2024 at 4:46 PM Nicholas Car <ni...@kurrawong.net> wrote:
>
>> We have just written a stand-alone Python SPARQL parser and serialiser 
>> that will probably do what you want:
>>
>> https://github.com/kurrawong/sparql
>>
>> We will contribute this to the RDFlib set of tools shortly.
>>
>> It parses any SPARQL to SPARQL grammar and then implements a serialiser 
>> to return back out SPARQL strings. This could be made to produce canonical 
>> serialisations which would then standardise all your files.
>>
>> Nick
>>
>>
>>
>> On Tue, Jan 23, 2024 at 6:49 am, Donny Winston <do...@polyneme.xyz> 
>> wrote:
>>
>> Ooh, I am interested as well. I use edmcouncil/rdf-toolkit (
>> https://github.com/edmcouncil/rdf-toolkit) to accomplish this for turtle 
>> (.ttl) files, but I have nothing for sparql files.
>>
>> On Mon, Jan 22, 2024, at 12:50 PM, Boris Pelakh wrote:
>>
>> My group has quite a few SPARQL queries in our git repo, and I would like 
>> to add a pre-commit formatter to standardize appearance and minimize 
>> format-related diff noise. Any suggestions? (would also love to have one in 
>> VSCode, but that's a secondary concern).
>>
>>
>> -- 
>> http://github.com/RDFLib
>> --- 
>> You received this message because you are subscribed to the Google Groups 
>> "rdflib-dev" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to rdflib-dev+...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/rdflib-dev/4b6283d4-db0a-4d7c-8fa9-347722304ea7n%40googlegroups.com
>> .
>>
>>
>> --
>> Donny Winston, PhD (he/him/his)
>> Polyneme LLC
>> New York, NY
>> https://polyneme.xyz
>>
>> -- 
>> http://github.com/RDFLib
>> --- 
>> You received this message because you are subscribed to the Google Groups 
>> "rdflib-dev" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to rdflib-dev+...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/rdflib-dev/6aa43f3e-da03-42db-8826-ea060a9d275c%40app.fastmail.com
>> .
>>
>> -- 
>> http://github.com/RDFLib
>> --- 
>> You received this message because you are subscribed to the Google Groups 
>> "rdflib-dev" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to rdflib-dev+...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/rdflib-dev/ej853gXqUjIERPfSmtRjAfj_SnmWopDV_-trLEH5sqjWBahgC5SYSvrNms_GfeHmCElBiNbPm4YDrRaeeGdeKYvGKLMRvNLFsM14XzK-tdc%3D%40kurrawong.net
>> .
>>
> -- 
> http://github.com/RDFLib
> --- 
> You received this message because you are subscribed to the Google Groups 
> "rdflib-dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to rdflib-dev+...@googlegroups.com.
>
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/rdflib-dev/CAMNphsoqCxtmX5Y3cKx6ynhjF%3D9pnRtOLiv3evXzgjRaJ81%3DFQ%40mail.gmail.com
> .
>
>
>

-- 
http://github.com/RDFLib
--- 
You received this message because you are subscribed to the Google Groups 
"rdflib-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rdflib-dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rdflib-dev/4b0ea91c-9667-4ce8-8bbf-609e23593a61n%40googlegroups.com.

Reply via email to