can/should a parser join groups?

Dear all,

Can/should a SPARQL parser join groups within a scope?

For instance, Section 5.2.2 of the SPARQL 1.1 spec [1]
says that the following patterns all have the same solutions:

 {  ?x foaf:name ?name .
    ?x foaf:mbox ?mbox .
    FILTER regex(?name, "Smith")
 }

 {  FILTER regex(?name, "Smith")
    ?x foaf:name ?name .
    ?x foaf:mbox ?mbox .
 }

 {  ?x foaf:name ?name .
    FILTER regex(?name, "Smith")
    ?x foaf:mbox ?mbox .
 }

Parse trees for the above could look like:

GROUP(GROUP(a, b), FILTER(c))

GROUP(FILTER(c), GROUP(a, b))

GROUP(GROUP(a), FILTER(c), GROUP(b))

I wondered if it thus makes sense for a parser
to join the groups together and moving them to the front,
so that all of the above become:

GROUP(GROUP(a, b), FILTER(c))

Is it a good idea for a parser to do this in general?

Best,

Ruben

[1] http://www.w3.org/TR/sparql11-query/#scopeFilters

Received on Wednesday, 20 August 2014 09:04:32 UTC