jena-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject [08/50] [abbrv] jena git commit: The SPARQL 1.1 parser (like the SPARQL 1.0 parser) are now unchanged.
Date Mon, 17 Aug 2015 15:09:47 GMT
The SPARQL 1.1 parser (like the SPARQL 1.0 parser) are now unchanged.

Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/a8b0d53e
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/a8b0d53e
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/a8b0d53e

Branch: refs/heads/JENA-491-construct-quads
Commit: a8b0d53e83a39357f6d35763494ecfa447826b51
Parents: 2cb175d
Author: confidencesun <confidence.sun@gmail.com>
Authored: Thu Jun 18 11:21:34 2015 +0800
Committer: confidencesun <confidence.sun@gmail.com>
Committed: Thu Jun 18 11:21:34 2015 +0800

----------------------------------------------------------------------
 jena-arq/Grammar/arq.jj                         |   34 +-
 jena-arq/Grammar/master.jj                      |   56 +-
 jena-arq/Grammar/sparql_11.jj                   |    8 +-
 .../apache/jena/sparql/lang/arq/ARQParser.java  | 1909 ++++++++++--------
 .../sparql/lang/sparql_11/SPARQLParser11.java   |    8 +-
 .../org/apache/jena/sparql/syntax/Template.java |    7 +-
 6 files changed, 1103 insertions(+), 919 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jena/blob/a8b0d53e/jena-arq/Grammar/arq.jj
