(Using 3.3)

Check out this partial grammar for SPARQL 1.1 
(http://www.w3.org/TR/sparql11-query/)

// [2]
query
        : prologue 
          ( select_query
          | construct_query
          | describe_query
          | ask_query
          )
          bindings_clause 
        ;
        
// [4]
prologue
        : prologue_decl*
        ; 
        
// [4.1]
prologue_decl
  : prefix_decl
  | base_decl
  ;
        
// [5]
base_decl
        : BASE IRI_REF
        ;
        
// [6]
prefix_decl
        : PREFIX PNAME_NS IRI_REF
        ;

The above version works - at least for SELECT queries.  The original production 
[4] that I replaced with [4] and [4.1] looked like

// [4]
prologue
        : ( base_decl | prefix_decl )*
        ;

The grammar with this production will fail to parse SPARQL queries like the 
following, with the error "NoViableAltException: line 1:0 no viable alternative 
at input 'PREFIX'"

PREFIX  data:  <http://example.org/foaf/>
PREFIX  foaf:  <http://xmlns.com/foaf/0.1/>
PREFIX  rdfs:  <http://www.w3.org/2000/01/rdf-schema#>

SELECT ?mbox ?nick ?ppd
FROM NAMED <http://example.org/foaf/aliceFoaf>
FROM NAMED <http://example.org/foaf/bobFoaf>
WHERE
{
  GRAPH data:aliceFoaf
  {
    ?alice foaf:mbox <alice> ;
           foaf:knows ?whom .
    ?whom  foaf:mbox ?mbox ;
           rdfs:seeAlso ?ppd .
    ?ppd  a foaf:PersonalProfileDocument .
  } .
  GRAPH ?ppd
  {
      ?w foaf:mbox ?mbox ;
         foaf:nick ?nick
  }
}

So, why should the new [4] + [4.1] combination work where the original [4] 
would not?



List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org/mailman/options/antlr-interest/your-email-address

-- 
You received this message because you are subscribed to the Google Groups 
"il-antlr-interest" group.
To post to this group, send email to il-antlr-inter...@googlegroups.com.
To unsubscribe from this group, send email to 
il-antlr-interest+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en.

Reply via email to