From 74942ae8616a076bfba0d21652bb5a046d90f9ca Mon Sep 17 00:00:00 2001 From: DavePearce Date: Thu, 24 Oct 2024 16:49:09 +0100 Subject: [PATCH] Reset internal primitive naming This resets some of the naming used for the internal primitives. This is to make a clear separation from the original corset syntax. --- pkg/schema/assignment/data_column.go | 2 +- pkg/schema/assignment/sorted_permutation.go | 2 +- pkg/schema/constraint/lookup.go | 2 +- pkg/schema/constraint/permutation.go | 2 +- pkg/schema/constraint/vanishing.go | 13 +++++++------ 5 files changed, 11 insertions(+), 10 deletions(-) diff --git a/pkg/schema/assignment/data_column.go b/pkg/schema/assignment/data_column.go index 19350f4..54ddff6 100644 --- a/pkg/schema/assignment/data_column.go +++ b/pkg/schema/assignment/data_column.go @@ -68,7 +68,7 @@ func (p *DataColumn) IsComputed() bool { // Lisp converts this schema element into a simple S-Expression, for example // so it can be printed. func (p *DataColumn) Lisp(schema sc.Schema) sexp.SExp { - col := sexp.NewSymbol("defcolumns") + col := sexp.NewSymbol("column") name := sexp.NewSymbol(p.Columns().Next().QualifiedName(schema)) // if p.datatype.AsField() != nil { diff --git a/pkg/schema/assignment/sorted_permutation.go b/pkg/schema/assignment/sorted_permutation.go index 6a873b5..a71abbc 100644 --- a/pkg/schema/assignment/sorted_permutation.go +++ b/pkg/schema/assignment/sorted_permutation.go @@ -152,7 +152,7 @@ func (p *SortedPermutation) Lisp(schema sc.Schema) sexp.SExp { } return sexp.NewList([]sexp.SExp{ - sexp.NewSymbol("defpermutation"), + sexp.NewSymbol("sort"), targets, sources, }) diff --git a/pkg/schema/constraint/lookup.go b/pkg/schema/constraint/lookup.go index 84c72be..da0bdb1 100644 --- a/pkg/schema/constraint/lookup.go +++ b/pkg/schema/constraint/lookup.go @@ -156,7 +156,7 @@ func (p *LookupConstraint[E]) Lisp(schema sc.Schema) sexp.SExp { } // Done return sexp.NewList([]sexp.SExp{ - sexp.NewSymbol("deflookup"), + sexp.NewSymbol("lookup"), sexp.NewSymbol(p.handle), targets, sources, diff --git a/pkg/schema/constraint/permutation.go b/pkg/schema/constraint/permutation.go index 9290e64..1b47a68 100644 --- a/pkg/schema/constraint/permutation.go +++ b/pkg/schema/constraint/permutation.go @@ -86,7 +86,7 @@ func (p *PermutationConstraint) Lisp(schema sc.Schema) sexp.SExp { } return sexp.NewList([]sexp.SExp{ - sexp.NewSymbol("defpermutation"), + sexp.NewSymbol("permutation"), targets, sources, }) diff --git a/pkg/schema/constraint/vanishing.go b/pkg/schema/constraint/vanishing.go index fe54a34..4ce503e 100644 --- a/pkg/schema/constraint/vanishing.go +++ b/pkg/schema/constraint/vanishing.go @@ -215,20 +215,21 @@ func HoldsLocally[T sc.Testable](k uint, handle string, constraint T, tr tr.Trac // //nolint:revive func (p *VanishingConstraint[T]) Lisp(schema sc.Schema) sexp.SExp { - attributes := sexp.EmptyList() + name := p.handle // Handle attributes if p.domain == nil { // Skip } else if *p.domain == 0 { - attributes.Append(sexp.NewSymbol(":first")) + name = fmt.Sprintf("%s:first", name) + } else if *p.domain == -1 { + name = fmt.Sprintf("%s:last", name) } else { - attributes.Append(sexp.NewSymbol(":last")) + panic(fmt.Sprintf("domain value %d not supported for local constraint", p.domain)) } // Construct the list return sexp.NewList([]sexp.SExp{ - sexp.NewSymbol("defconstraint"), - sexp.NewSymbol(p.handle), - attributes, + sexp.NewSymbol("vanish"), + sexp.NewSymbol(name), p.constraint.Lisp(schema), }) }