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).




Reply via email to