diff --git a/common/voc/voc.go b/common/voc/voc.go index f2ba1d3..50748fe 100644 --- a/common/voc/voc.go +++ b/common/voc/voc.go @@ -17,6 +17,11 @@ func NewVoc[V any](parent *Vocabulary[V]) *Vocabulary[V] { data: VocData[V]{}, } } + +func (voc *Vocabulary[V]) Parent() *Vocabulary[V] { + return voc.parent +} + func (voc *Vocabulary[V]) Register(name string, it V) { vi, ok := voc.data[name] if ok { diff --git a/forge/forge.go b/forge/forge.go index 925175c..a440ca0 100644 --- a/forge/forge.go +++ b/forge/forge.go @@ -1,4 +1,4 @@ -// Package forge implements sort of a stack-based interpreter. +// Package forge implements a stack-based interpreter. package forge import ( diff --git a/forge/rep/json.go b/forge/rep/json.go index 803c077..2c7e018 100644 --- a/forge/rep/json.go +++ b/forge/rep/json.go @@ -8,12 +8,16 @@ import ( func ParseJson(inp string) coderep { var raw interface{} - err := json.Unmarshal([]byte(inp), &raw) + return ParseJsonToTarget(inp, &raw) +} + +func ParseJsonToTarget(inp string, target *interface{}) coderep { + err := json.Unmarshal([]byte(inp), target) if err != nil { log.Error(err).Msg("rep.ParseJson") return nil } - rep := prepare(raw) + rep := prepare(*target) return rep } diff --git a/forge/rep/rep.go b/forge/rep/rep.go index 4f82d93..d25be33 100644 --- a/forge/rep/rep.go +++ b/forge/rep/rep.go @@ -72,7 +72,7 @@ func makeCode(ri []interface{}) code { return c } -// module - code definitions, represented by a map +// module - code definitions, represented by a map that is used as a forge vocabulary type module map[string]citem diff --git a/forge/xt.go b/forge/xt.go index 5b1190b..2f39db3 100644 --- a/forge/xt.go +++ b/forge/xt.go @@ -33,7 +33,7 @@ func (it *gofunc) Code() fptr { } func (it *gofunc) Name() string { - return string(it.name) + return it.name } // acode: anonymous forge code @@ -70,5 +70,5 @@ func FCode(n string, c fptr) XT { } func (it *fcode) Name() string { - return string(it.name) + return it.name }