refactor: extract shared token package #46
Reference in New Issue
Block a user
Delete Branch "refactor/shared-token-package"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Description
Both the
saccharineandlambdapackages need tokenizing and parsing primitives.This PR extracts shared token infrastructure into a new
pkg/tokenpackage, then wires both languages up to use it.pkg/tokenwith a genericToken[T]type,Scan,ScanAtom,ScanRune,ScanCharacter,IsVariable,ParseRawToken, andParseList.pkg/saccharineto delegate topkg/token, removing duplicated scanning and parsing helpers.Codec.Decodeforpkg/lambda(scanner + parser) using the shared token package.iterator.Whilefor predicate-driven iteration.iterator.Dotoiterator.Tryto better describe its rollback semantics.Decisions
Typeconstraint (comparable+Name() string) keeps the generic token flexible while ensuring every token type can produce readable error messages.iterator.Dowas renamed toiterator.Trysince it describes a try/rollback operation, not a side-effecting "do".Benefits
lambdapackage to decode (parse) lambda calculus strings, which was previously unimplemented.pkg/tokenprimitives.Checklist
<type>/<description>). Always use underscores.