style: rename repr to expr (#44)

## Description

The `Repr` type name was unclear — it was intended to represent a lambda calculus expression, not a "representation."
This PR renames `Repr` to `Expr` throughout the registry package for clarity.

- Rename `Repr` interface to `Expr` and `baseRepr` struct to `baseExpr`.
- Rename `repr.go` to `expr.go`.
- Rename `ID()` method to `Repr()` to indicate the representation type.
- Rename `NewRepr` constructor to `NewExpr`.
- Update all usages in codec, conversion, engine, process, and registry files.
- Add command aliases `conv` and `eng` for `convert` and `engine` subcommands.

## Benefits

- The naming better reflects the domain: an `Expr` is an expression, and `Repr()` returns its representation kind.
- Command aliases reduce typing for common subcommands.

## Checklist

- [x] Code follows conventional commit format.
- [x] Branch follows naming convention (`<type>/<description>`). Always use underscores.
- [x] Tests pass (if applicable).
- [x] Documentation updated (if applicable).

Reviewed-on: #44
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 #44.
This commit is contained in:
2026-02-07 15:26:50 +00:00
committed by Maxim Hutz
parent bbe027e9f4
commit 1f486875fd
9 changed files with 54 additions and 50 deletions

View File

@@ -40,16 +40,18 @@ func (r *Registry) GetDefaultEngine(id string) (Engine, error) {
}
}
return nil, fmt.Errorf("no engine for '%s'", id)
return r.GetEngine("normalorder")
// return nil, fmt.Errorf("no engine for '%s'", id)
}
func (r *Registry) ConvertTo(repr Repr, outType string) (Repr, error) {
path, err := r.ConversionPath(repr.ID(), outType)
func (r *Registry) ConvertTo(expr Expr, outType string) (Expr, error) {
path, err := r.ConversionPath(expr.Repr(), outType)
if err != nil {
return nil, err
}
result := repr
result := expr
for _, conversion := range path {
result, err = conversion.Run(result)
if err != nil {
@@ -60,16 +62,16 @@ func (r *Registry) ConvertTo(repr Repr, outType string) (Repr, error) {
return result, err
}
func (r *Registry) Marshal(repr Repr) (string, error) {
m, ok := r.codecs[repr.ID()]
func (r *Registry) Marshal(expr Expr) (string, error) {
m, ok := r.codecs[expr.Repr()]
if !ok {
return "", fmt.Errorf("no marshaler for '%s'", repr.ID())
return "", fmt.Errorf("no marshaler for '%s'", expr.Repr())
}
return m.Encode(repr)
return m.Encode(expr)
}
func (r *Registry) Unmarshal(s string, outType string) (Repr, error) {
func (r *Registry) Unmarshal(s string, outType string) (Expr, error) {
m, ok := r.codecs[outType]
if !ok {
return nil, fmt.Errorf("no marshaler for '%s'", outType)