docs: document remaining packages and simplify AST types (#45)
## Summary - Added doc comments across the codebase: `pkg/lambda`, `pkg/saccharine`, `pkg/codec`, `pkg/engine`, `pkg/iterator`, `pkg/set`, `pkg/convert`, `internal/registry`, and `cmd/lambda`. - Made lambda and saccharine expression structs use public fields instead of getters, matching `go/ast` conventions. - Removed superfluous constructors for saccharine and lambda expression/statement types in favor of struct literals. - Consolidated saccharine token constructors into a single `NewToken` function. - Removed the unused `trace` package. ## Test plan - [x] `go build ./...` passes. - [x] `go test ./...` passes. - [ ] Verify `go doc` output renders correctly for documented packages. Reviewed-on: #45 Co-authored-by: M.V. Hutz <git@maximhutz.me> Co-committed-by: M.V. Hutz <git@maximhutz.me>
This commit was merged in pull request #45.
This commit is contained in:
@@ -4,28 +4,32 @@ import (
|
||||
"git.maximhutz.com/max/lambda/pkg/engine"
|
||||
)
|
||||
|
||||
// A Process is a type-erased reduction process that operates on Expr values.
|
||||
type Process interface {
|
||||
engine.Process[Expr]
|
||||
|
||||
// InType returns the name of the representation this process operates on.
|
||||
InType() string
|
||||
}
|
||||
|
||||
type convertedProcess[T any] struct {
|
||||
// A registeredProcess adapts a typed engine.Process[T] into the type-erased
|
||||
// Process interface. It wraps the result of Get into an Expr.
|
||||
type registeredProcess[T any] struct {
|
||||
process engine.Process[T]
|
||||
inType string
|
||||
}
|
||||
|
||||
func (e convertedProcess[T]) InType() string { return e.inType }
|
||||
func (p registeredProcess[T]) InType() string { return p.inType }
|
||||
|
||||
func (b convertedProcess[T]) Get() (Expr, error) {
|
||||
s, err := b.process.Get()
|
||||
func (p registeredProcess[T]) Get() (Expr, error) {
|
||||
s, err := p.process.Get()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return NewExpr(b.inType, s), nil
|
||||
return NewExpr(p.inType, s), nil
|
||||
}
|
||||
|
||||
func (b convertedProcess[T]) Step(i int) bool {
|
||||
return b.process.Step(i)
|
||||
func (p registeredProcess[T]) Step(i int) bool {
|
||||
return p.process.Step(i)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user