Skip to content

Allow customizing PostMachine blank and mark symbols#56

Merged
mellonis merged 1 commit intomasterfrom
feat/custom-alphabet-55
May 4, 2026
Merged

Allow customizing PostMachine blank and mark symbols#56
mellonis merged 1 commit intomasterfrom
feat/custom-alphabet-55

Conversation

@mellonis
Copy link
Copy Markdown
Owner

@mellonis mellonis commented May 4, 2026

Closes #55.

Summary

  • Adds optional second constructor arg new PostMachine(instructions, { blankSymbol?, markSymbol? }).
  • When either symbol is overridden, the constructor builds a per-instance Alphabet + TapeBlock. The default path still clones originalTapeBlock to keep existing behavior identical.
  • CommandContext gains blankSymbol and markSymbol; mark / erase / check now read these from the context instead of the module-level constants. left / right / noop are unaffected (no symbol writes).
  • New validateSymbolPair rejects multi-char or equal symbols up front with a clear message; null / undefined fall back to the defaults via ??.

Public API

  • PostMachine constructor signature widened — the second arg is optional, so existing callers compile and run unchanged.
  • New exported type PostMachineOptions.
  • blankSymbol / markSymbol / alphabet module exports unchanged — they remain the defaults.

Tests

  • 22 new tests in packages/machine/test/custom-alphabet.spec.ts covering: default path regression, validation errors, partial overrides, full override (mark/erase/check semantics, subroutines, groups, summarizePostMachine invariants, non-ASCII glyphs / ).
  • New Custom symbols README example with matching test in examples.spec.ts (per repo doc-parity rule).
  • Full suite: 119 tests passing (was 96).

Known limitation (out of scope)

equivalentPostMachines clones the originating tapeBlock per case. Comparing a custom-alphabet machine against a default-alphabet machine via the wrapper will hit symbol-interning mismatches in upstream equivalentOn. Cross-alphabet equivalence is an upstream concern; the bare equivalentOn re-export is the existing escape hatch. Worth a follow-up if it bites in practice.

Test plan

  • npm test — 119 passing (was 96, +22 new + 1 README example).
  • npm run lint — clean.
  • npm run build — builds; pre-existing Rollup this-at-module-top warnings are unchanged.

Adds an optional second constructor argument
`{ blankSymbol?, markSymbol? }`. When either is supplied, PostMachine
builds a per-instance Alphabet/TapeBlock and threads the chosen symbols
into CommandContext so mark/erase/check use the per-instance pair.
Defaults are unchanged (' ' / '*'); module-level constants remain
exported as the defaults.
@mellonis mellonis merged commit fc685f7 into master May 4, 2026
5 checks passed
@mellonis mellonis deleted the feat/custom-alphabet-55 branch May 4, 2026 23:22
@github-project-automation github-project-automation Bot moved this from Todo to Done in @mellonis's machines May 4, 2026
@mellonis mellonis mentioned this pull request May 4, 2026
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Allow customizing the blank/mark symbols of a PostMachine

1 participant