----------------------------------------------------------------------
diff --git a/jena-arq/Grammar/arq.jj b/jena-arq/Grammar/arq.jj
index 2f80284..70a34f4 100644
--- a/jena-arq/Grammar/arq.jj
+++ b/jena-arq/Grammar/arq.jj
@@ -134,8 +134,10 @@ void ConstructQuery() : { Template t ;
  <CONSTRUCT>
    { getQuery().setQueryConstructType() ; }
  (
-    t = ConstructTemplate()
+    <LBRACE>
+    t = ConstructQuads(acc)
       { getQuery().setConstructTemplate(t) ; }
+    <RBRACE>
     ( DatasetClause() )*
     WhereClause()
     SolutionModifier()
@@ -143,7 +145,7 @@ void ConstructQuery() : { Template t ;
     ( DatasetClause() )*
     <WHERE>
     <LBRACE>
-    (TriplesTemplate(acc))?
+    ConstructQuads(acc)
     <RBRACE>
     SolutionModifier()
     {
@@ -500,6 +502,30 @@ void QuadsNotTriples(QuadAccSink acc) : {Node gn ; Node prev = acc.getGraph()
;
     <RBRACE>
     { setAccGraph(acc, prev) ; }
 }
+Template ConstructQuads(QuadAcc acc) : {Template t = new Template (acc);}
+{
+    { setInConstructTemplate(true) ; }
+    (TriplesTemplate(acc))?
+    (
+       ConstructQuadsNotTriples(acc)
+       (<DOT>)?
+       (TriplesTemplate(acc))?
+    )*
+    { setInConstructTemplate(false) ;
+      return t ; }
+}
+void ConstructQuadsNotTriples(QuadAccSink acc) : {Node gn = null ; Node prev = acc.getGraph()
; }
+{
+    (
+    <GRAPH>
+     gn = VarOrIri()
+    )?
+    { setAccGraph(acc, gn) ; }
+    <LBRACE>
+    (TriplesTemplate(acc))?
+    <RBRACE>
+    { setAccGraph(acc, prev) ; }
+}
 void TriplesTemplate(TripleCollector acc) : { }
 {
     TriplesSameSubject(acc)
@@ -780,8 +806,8 @@ ExprList ExpressionList() : { Expr expr = null ; ExprList args = new ExprList()
   )
   { return args ; }
 }
-Template ConstructTemplate() : { QuadAcc acc = new QuadAcc() ;
-                                 Template t = new Template(acc) ; }
+Template ConstructTemplate() : { TripleCollectorBGP acc = new TripleCollectorBGP();
+                                 Template t = new Template(acc.getBGP()) ; }
 {
     { setInConstructTemplate(true) ; }
   <LBRACE>

http://git-wip-us.apache.org/repos/asf/jena/blob/a8b0d53e/jena-arq/Grammar/master.jj
----------------------------------------------------------------------
diff --git a/jena-arq/Grammar/master.jj b/jena-arq/Grammar/master.jj
index 2de8bba..1c1c93d 100644
--- a/jena-arq/Grammar/master.jj
+++ b/jena-arq/Grammar/master.jj
@@ -241,8 +241,10 @@ void ConstructQuery() : { Template t ;
    { getQuery().setQueryConstructType() ; }
  (
     // Full form.
-    t = ConstructTemplate() 
+    <LBRACE>
+    t = ConstructQuads(acc) 
       { getQuery().setConstructTemplate(t) ; }
+    <RBRACE>
     ( DatasetClause() )*
     WhereClause()
     SolutionModifier()
@@ -252,7 +254,7 @@ void ConstructQuery() : { Template t ;
     <WHERE>
     // Should have been "ConstructTemplate()"
     <LBRACE>  
-    (TriplesTemplate(acc))?
+    ConstructQuads(acc)
     <RBRACE>
     SolutionModifier()
     { 
@@ -268,9 +270,20 @@ void ConstructQuery() : { Template t ;
 //#endif
 }
 #else
+
 void ConstructQuery() : { Template t ; 
-                          QuadAcc acc = new QuadAcc() ; }
-{
+                          TripleCollectorBGP acc = new TripleCollectorBGP() ; }
+{
+// #ifndef ARQ
+//   <CONSTRUCT>
+//      { getQuery().setQueryConstructType() ; }
+//   t = ConstructTemplate() 
+//     { getQuery().setConstructTemplate(t) ; }
+//   ( DatasetClause() )*
+//   WhereClause()
+//   SolutionModifier()
+// #else
+
  <CONSTRUCT>
    { getQuery().setQueryConstructType() ; }
  (
@@ -290,7 +303,7 @@ void ConstructQuery() : { Template t ;
     <RBRACE>
     SolutionModifier()
     { 
-      t = new Template(acc) ;
+      t = new Template(acc.getBGP()) ;
       getQuery().setConstructTemplate(t) ;
       // Create a query in the same shape as the query created by writing out in full.
       ElementPathBlock epb = new ElementPathBlock(acc.getBGP()) ;
@@ -728,7 +741,36 @@ void QuadsNotTriples(QuadAccSink acc) : {Node gn ; Node prev = acc.getGraph()
;
     { setAccGraph(acc, prev) ; }
     
 }
+#ifdef ARQ
+Template ConstructQuads(QuadAcc acc) : {Template t = new Template (acc);}
+{
+    { setInConstructTemplate(true) ; }
+    (TriplesTemplate(acc))?
+    (
+       ConstructQuadsNotTriples(acc)
+       (<DOT>)?
+       (TriplesTemplate(acc))?
+    )*
+    
+    { setInConstructTemplate(false) ;
+      return t ; }
+}
+
+void ConstructQuadsNotTriples(QuadAccSink acc) : {Node gn = null ; Node prev = acc.getGraph()
; }
+{
+    (
+  	 <GRAPH>
+     gn = VarOrIri()
+    )?
 
+    { setAccGraph(acc, gn) ; }
+    <LBRACE> 
+    (TriplesTemplate(acc))?
+    <RBRACE>
+    { setAccGraph(acc, prev) ; }
+    
+}
+#endif
 void TriplesTemplate(TripleCollector acc) : { }
 {    // same as ConstructTriples
 #if SPARQL_11
@@ -1085,8 +1127,8 @@ ExprList ExpressionList() : { Expr expr = null ; ExprList args = new
ExprList()
 
 // -------- Construct patterns
 
-Template ConstructTemplate() : { QuadAcc acc = new QuadAcc() ; 
-                                 Template t = new Template(acc) ; }
+Template ConstructTemplate() : { TripleCollectorBGP acc = new TripleCollectorBGP(); 
+                                 Template t = new Template(acc.getBGP()) ; }
 {
     { setInConstructTemplate(true) ; }
   <LBRACE> 

http://git-wip-us.apache.org/repos/asf/jena/blob/a8b0d53e/jena-arq/Grammar/sparql_11.jj
----------------------------------------------------------------------
diff --git a/jena-arq/Grammar/sparql_11.jj b/jena-arq/Grammar/sparql_11.jj
index e82bc3e..df2b3b8 100644
--- a/jena-arq/Grammar/sparql_11.jj
+++ b/jena-arq/Grammar/sparql_11.jj
@@ -121,7 +121,7 @@ void SelectClause() : { Var v ; Expr expr ; Node n ; }
   { allowAggregatesInExpressions = false ; }
 }
 void ConstructQuery() : { Template t ;
-                          QuadAcc acc = new QuadAcc() ; }
+                          TripleCollectorBGP acc = new TripleCollectorBGP() ; }
 {
  <CONSTRUCT>
    { getQuery().setQueryConstructType() ; }
@@ -139,7 +139,7 @@ void ConstructQuery() : { Template t ;
     <RBRACE>
     SolutionModifier()
     {
-      t = new Template(acc) ;
+      t = new Template(acc.getBGP()) ;
       getQuery().setConstructTemplate(t) ;
       ElementPathBlock epb = new ElementPathBlock(acc.getBGP()) ;
       ElementGroup elg = new ElementGroup() ;
@@ -729,8 +729,8 @@ ExprList ExpressionList() : { Expr expr = null ; ExprList args = new ExprList()
   )
   { return args ; }
 }
-Template ConstructTemplate() : { QuadAcc acc = new QuadAcc() ;
-                                 Template t = new Template(acc) ; }
+Template ConstructTemplate() : { TripleCollectorBGP acc = new TripleCollectorBGP();
+                                 Template t = new Template(acc.getBGP()) ; }
 {
     { setInConstructTemplate(true) ; }
   <LBRACE>


Mime
View raw message