@ -139,9 +139,9 @@ impl From<PropertyPathExpression> for VariableOrPropertyPath {
}
}
fn add_to_triple_or_path_patterns (
fn add_to_triple_or_path_patterns (
subject : TermOrVariable ,
subject : TermPattern ,
predicate : impl Into < VariableOrPropertyPath > ,
predicate : impl Into < VariableOrPropertyPath > ,
object : TermOrVariable ,
object : TermPattern ,
patterns : & mut Vec < TripleOrPathPattern > ,
patterns : & mut Vec < TripleOrPathPattern > ,
) {
) {
match predicate . into ( ) {
match predicate . into ( ) {
@ -199,9 +199,9 @@ fn build_bgp(patterns: Vec<TripleOrPathPattern>) -> GraphPattern {
enum TripleOrPathPattern {
enum TripleOrPathPattern {
Triple ( TriplePattern ) ,
Triple ( TriplePattern ) ,
Path {
Path {
subject : TermOrVariable ,
subject : TermPattern ,
path : PropertyPathExpression ,
path : PropertyPathExpression ,
object : TermOrVariable ,
object : TermPattern ,
} ,
} ,
}
}
@ -454,10 +454,7 @@ fn build_select(
m
m
}
}
fn copy_graph (
fn copy_graph ( from : impl Into < GraphName > , to : impl Into < GraphNamePattern > ) -> GraphUpdateOperation {
from : impl Into < GraphName > ,
to : impl Into < GraphNameOrVariable > ,
) -> GraphUpdateOperation {
let bgp = GraphPattern ::Bgp ( vec! [ TriplePattern ::new (
let bgp = GraphPattern ::Bgp ( vec! [ TriplePattern ::new (
Variable { name : "s" . into ( ) } ,
Variable { name : "s" . into ( ) } ,
Variable { name : "p" . into ( ) } ,
Variable { name : "p" . into ( ) } ,
@ -840,14 +837,14 @@ parser! {
pattern : build_select ( Selection {
pattern : build_select ( Selection {
option : SelectionOption ::Default ,
option : SelectionOption ::Default ,
variables : Some ( p . into_iter ( ) . map ( | var_or_iri | match var_or_iri {
variables : Some ( p . into_iter ( ) . map ( | var_or_iri | match var_or_iri {
NamedNodeOrVariable ::NamedNode ( n ) = > SelectionMember ::Expression ( n . into ( ) , variable ( ) ) ,
NamedNodePattern ::NamedNode ( n ) = > SelectionMember ::Expression ( n . into ( ) , variable ( ) ) ,
NamedNodeOrVariable ::Variable ( v ) = > SelectionMember ::Variable ( v )
NamedNodePattern ::Variable ( v ) = > SelectionMember ::Variable ( v )
} ) . collect ( ) )
} ) . collect ( ) )
} , w . unwrap_or_else ( GraphPattern ::default ) , g , h , o , l , v , state ) ,
} , w . unwrap_or_else ( GraphPattern ::default ) , g , h , o , l , v , state ) ,
base_iri : state . base_iri . clone ( )
base_iri : state . base_iri . clone ( )
}
}
}
}
rule DescribeQuery_item ( ) -> NamedNodeOrVariable = i :VarOrIri ( ) _ { i }
rule DescribeQuery_item ( ) -> NamedNodePattern = i :VarOrIri ( ) _ { i }
//[12]
//[12]
rule AskQuery ( ) -> Query = i ( "ASK" ) _ d :DatasetClauses ( ) w :WhereClause ( ) _ g :GroupClause ( ) ? _ h :HavingClause ( ) ? _ o :OrderClause ( ) ? _ l :LimitOffsetClauses ( ) ? _ v :ValuesClause ( ) {
rule AskQuery ( ) -> Query = i ( "ASK" ) _ d :DatasetClauses ( ) w :WhereClause ( ) _ g :GroupClause ( ) ? _ h :HavingClause ( ) ? _ o :OrderClause ( ) ? _ l :LimitOffsetClauses ( ) ? _ v :ValuesClause ( ) {
@ -1037,24 +1034,24 @@ parser! {
let pattern = d . iter ( ) . map ( | q | {
let pattern = d . iter ( ) . map ( | q | {
let bgp = GraphPattern ::Bgp ( vec! [ TriplePattern ::new ( q . subject . clone ( ) , q . predicate . clone ( ) , q . object . clone ( ) ) ] ) ;
let bgp = GraphPattern ::Bgp ( vec! [ TriplePattern ::new ( q . subject . clone ( ) , q . predicate . clone ( ) , q . object . clone ( ) ) ] ) ;
match & q . graph_name {
match & q . graph_name {
GraphNameOrVariable ::NamedNode ( graph_name ) = > GraphPattern ::Graph { graph_name : graph_name . clone ( ) . into ( ) , inner : Box ::new ( bgp ) } ,
GraphNamePattern ::NamedNode ( graph_name ) = > GraphPattern ::Graph { graph_name : graph_name . clone ( ) . into ( ) , inner : Box ::new ( bgp ) } ,
GraphNameOrVariable ::DefaultGraph = > bgp ,
GraphNamePattern ::DefaultGraph = > bgp ,
GraphNameOrVariable ::Variable ( graph_name ) = > GraphPattern ::Graph { graph_name : graph_name . clone ( ) . into ( ) , inner : Box ::new ( bgp ) } ,
GraphNamePattern ::Variable ( graph_name ) = > GraphPattern ::Graph { graph_name : graph_name . clone ( ) . into ( ) , inner : Box ::new ( bgp ) } ,
}
}
} ) . fold ( GraphPattern ::Bgp ( Vec ::new ( ) ) , new_join ) ;
} ) . fold ( GraphPattern ::Bgp ( Vec ::new ( ) ) , new_join ) ;
let delete = d . into_iter ( ) . map ( | q | Ok ( GroundQuadPattern {
let delete = d . into_iter ( ) . map ( | q | Ok ( GroundQuadPattern {
subject : match q . subject {
subject : match q . subject {
TermOrVariable ::NamedNode ( subject ) = > subject . into ( ) ,
TermPattern ::NamedNode ( subject ) = > subject . into ( ) ,
TermOrVariable ::BlankNode ( _ ) = > return Err ( "Blank nodes are not allowed in DELETE WHERE" ) ,
TermPattern ::BlankNode ( _ ) = > return Err ( "Blank nodes are not allowed in DELETE WHERE" ) ,
TermOrVariable ::Literal ( subject ) = > subject . into ( ) ,
TermPattern ::Literal ( subject ) = > subject . into ( ) ,
TermOrVariable ::Variable ( subject ) = > subject . into ( ) ,
TermPattern ::Variable ( subject ) = > subject . into ( ) ,
} ,
} ,
predicate : q . predicate ,
predicate : q . predicate ,
object : match q . object {
object : match q . object {
TermOrVariable ::NamedNode ( object ) = > object . into ( ) ,
TermPattern ::NamedNode ( object ) = > object . into ( ) ,
TermOrVariable ::BlankNode ( _ ) = > return Err ( "Blank nodes are not allowed in DELETE WHERE" ) ,
TermPattern ::BlankNode ( _ ) = > return Err ( "Blank nodes are not allowed in DELETE WHERE" ) ,
TermOrVariable ::Literal ( object ) = > object . into ( ) ,
TermPattern ::Literal ( object ) = > object . into ( ) ,
TermOrVariable ::Variable ( object ) = > object . into ( ) ,
TermPattern ::Variable ( object ) = > object . into ( ) ,
} ,
} ,
graph_name : q . graph_name
graph_name : q . graph_name
} ) ) . collect ::< Result < Vec < _ > , _ > > ( ) ? ;
} ) ) . collect ::< Result < Vec < _ > , _ > > ( ) ? ;
@ -1091,7 +1088,7 @@ parser! {
if let Some ( with ) = with {
if let Some ( with ) = with {
// We inject WITH everywhere
// We inject WITH everywhere
delete = delete . into_iter ( ) . map ( | q | if q . graph_name = = GraphNameOrVariable ::DefaultGraph {
delete = delete . into_iter ( ) . map ( | q | if q . graph_name = = GraphNamePattern ::DefaultGraph {
GroundQuadPattern {
GroundQuadPattern {
subject : q . subject ,
subject : q . subject ,
predicate : q . predicate ,
predicate : q . predicate ,
@ -1101,7 +1098,7 @@ parser! {
} else {
} else {
q
q
} ) . collect ( ) ;
} ) . collect ( ) ;
insert = insert . into_iter ( ) . map ( | q | if q . graph_name = = GraphNameOrVariable ::DefaultGraph {
insert = insert . into_iter ( ) . map ( | q | if q . graph_name = = GraphNamePattern ::DefaultGraph {
QuadPattern {
QuadPattern {
subject : q . subject ,
subject : q . subject ,
predicate : q . predicate ,
predicate : q . predicate ,
@ -1138,17 +1135,17 @@ parser! {
rule DeleteClause ( ) -> Vec < GroundQuadPattern > = i ( "DELETE" ) _ q :QuadPattern ( ) { ?
rule DeleteClause ( ) -> Vec < GroundQuadPattern > = i ( "DELETE" ) _ q :QuadPattern ( ) { ?
q . into_iter ( ) . map ( | q | Ok ( GroundQuadPattern {
q . into_iter ( ) . map ( | q | Ok ( GroundQuadPattern {
subject : match q . subject {
subject : match q . subject {
TermOrVariable ::NamedNode ( subject ) = > subject . into ( ) ,
TermPattern ::NamedNode ( subject ) = > subject . into ( ) ,
TermOrVariable ::BlankNode ( _ ) = > return Err ( "Blank nodes are not allowed in DELETE WHERE" ) ,
TermPattern ::BlankNode ( _ ) = > return Err ( "Blank nodes are not allowed in DELETE WHERE" ) ,
TermOrVariable ::Literal ( subject ) = > subject . into ( ) ,
TermPattern ::Literal ( subject ) = > subject . into ( ) ,
TermOrVariable ::Variable ( subject ) = > subject . into ( ) ,
TermPattern ::Variable ( subject ) = > subject . into ( ) ,
} ,
} ,
predicate : q . predicate ,
predicate : q . predicate ,
object : match q . object {
object : match q . object {
TermOrVariable ::NamedNode ( object ) = > object . into ( ) ,
TermPattern ::NamedNode ( object ) = > object . into ( ) ,
TermOrVariable ::BlankNode ( _ ) = > return Err ( "Blank nodes are not allowed in DELETE WHERE" ) ,
TermPattern ::BlankNode ( _ ) = > return Err ( "Blank nodes are not allowed in DELETE WHERE" ) ,
TermOrVariable ::Literal ( object ) = > object . into ( ) ,
TermPattern ::Literal ( object ) = > object . into ( ) ,
TermOrVariable ::Variable ( object ) = > object . into ( ) ,
TermPattern ::Variable ( object ) = > object . into ( ) ,
} ,
} ,
graph_name : q . graph_name
graph_name : q . graph_name
} ) ) . collect ::< Result < Vec < _ > , _ > > ( )
} ) ) . collect ::< Result < Vec < _ > , _ > > ( )
@ -1189,49 +1186,49 @@ parser! {
rule QuadData ( ) -> Vec < Quad > = "{" _ q :Quads ( ) _ "}" { ?
rule QuadData ( ) -> Vec < Quad > = "{" _ q :Quads ( ) _ "}" { ?
q . into_iter ( ) . map ( | q | Ok ( Quad {
q . into_iter ( ) . map ( | q | Ok ( Quad {
subject : match q . subject {
subject : match q . subject {
TermOrVariable ::NamedNode ( t ) = > t . into ( ) ,
TermPattern ::NamedNode ( t ) = > t . into ( ) ,
TermOrVariable ::BlankNode ( t ) = > t . into ( ) ,
TermPattern ::BlankNode ( t ) = > t . into ( ) ,
TermOrVariable ::Literal ( _ ) | TermOrVariable ::Variable ( _ ) = > return Err ( ( ) )
TermPattern ::Literal ( _ ) | TermPattern ::Variable ( _ ) = > return Err ( ( ) )
} ,
} ,
predicate : if let NamedNodeOrVariable ::NamedNode ( t ) = q . predicate {
predicate : if let NamedNodePattern ::NamedNode ( t ) = q . predicate {
t
t
} else {
} else {
return Err ( ( ) )
return Err ( ( ) )
} ,
} ,
object : match q . object {
object : match q . object {
TermOrVariable ::NamedNode ( t ) = > t . into ( ) ,
TermPattern ::NamedNode ( t ) = > t . into ( ) ,
TermOrVariable ::BlankNode ( t ) = > t . into ( ) ,
TermPattern ::BlankNode ( t ) = > t . into ( ) ,
TermOrVariable ::Literal ( t ) = > t . into ( ) ,
TermPattern ::Literal ( t ) = > t . into ( ) ,
TermOrVariable ::Variable ( _ ) = > return Err ( ( ) )
TermPattern ::Variable ( _ ) = > return Err ( ( ) )
} ,
} ,
graph_name : match q . graph_name {
graph_name : match q . graph_name {
GraphNameOrVariable ::NamedNode ( t ) = > t . into ( ) ,
GraphNamePattern ::NamedNode ( t ) = > t . into ( ) ,
GraphNameOrVariable ::DefaultGraph = > GraphName ::DefaultGraph ,
GraphNamePattern ::DefaultGraph = > GraphName ::DefaultGraph ,
GraphNameOrVariable ::Variable ( _ ) = > return Err ( ( ) )
GraphNamePattern ::Variable ( _ ) = > return Err ( ( ) )
}
}
} ) ) . collect ::< Result < Vec < _ > , ( ) > > ( ) . map_err ( | _ | "Variables are not allowed in INSERT DATA and DELETE DATA" )
} ) ) . collect ::< Result < Vec < _ > , ( ) > > ( ) . map_err ( | _ | "Variables are not allowed in INSERT DATA and DELETE DATA" )
}
}
rule GroundQuadData ( ) -> Vec < GroundQuad > = "{" _ q :Quads ( ) _ "}" { ?
rule GroundQuadData ( ) -> Vec < GroundQuad > = "{" _ q :Quads ( ) _ "}" { ?
q . into_iter ( ) . map ( | q | Ok ( GroundQuad {
q . into_iter ( ) . map ( | q | Ok ( GroundQuad {
subject : if let TermOrVariable ::NamedNode ( t ) = q . subject {
subject : if let TermPattern ::NamedNode ( t ) = q . subject {
t
t
} else {
} else {
return Err ( ( ) )
return Err ( ( ) )
} ,
} ,
predicate : if let NamedNodeOrVariable ::NamedNode ( t ) = q . predicate {
predicate : if let NamedNodePattern ::NamedNode ( t ) = q . predicate {
t
t
} else {
} else {
return Err ( ( ) )
return Err ( ( ) )
} ,
} ,
object : match q . object {
object : match q . object {
TermOrVariable ::NamedNode ( t ) = > t . into ( ) ,
TermPattern ::NamedNode ( t ) = > t . into ( ) ,
TermOrVariable ::Literal ( t ) = > t . into ( ) ,
TermPattern ::Literal ( t ) = > t . into ( ) ,
TermOrVariable ::BlankNode ( _ ) | TermOrVariable ::Variable ( _ ) = > return Err ( ( ) )
TermPattern ::BlankNode ( _ ) | TermPattern ::Variable ( _ ) = > return Err ( ( ) )
} ,
} ,
graph_name : match q . graph_name {
graph_name : match q . graph_name {
GraphNameOrVariable ::NamedNode ( t ) = > t . into ( ) ,
GraphNamePattern ::NamedNode ( t ) = > t . into ( ) ,
GraphNameOrVariable ::DefaultGraph = > GraphName ::DefaultGraph ,
GraphNamePattern ::DefaultGraph = > GraphName ::DefaultGraph ,
GraphNameOrVariable ::Variable ( _ ) = > return Err ( ( ) )
GraphNamePattern ::Variable ( _ ) = > return Err ( ( ) )
}
}
} ) ) . collect ::< Result < Vec < _ > , ( ) > > ( ) . map_err ( | _ | "Variables are not allowed in INSERT DATA and DELETE DATA" )
} ) ) . collect ::< Result < Vec < _ > , ( ) > > ( ) . map_err ( | _ | "Variables are not allowed in INSERT DATA and DELETE DATA" )
}
}
@ -1241,7 +1238,7 @@ parser! {
q . into_iter ( ) . flatten ( ) . collect ( )
q . into_iter ( ) . flatten ( ) . collect ( )
}
}
rule Quads_TriplesTemplate ( ) -> Vec < QuadPattern > = t :TriplesTemplate ( ) {
rule Quads_TriplesTemplate ( ) -> Vec < QuadPattern > = t :TriplesTemplate ( ) {
t . into_iter ( ) . map ( | t | QuadPattern ::new ( t . subject , t . predicate , t . object , GraphNameOrVariable ::DefaultGraph ) ) . collect ( )
t . into_iter ( ) . map ( | t | QuadPattern ::new ( t . subject , t . predicate , t . object , GraphNamePattern ::DefaultGraph ) ) . collect ( )
} //TODO: return iter?
} //TODO: return iter?
rule Quads_QuadsNotTriples ( ) -> Vec < QuadPattern > = q :QuadsNotTriples ( ) _ "." ? { q }
rule Quads_QuadsNotTriples ( ) -> Vec < QuadPattern > = q :QuadsNotTriples ( ) _ "." ? { q }
@ -1452,19 +1449,19 @@ parser! {
}
}
//[76]
//[76]
rule PropertyList ( ) -> FocusedTriplePattern < Vec < ( NamedNodeOrVariable , Vec < TermOrVariable > ) > > =
rule PropertyList ( ) -> FocusedTriplePattern < Vec < ( NamedNodePattern , Vec < TermPattern > ) > > =
PropertyListNotEmpty ( ) /
PropertyListNotEmpty ( ) /
{ FocusedTriplePattern ::default ( ) }
{ FocusedTriplePattern ::default ( ) }
//[77]
//[77]
rule PropertyListNotEmpty ( ) -> FocusedTriplePattern < Vec < ( NamedNodeOrVariable , Vec < TermOrVariable > ) > > = l :PropertyListNotEmpty_item ( ) * * < 1 , > ( ";" _ ) {
rule PropertyListNotEmpty ( ) -> FocusedTriplePattern < Vec < ( NamedNodePattern , Vec < TermPattern > ) > > = l :PropertyListNotEmpty_item ( ) * * < 1 , > ( ";" _ ) {
l . into_iter ( ) . fold ( FocusedTriplePattern ::< Vec < ( NamedNodeOrVariable , Vec < TermOrVariable > ) > > ::default ( ) , | mut a , b | {
l . into_iter ( ) . fold ( FocusedTriplePattern ::< Vec < ( NamedNodePattern , Vec < TermPattern > ) > > ::default ( ) , | mut a , b | {
a . focus . push ( b . focus ) ;
a . focus . push ( b . focus ) ;
a . patterns . extend ( b . patterns ) ;
a . patterns . extend ( b . patterns ) ;
a
a
} )
} )
}
}
rule PropertyListNotEmpty_item ( ) -> FocusedTriplePattern < ( NamedNodeOrVariable , Vec < TermOrVariable > ) > = p :Verb ( ) _ o :ObjectList ( ) _ {
rule PropertyListNotEmpty_item ( ) -> FocusedTriplePattern < ( NamedNodePattern , Vec < TermPattern > ) > = p :Verb ( ) _ o :ObjectList ( ) _ {
FocusedTriplePattern {
FocusedTriplePattern {
focus : ( p , o . focus ) ,
focus : ( p , o . focus ) ,
patterns : o . patterns
patterns : o . patterns
@ -1472,20 +1469,20 @@ parser! {
}
}
//[78]
//[78]
rule Verb ( ) -> NamedNodeOrVariable = VarOrIri ( ) / "a" { iri ( "http://www.w3.org/1999/02/22-rdf-syntax-ns#type" ) . into ( ) }
rule Verb ( ) -> NamedNodePattern = VarOrIri ( ) / "a" { iri ( "http://www.w3.org/1999/02/22-rdf-syntax-ns#type" ) . into ( ) }
//[79]
//[79]
rule ObjectList ( ) -> FocusedTriplePattern < Vec < TermOrVariable > > = o :ObjectList_item ( ) * * < 1 , > ( "," _ ) {
rule ObjectList ( ) -> FocusedTriplePattern < Vec < TermPattern > > = o :ObjectList_item ( ) * * < 1 , > ( "," _ ) {
o . into_iter ( ) . fold ( FocusedTriplePattern ::< Vec < TermOrVariable > > ::default ( ) , | mut a , b | {
o . into_iter ( ) . fold ( FocusedTriplePattern ::< Vec < TermPattern > > ::default ( ) , | mut a , b | {
a . focus . push ( b . focus ) ;
a . focus . push ( b . focus ) ;
a . patterns . extend_from_slice ( & b . patterns ) ;
a . patterns . extend_from_slice ( & b . patterns ) ;
a
a
} )
} )
}
}
rule ObjectList_item ( ) -> FocusedTriplePattern < TermOrVariable > = o :Object ( ) _ { o }
rule ObjectList_item ( ) -> FocusedTriplePattern < TermPattern > = o :Object ( ) _ { o }
//[80]
//[80]
rule Object ( ) -> FocusedTriplePattern < TermOrVariable > = GraphNode ( )
rule Object ( ) -> FocusedTriplePattern < TermPattern > = GraphNode ( )
//[81]
//[81]
rule TriplesSameSubjectPath ( ) -> Vec < TripleOrPathPattern > =
rule TriplesSameSubjectPath ( ) -> Vec < TripleOrPathPattern > =
@ -1510,12 +1507,12 @@ parser! {
}
}
//[82]
//[82]
rule PropertyListPath ( ) -> FocusedTripleOrPathPattern < Vec < ( VariableOrPropertyPath , Vec < TermOrVariable > ) > > =
rule PropertyListPath ( ) -> FocusedTripleOrPathPattern < Vec < ( VariableOrPropertyPath , Vec < TermPattern > ) > > =
PropertyListPathNotEmpty ( ) /
PropertyListPathNotEmpty ( ) /
{ FocusedTripleOrPathPattern ::default ( ) }
{ FocusedTripleOrPathPattern ::default ( ) }
//[83]
//[83]
rule PropertyListPathNotEmpty ( ) -> FocusedTripleOrPathPattern < Vec < ( VariableOrPropertyPath , Vec < TermOrVariable > ) > > = hp :( VerbPath ( ) / VerbSimple ( ) ) _ ho :ObjectListPath ( ) _ t :PropertyListPathNotEmpty_item ( ) * {
rule PropertyListPathNotEmpty ( ) -> FocusedTripleOrPathPattern < Vec < ( VariableOrPropertyPath , Vec < TermPattern > ) > > = hp :( VerbPath ( ) / VerbSimple ( ) ) _ ho :ObjectListPath ( ) _ t :PropertyListPathNotEmpty_item ( ) * {
t . into_iter ( ) . flat_map ( | e | e . into_iter ( ) ) . fold ( FocusedTripleOrPathPattern {
t . into_iter ( ) . flat_map ( | e | e . into_iter ( ) ) . fold ( FocusedTripleOrPathPattern {
focus : vec ! [ ( hp , ho . focus ) ] ,
focus : vec ! [ ( hp , ho . focus ) ] ,
patterns : ho . patterns
patterns : ho . patterns
@ -1525,10 +1522,10 @@ parser! {
a
a
} )
} )
}
}
rule PropertyListPathNotEmpty_item ( ) -> Option < FocusedTriplePattern < ( VariableOrPropertyPath , Vec < TermOrVariable > ) > > = ";" _ c :PropertyListPathNotEmpty_item_content ( ) ? {
rule PropertyListPathNotEmpty_item ( ) -> Option < FocusedTriplePattern < ( VariableOrPropertyPath , Vec < TermPattern > ) > > = ";" _ c :PropertyListPathNotEmpty_item_content ( ) ? {
c
c
}
}
rule PropertyListPathNotEmpty_item_content ( ) -> FocusedTriplePattern < ( VariableOrPropertyPath , Vec < TermOrVariable > ) > = p :( VerbPath ( ) / VerbSimple ( ) ) _ o :ObjectList ( ) _ {
rule PropertyListPathNotEmpty_item_content ( ) -> FocusedTriplePattern < ( VariableOrPropertyPath , Vec < TermPattern > ) > = p :( VerbPath ( ) / VerbSimple ( ) ) _ o :ObjectList ( ) _ {
FocusedTriplePattern {
FocusedTriplePattern {
focus : ( p , o . focus ) ,
focus : ( p , o . focus ) ,
patterns : o . patterns
patterns : o . patterns
@ -1546,17 +1543,17 @@ parser! {
}
}
//[86]
//[86]
rule ObjectListPath ( ) -> FocusedTripleOrPathPattern < Vec < TermOrVariable > > = o :ObjectPath_item ( ) * * < 1 , > ( "," _ ) {
rule ObjectListPath ( ) -> FocusedTripleOrPathPattern < Vec < TermPattern > > = o :ObjectPath_item ( ) * * < 1 , > ( "," _ ) {
o . into_iter ( ) . fold ( FocusedTripleOrPathPattern ::< Vec < TermOrVariable > > ::default ( ) , | mut a , b | {
o . into_iter ( ) . fold ( FocusedTripleOrPathPattern ::< Vec < TermPattern > > ::default ( ) , | mut a , b | {
a . focus . push ( b . focus ) ;
a . focus . push ( b . focus ) ;
a . patterns . extend ( b . patterns ) ;
a . patterns . extend ( b . patterns ) ;
a
a
} )
} )
}
}
rule ObjectPath_item ( ) -> FocusedTripleOrPathPattern < TermOrVariable > = o :ObjectPath ( ) _ { o }
rule ObjectPath_item ( ) -> FocusedTripleOrPathPattern < TermPattern > = o :ObjectPath ( ) _ { o }
//[87]
//[87]
rule ObjectPath ( ) -> FocusedTripleOrPathPattern < TermOrVariable > = GraphNodePath ( )
rule ObjectPath ( ) -> FocusedTripleOrPathPattern < TermPattern > = GraphNodePath ( )
//[88]
//[88]
rule Path ( ) -> PropertyPathExpression = PathAlternative ( )
rule Path ( ) -> PropertyPathExpression = PathAlternative ( )
@ -1634,12 +1631,12 @@ parser! {
"a" { Either ::Left ( iri ( "http://www.w3.org/1999/02/22-rdf-syntax-ns#type" ) ) }
"a" { Either ::Left ( iri ( "http://www.w3.org/1999/02/22-rdf-syntax-ns#type" ) ) }
//[98]
//[98]
rule TriplesNode ( ) -> FocusedTriplePattern < TermOrVariable > = Collection ( ) / BlankNodePropertyList ( )
rule TriplesNode ( ) -> FocusedTriplePattern < TermPattern > = Collection ( ) / BlankNodePropertyList ( )
//[99]
//[99]
rule BlankNodePropertyList ( ) -> FocusedTriplePattern < TermOrVariable > = "[" _ po :PropertyListNotEmpty ( ) _ "]" {
rule BlankNodePropertyList ( ) -> FocusedTriplePattern < TermPattern > = "[" _ po :PropertyListNotEmpty ( ) _ "]" {
let mut patterns : Vec < TriplePattern > = Vec ::default ( ) ;
let mut patterns : Vec < TriplePattern > = Vec ::default ( ) ;
let mut bnode = TermOrVariable ::from ( bnode ( ) ) ;
let mut bnode = TermPattern ::from ( bnode ( ) ) ;
for ( p , os ) in po . focus {
for ( p , os ) in po . focus {
for o in os {
for o in os {
patterns . push ( TriplePattern ::new ( bnode . clone ( ) , p . clone ( ) , o ) ) ;
patterns . push ( TriplePattern ::new ( bnode . clone ( ) , p . clone ( ) , o ) ) ;
@ -1652,12 +1649,12 @@ parser! {
}
}
//[100]
//[100]
rule TriplesNodePath ( ) -> FocusedTripleOrPathPattern < TermOrVariable > = CollectionPath ( ) / BlankNodePropertyListPath ( )
rule TriplesNodePath ( ) -> FocusedTripleOrPathPattern < TermPattern > = CollectionPath ( ) / BlankNodePropertyListPath ( )
//[101]
//[101]
rule BlankNodePropertyListPath ( ) -> FocusedTripleOrPathPattern < TermOrVariable > = "[" _ po :PropertyListPathNotEmpty ( ) _ "]" {
rule BlankNodePropertyListPath ( ) -> FocusedTripleOrPathPattern < TermPattern > = "[" _ po :PropertyListPathNotEmpty ( ) _ "]" {
let mut patterns : Vec < TripleOrPathPattern > = Vec ::default ( ) ;
let mut patterns : Vec < TripleOrPathPattern > = Vec ::default ( ) ;
let mut bnode = TermOrVariable ::from ( bnode ( ) ) ;
let mut bnode = TermPattern ::from ( bnode ( ) ) ;
for ( p , os ) in po . focus {
for ( p , os ) in po . focus {
for o in os {
for o in os {
add_to_triple_or_path_patterns ( bnode . clone ( ) , p . clone ( ) , o , & mut patterns ) ;
add_to_triple_or_path_patterns ( bnode . clone ( ) , p . clone ( ) , o , & mut patterns ) ;
@ -1670,11 +1667,11 @@ parser! {
}
}
//[102]
//[102]
rule Collection ( ) -> FocusedTriplePattern < TermOrVariable > = "(" _ o :Collection_item ( ) + ")" {
rule Collection ( ) -> FocusedTriplePattern < TermPattern > = "(" _ o :Collection_item ( ) + ")" {
let mut patterns : Vec < TriplePattern > = Vec ::default ( ) ;
let mut patterns : Vec < TriplePattern > = Vec ::default ( ) ;
let mut current_list_node = TermOrVariable ::from ( iri ( "http://www.w3.org/1999/02/22-rdf-syntax-ns#nil" ) ) ;
let mut current_list_node = TermPattern ::from ( iri ( "http://www.w3.org/1999/02/22-rdf-syntax-ns#nil" ) ) ;
for objWithPatterns in o . into_iter ( ) . rev ( ) {
for objWithPatterns in o . into_iter ( ) . rev ( ) {
let new_blank_node = TermOrVariable ::from ( bnode ( ) ) ;
let new_blank_node = TermPattern ::from ( bnode ( ) ) ;
patterns . push ( TriplePattern ::new ( new_blank_node . clone ( ) , iri ( "http://www.w3.org/1999/02/22-rdf-syntax-ns#first" ) , objWithPatterns . focus . clone ( ) ) ) ;
patterns . push ( TriplePattern ::new ( new_blank_node . clone ( ) , iri ( "http://www.w3.org/1999/02/22-rdf-syntax-ns#first" ) , objWithPatterns . focus . clone ( ) ) ) ;
patterns . push ( TriplePattern ::new ( new_blank_node . clone ( ) , iri ( "http://www.w3.org/1999/02/22-rdf-syntax-ns#rest" ) , current_list_node ) ) ;
patterns . push ( TriplePattern ::new ( new_blank_node . clone ( ) , iri ( "http://www.w3.org/1999/02/22-rdf-syntax-ns#rest" ) , current_list_node ) ) ;
current_list_node = new_blank_node ;
current_list_node = new_blank_node ;
@ -1685,14 +1682,14 @@ parser! {
patterns
patterns
}
}
}
}
rule Collection_item ( ) -> FocusedTriplePattern < TermOrVariable > = o :GraphNode ( ) _ { o }
rule Collection_item ( ) -> FocusedTriplePattern < TermPattern > = o :GraphNode ( ) _ { o }
//[103]
//[103]
rule CollectionPath ( ) -> FocusedTripleOrPathPattern < TermOrVariable > = "(" _ o :CollectionPath_item ( ) + _ ")" {
rule CollectionPath ( ) -> FocusedTripleOrPathPattern < TermPattern > = "(" _ o :CollectionPath_item ( ) + _ ")" {
let mut patterns : Vec < TripleOrPathPattern > = Vec ::default ( ) ;
let mut patterns : Vec < TripleOrPathPattern > = Vec ::default ( ) ;
let mut current_list_node = TermOrVariable ::from ( iri ( "http://www.w3.org/1999/02/22-rdf-syntax-ns#nil" ) ) ;
let mut current_list_node = TermPattern ::from ( iri ( "http://www.w3.org/1999/02/22-rdf-syntax-ns#nil" ) ) ;
for objWithPatterns in o . into_iter ( ) . rev ( ) {
for objWithPatterns in o . into_iter ( ) . rev ( ) {
let new_blank_node = TermOrVariable ::from ( bnode ( ) ) ;
let new_blank_node = TermPattern ::from ( bnode ( ) ) ;
patterns . push ( TriplePattern ::new ( new_blank_node . clone ( ) , iri ( "http://www.w3.org/1999/02/22-rdf-syntax-ns#first" ) , objWithPatterns . focus . clone ( ) ) . into ( ) ) ;
patterns . push ( TriplePattern ::new ( new_blank_node . clone ( ) , iri ( "http://www.w3.org/1999/02/22-rdf-syntax-ns#first" ) , objWithPatterns . focus . clone ( ) ) . into ( ) ) ;
patterns . push ( TriplePattern ::new ( new_blank_node . clone ( ) , iri ( "http://www.w3.org/1999/02/22-rdf-syntax-ns#rest" ) , current_list_node ) . into ( ) ) ;
patterns . push ( TriplePattern ::new ( new_blank_node . clone ( ) , iri ( "http://www.w3.org/1999/02/22-rdf-syntax-ns#rest" ) , current_list_node ) . into ( ) ) ;
current_list_node = new_blank_node ;
current_list_node = new_blank_node ;
@ -1703,25 +1700,25 @@ parser! {
patterns
patterns
}
}
}
}
rule CollectionPath_item ( ) -> FocusedTripleOrPathPattern < TermOrVariable > = p :GraphNodePath ( ) _ { p }
rule CollectionPath_item ( ) -> FocusedTripleOrPathPattern < TermPattern > = p :GraphNodePath ( ) _ { p }
//[104]
//[104]
rule GraphNode ( ) -> FocusedTriplePattern < TermOrVariable > =
rule GraphNode ( ) -> FocusedTriplePattern < TermPattern > =
t :VarOrTerm ( ) { FocusedTriplePattern ::new ( t ) } /
t :VarOrTerm ( ) { FocusedTriplePattern ::new ( t ) } /
TriplesNode ( )
TriplesNode ( )
//[105]
//[105]
rule GraphNodePath ( ) -> FocusedTripleOrPathPattern < TermOrVariable > =
rule GraphNodePath ( ) -> FocusedTripleOrPathPattern < TermPattern > =
t :VarOrTerm ( ) { FocusedTripleOrPathPattern ::new ( t ) } /
t :VarOrTerm ( ) { FocusedTripleOrPathPattern ::new ( t ) } /
TriplesNodePath ( )
TriplesNodePath ( )
//[106]
//[106]
rule VarOrTerm ( ) -> TermOrVariable =
rule VarOrTerm ( ) -> TermPattern =
v :Var ( ) { v . into ( ) } /
v :Var ( ) { v . into ( ) } /
t :GraphTerm ( ) { t . into ( ) }
t :GraphTerm ( ) { t . into ( ) }
//[107]
//[107]
rule VarOrIri ( ) -> NamedNodeOrVariable =
rule VarOrIri ( ) -> NamedNodePattern =
v :Var ( ) { v . into ( ) } /
v :Var ( ) { v . into ( ) } /
i :iri ( ) { i . into ( ) }
i :iri ( ) { i . into ( ) }