Add noun literal syntax: [42], [42 99], [[1 2] 3]#25
Merged
Conversation
Three changes to desk/lib/north.hoon:
1. Tokenizer (++ tokenize-src): [ and ] are now self-delimiting — always
emitted as separate word tokens regardless of surrounding whitespace.
Special-cases [CHAR] (4-char lookahead) to keep it as one token.
2. New arms ++ is-pure-noun, ++ noun-lit-one, ++ noun-lit-list replace
the dead ++ parse-noun-tok / ++ parse-cell-items stubs. is-pure-noun
does lookahead from the token after [ to the matching ] and returns %.y
only if all content is numbers or nested [ ] pairs.
3. Eval interpret-mode %word dispatch: when w='[', call is-pure-noun first.
If pure, noun-lit-list builds a make-atom/make-cell token sequence and
evals it recursively. If not pure (e.g. [ 4 + ]), fall through to
run-word('[') which is the existing Tier 14 no-op, preserving
[ expr ] LITERAL behaviour.
All 288 test-north.sh and 34 test-nock.sh tests pass. [CHAR], Tier 14
LITERAL, and bracket-top-level tests unaffected.
Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Previously both push and pull_request triggered CI on every PR commit, running the test suite twice. Now push is limited to master (post-merge validation) and pull_request covers branch commits. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
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.
Summary
[and]are now self-delimiting characters — emitted as separate word tokens without requiring surrounding whitespace.[CHAR]is special-cased with a 4-char lookahead to stay intact.++ is-pure-noun,++ noun-lit-one,++ noun-lit-listreplace the dead++ parse-noun-tok/++ parse-cell-itemsstubs. Pure-noun lookahead checks that all content between[and the matching]is only numbers or nested brackets.%worddispatch,[triggersis-pure-nounlookahead. If pure, the noun literal is expanded tomake-atom/make-celltoken sequences (fromnock.fs) and evaluated. If not pure, falls through to the Tier 14 no-op, preserving[ expr ] LITERALbehaviour.Examples
Requires
make-atomandmake-cellfromnock.fsto be loaded.Test plan
test-north.shtests pass (Tiers 0–21 unaffected)test-nock.shtests pass[CHAR] Aand[CHAR] 0still work[ expr ] LITERALstill works (3 [ 4 + ] 5→~[7])[42] get-value→~[42][42 99] get-head get-value→~[42][[1 2] 3] get-head get-head get-value→~[1]🤖 Generated with Claude Code