Allow customizing PostMachine blank and mark symbols#56
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #55.
Summary
new PostMachine(instructions, { blankSymbol?, markSymbol? }).Alphabet+TapeBlock. The default path still clonesoriginalTapeBlockto keep existing behavior identical.CommandContextgainsblankSymbolandmarkSymbol;mark/erase/checknow read these from the context instead of the module-level constants.left/right/noopare unaffected (no symbol writes).validateSymbolPairrejects multi-char or equal symbols up front with a clear message;null/undefinedfall back to the defaults via??.Public API
PostMachineconstructor signature widened — the second arg is optional, so existing callers compile and run unchanged.PostMachineOptions.blankSymbol/markSymbol/alphabetmodule exports unchanged — they remain the defaults.Tests
packages/machine/test/custom-alphabet.spec.tscovering: default path regression, validation errors, partial overrides, full override (mark/erase/checksemantics, subroutines, groups,summarizePostMachineinvariants, non-ASCII glyphs␣/•).Custom symbolsREADME example with matching test inexamples.spec.ts(per repo doc-parity rule).Known limitation (out of scope)
equivalentPostMachinesclones the originating tapeBlock per case. Comparing a custom-alphabet machine against a default-alphabet machine via the wrapper will hit symbol-interning mismatches in upstreamequivalentOn. Cross-alphabet equivalence is an upstream concern; the bareequivalentOnre-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 Rollupthis-at-module-top warnings are unchanged.