-
Notifications
You must be signed in to change notification settings - Fork 64
Added clause hooks for CONSTRUCT statement. #69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -140,6 +140,16 @@ func CollectGlobalBounds() ElementHook { | |
| return collectGlobalBounds() | ||
| } | ||
|
|
||
| // InitWorkingConstructClauseHook returns the singleton for clause accumulation within the construct statement. | ||
| func InitWorkingConstructClauseHook() ClauseHook { | ||
| return InitWorkingConstructClause() | ||
| } | ||
|
|
||
| // NextWorkingConstructClauseHook returns the singleton for clause accumulation within the construct statement. | ||
| func NextWorkingConstructClauseHook() ClauseHook { | ||
| return NextWorkingConstructClause() | ||
| } | ||
|
|
||
| // TypeBindingClauseHook returns a ClauseHook that sets the binding type. | ||
| func TypeBindingClauseHook(t StatementType) ClauseHook { | ||
| var f ClauseHook | ||
|
|
@@ -567,7 +577,7 @@ func whereObjectClause() ElementHook { | |
| return f | ||
| } | ||
|
|
||
| // whereObjectClause returns an element hook that updates the object | ||
| // varAccumulator returns an element hook that updates the object | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thx! |
||
| // modifiers on the working graph clause. | ||
| func varAccumulator() ElementHook { | ||
| var ( | ||
|
|
@@ -862,3 +872,26 @@ func collectGlobalBounds() ElementHook { | |
| } | ||
| return f | ||
| } | ||
|
|
||
| // InitWorkingConstructClause returns a clause hook to initialize a new working | ||
| // construct clause. | ||
| func InitWorkingConstructClause() ClauseHook { | ||
| var f ClauseHook | ||
| f = func(s *Statement, _ Symbol) (ClauseHook, error) { | ||
| s.ResetWorkingConstructClause() | ||
| return f, nil | ||
| } | ||
| return f | ||
| } | ||
|
|
||
|
|
||
| // NextWorkingConstructClause returns a clause hook to close the current working | ||
| // construct clause and start a new working construct clause. | ||
| func NextWorkingConstructClause() ClauseHook { | ||
| var f ClauseHook | ||
| f = func(s *Statement, _ Symbol) (ClauseHook, error) { | ||
| s.AddWorkingConstructClause() | ||
| return f, nil | ||
| } | ||
| return f | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -136,7 +136,7 @@ func TestTypeBindingClauseHook(t *testing.T) { | |
| st := &Statement{} | ||
| f(st, Symbol("FOO")) | ||
| if got, want := st.Type(), Insert; got != want { | ||
| t.Errorf("semantic.TypeBidingHook failed to set the right type; got %s, want %s", got, want) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wow... |
||
| t.Errorf("semantic.TypeBindingHook failed to set the right type; got %s, want %s", got, want) | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -153,9 +153,14 @@ func TestWhereWorkingClauseHook(t *testing.T) { | |
| f := whereNextWorkingClause() | ||
| st := &Statement{} | ||
| st.ResetWorkingGraphClause() | ||
| wcs := st.WorkingClause() | ||
| wcs.SBinding = "?a" | ||
| f(st, Symbol("FOO")) | ||
| wcs = st.WorkingClause() | ||
| wcs.SBinding = "?b" | ||
| f(st, Symbol("FOO")) | ||
| if got, want := len(st.GraphPatternClauses()), 0; got != want { | ||
|
|
||
| if got, want := len(st.GraphPatternClauses()), 2; got != want { | ||
| t.Errorf("semantic.whereNextWorkingClause should have returned two clauses for statement %v; got %d, want %d", st, got, want) | ||
| } | ||
| } | ||
|
|
@@ -1169,7 +1174,7 @@ func TestBindingsGraphChecker(t *testing.T) { | |
| want bool | ||
| }{ | ||
| { | ||
| id: "missing biding", | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. :'( |
||
| id: "missing binding", | ||
| s: &Statement{ | ||
| pattern: []*GraphClause{ | ||
| {}, | ||
|
|
@@ -1199,7 +1204,7 @@ func TestBindingsGraphChecker(t *testing.T) { | |
| want: false, | ||
| }, | ||
| { | ||
| id: "all bidings available", | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. :'( |
||
| id: "all bindings available", | ||
| s: &Statement{ | ||
| pattern: []*GraphClause{ | ||
| {}, | ||
|
|
@@ -1913,3 +1918,27 @@ func TestCollectGlobalBounds(t *testing.T) { | |
| } | ||
| } | ||
| } | ||
|
|
||
| func TestInitWorkingConstructClauseHook(t *testing.T) { | ||
| f := InitWorkingConstructClause() | ||
| st := &Statement{} | ||
| f(st, Symbol("FOO")) | ||
| if st.WorkingConstructClause() == nil { | ||
| t.Errorf("semantic.InitConstructWorkingClause should have returned a valid working clause for statement %v", st) | ||
| } | ||
| } | ||
|
|
||
| func TestNextWorkingConstructClauseHook(t *testing.T) { | ||
| f := NextWorkingConstructClause() | ||
| st := &Statement{} | ||
| st.ResetWorkingConstructClause() | ||
| wcs := st.WorkingConstructClause() | ||
| wcs.SBinding = "?a" | ||
| f(st, Symbol("FOO")) | ||
| wcs = st.WorkingConstructClause() | ||
| wcs.SBinding = "?b" | ||
| f(st, Symbol("FOO")) | ||
| if got, want := len(st.ConstructClauses()), 2; got != want { | ||
| t.Errorf("semantic.NextConstructWorkingClause should have returned two clauses for statement %v; got %d, want %d", st, got, want) | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thx!