From 419ad41ec6b212d8c827b838c68434dd065caf03 Mon Sep 17 00:00:00 2001 From: Aravind Rao Date: Tue, 2 May 2017 11:23:27 -0700 Subject: [PATCH] Added Reification Clause --- bql/grammar/grammar.go | 14 ++++++++++++++ bql/grammar/grammar_test.go | 13 +++++++++++++ 2 files changed, 27 insertions(+) diff --git a/bql/grammar/grammar.go b/bql/grammar/grammar.go index 6e847129..18cc1dcb 100644 --- a/bql/grammar/grammar.go +++ b/bql/grammar/grammar.go @@ -761,6 +761,7 @@ func BQL() *Grammar { NewTokenType(lexer.ItemNode), NewSymbol("CONSTRUCT_PREDICATE"), NewSymbol("CONSTRUCT_OBJECT"), + NewSymbol("REIFICATION_CLAUSE"), NewSymbol("MORE_CONSTRUCT_TRIPLES"), }, }, @@ -769,6 +770,7 @@ func BQL() *Grammar { NewTokenType(lexer.ItemBlankNode), NewSymbol("CONSTRUCT_PREDICATE"), NewSymbol("CONSTRUCT_OBJECT"), + NewSymbol("REIFICATION_CLAUSE"), NewSymbol("MORE_CONSTRUCT_TRIPLES"), }, }, @@ -777,6 +779,7 @@ func BQL() *Grammar { NewTokenType(lexer.ItemBinding), NewSymbol("CONSTRUCT_PREDICATE"), NewSymbol("CONSTRUCT_OBJECT"), + NewSymbol("REIFICATION_CLAUSE"), NewSymbol("MORE_CONSTRUCT_TRIPLES"), }, }, @@ -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{ diff --git a/bql/grammar/grammar_test.go b/bql/grammar/grammar_test.go index 7c3c5d02..c3ea3da2 100644 --- a/bql/grammar/grammar_test.go +++ b/bql/grammar/grammar_test.go @@ -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 { @@ -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())