Miguel I would suggest that you use the third option for prefixes. Apply the prefixes in the containing rules file provided they aren't overridden by the query.
Rob On 05/06/2014 12:06, "Miguel Bento Alves" <mbentoal...@gmail.com> wrote: >Hi Andy, > >I upload the code to https://github.com/mbentoalves/jenaMBA_JENA650. Give >me some feedback if I'm doing well. I changed the files Rule.java and >Tokenizer.java. > >As you suggested, I implemented the Sparql command enclosure as: > >(\\\SPARQL >PREFIX >SELECT ... > >\\\SPARQL) > >(I added the tokens of the clauses) > >However, I left an "open door" if in future we want go deep in parsing, >overcoming corner cases, and simplify the declaration as my initial >propose: > >(PREFIX >SELECT ... > >) > >Next, I will work on parsing of a Sparql command. > >Related with prefixes, in your opinion what is the best approach: > - The Sparql command has is own prefixes; > - The prefixes are the same of the rules files, and should be declared > in >the rules file and not in Sparql command; > - mixed of the previous situations. The command share the same prefixes >of the rules but can be declared some specific prefix in a given sparql >command. > > > >Miguel > > > > >On 04/06/14 10:23, "Andy Seaborne" <a...@apache.org> wrote: > >>On 04/06/14 09:20, Miguel Bento Alves wrote: >>> Hi Andy, >>> >>> I didn't foresee that cases. I will work on that. >> >>Without deep parsing you can't address all the cases. And there are >>more important things to worry about. >> >>> >>> Related with the syntax of the definition a SPARQL command, do you >>>think >>> that parenthesis is ok? >> >>They are OK - a choice like ``` which is something very unlikely in a >>query is also possible. Then you just look for another ``` and assume >>everything in between is one valid SPARQL query. >> >>\\\SPARQL >>PREFIX >>SELECT ... >> >>\\\SPARQL >> >>You simply make the token very unlikely or even invalid (In SPARQL, \\\ >>is nearly invalid, \\\S is invalid except for comments.). >> >>> I think that is the better choice because whatever the token we choose >>>we >>> will have the same problems. Furthermore, is congruent with rules >>>syntax. >>> >>> I don't have much experience in team development. How is the better way >>>to >>> share code with you? >> >>Please set up a repository e.g. on github. >> >> Andy >> >>> >>> Miguel >>> >>> >>> >>> On 04/06/14 08:56, "Andy Seaborne" <a...@apache.org> wrote: >>> >>>> On 03/06/14 17:15, Miguel Bento Alves wrote: >>>>> Hi all, >>>>> >>>>> I'm working on JENA-650 - Define SPARQL commands in Jena rules, under >>>>> GSoC >>>>> project. Right now, I need to define the syntax to declare a SPARQL >>>>> command >>>>> in a rule. My proposal is to do as in rules, enclosed between >>>>> parenthesis >>>>> (some examples listed below). >>>>> >>>>> I need some feedback from you about this proposal. >>>>> >>>>> To parse the rule, my approach was: >>>>> - for every open parenthesis, "(", I analyse the next token. *1 >>>>> - if the token after an open bracket is a SPARQL command (private >>>>>words >>>>> "select" or "ask", for instance), I extract the command between >>>>> parenthesis. >>>>> - As inside a SPARQL command we can have parenthesis, I count the >>>>> number of >>>>> open and close parenthesis. When the difference between both achieve >>>>>0, >>>>> I >>>>> get the command). >>>>> >>>>> *1 - I implemented a method to return the next token without increase >>>>> the >>>>> pointer of the tokens extraction process. >>>>> >>>>> I did small tests, and so far is working well. As I return null in >>>>>each >>>>> SPARQL command parsed, for now, the rule is well executed. When I >>>>> introduce >>>>> errors in parenthesis, the parse is returning the error in the right >>>>> place. >>>>> >>>>> Miguel >>>> >>>> Miguel, >>>> >>>> If you have got it working then that's what counts. I can see some >>>> corner cases where the ( and the ) need not match up even on a >>>> syntactically valid >>>> >>>> ( SELECT * >>>> { ?s ?p ?o >>>> BIND ( STRAFTER(str(?o), ")" ) >>>> } >>>> ) >>>> >>>> or comments >>>> >>>> ( SELECT * { ?s ?p "hello" } # Comment ) here >>>> ) >>>> >>>> Do you have a link to the code? I'd like to take a look. >>>> >>>> Andy >>>> >>>> >>>>> >>>>> (?r rdf:type ex:Square) <- >>>>> ( >>>>> select ?r >>>>> where { >>>>> ?r ex:width ?width . >>>>> ?r ex:height ?height . >>>>> FILTER(?width = ?height) . >>>>> } >>>>> ). >>>>> (?r rdf:type ex:Square) <- >>>>> (? rdf:type ex:Rectangle), >>>>> ( >>>>> select ?r >>>>> where { >>>>> ?r ex:width ?width . >>>>> ?r ex:height ?height . >>>>> FILTER(?width = ?height) . >>>>> } >>>>> ). >>>>> (? rdf:type ex:Rectangle), >>>>> ( >>>>> select ?r >>>>> where { >>>>> ?r ex:width ?width . >>>>> ?r ex:height ?height . >>>>> FILTER(?width = ?height) . >>>>> } >>>>> ) -> >>>>> (?r rdf:type ex:Square). >>>>> >>>>> >>>>> >>>> >>> >>> >> > >