Skip to content

Commit

Permalink
Added Reification Clause
Browse files Browse the repository at this point in the history
  • Loading branch information
apr94 committed May 2, 2017
1 parent 320fbca commit 419ad41
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
14 changes: 14 additions & 0 deletions bql/grammar/grammar.go
Original file line number Diff line number Diff line change
Expand Up @@ -761,6 +761,7 @@ func BQL() *Grammar {
NewTokenType(lexer.ItemNode),
NewSymbol("CONSTRUCT_PREDICATE"),
NewSymbol("CONSTRUCT_OBJECT"),
NewSymbol("REIFICATION_CLAUSE"),
NewSymbol("MORE_CONSTRUCT_TRIPLES"),
},
},
Expand All @@ -769,6 +770,7 @@ func BQL() *Grammar {
NewTokenType(lexer.ItemBlankNode),
NewSymbol("CONSTRUCT_PREDICATE"),
NewSymbol("CONSTRUCT_OBJECT"),
NewSymbol("REIFICATION_CLAUSE"),
NewSymbol("MORE_CONSTRUCT_TRIPLES"),
},
},
Expand All @@ -777,6 +779,7 @@ func BQL() *Grammar {
NewTokenType(lexer.ItemBinding),
NewSymbol("CONSTRUCT_PREDICATE"),
NewSymbol("CONSTRUCT_OBJECT"),
NewSymbol("REIFICATION_CLAUSE"),
NewSymbol("MORE_CONSTRUCT_TRIPLES"),
},
},
Expand Down Expand Up @@ -815,6 +818,17 @@ func BQL() *Grammar {
},
},
},
"REIFICATION_CLAUSE": []*Clause{
{
Elements: []Element{
NewTokenType(lexer.ItemSemicolon),
NewSymbol("CONSTRUCT_PREDICATE"),
NewSymbol("CONSTRUCT_OBJECT"),
NewSymbol("REIFICATION_CLAUSE"),
},
},
{},
},
"MORE_CONSTRUCT_TRIPLES": []*Clause{
{
Elements: []Element{
Expand Down
13 changes: 13 additions & 0 deletions bql/grammar/grammar_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,15 @@ func TestAcceptByParse(t *testing.T) {
_:v "_object"@[] ?o} into ?a from ?b where {?n "_subject"@[] ?s.
?n "_predicate"@[] ?p.
?n "_object"@[] ?o};`,
`construct {?s "predicate_1"@[] ?o1;
"predicate_2"@[] ?o2} into ?a from ?b where {?s "old_predicate_1"@[,] ?o1.
?s "old_predicate_2"@[,] ?o2};`,

`construct {?s "predicate_1"@[] ?o1;
"predicate_2"@[] ?o2.
?s "predicate_3"@[] ?o3} into ?a from ?b where {?s "old_predicate_1"@[,] ?o1.
?s "old_predicate_2"@[,] ?o2.
?s "old_predicate_3"@[,] ?o3};`,
}
p, err := NewParser(BQL())
if err != nil {
Expand Down Expand Up @@ -229,6 +238,10 @@ func TestRejectByParse(t *testing.T) {
// Construct clause with badly formed triple.
`construct {?s ?p ?o.
_:v "some_pred"@[]} into ?a from ?b where {?s "foo"@[,] ?o};`,
// Construct clause with badly formed reification clause.
`construct {?s "predicate_1"@[] ?o1;
?s "predicate_2"@[] ?o2} into ?a from ?b where {?s "old_predicate_1"@[,] ?o1.
?s "old_predicate_2"@[,] ?o2};`,

}
p, err := NewParser(BQL())
Expand Down

0 comments on commit 419ad41

Please sign in to comment.