Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"),
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently, this allows multiple levels of indirection for reification purposes. Should we allow that?

},
},
{},
},
"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