Skip to content

Add noun literal syntax: [42], [42 99], [[1 2] 3]#25

Merged
sigilante merged 2 commits intomasterfrom
sigilante/noun-literals
Apr 14, 2026
Merged

Add noun literal syntax: [42], [42 99], [[1 2] 3]#25
sigilante merged 2 commits intomasterfrom
sigilante/noun-literals

Conversation

@sigilante
Copy link
Copy Markdown
Owner

Summary

  • Tokenizer: [ 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.
  • New arms: ++ is-pure-noun, ++ noun-lit-one, ++ noun-lit-list replace the dead ++ parse-noun-tok / ++ parse-cell-items stubs. Pure-noun lookahead checks that all content between [ and the matching ] is only numbers or nested brackets.
  • Eval hook: In interpret-mode %word dispatch, [ triggers is-pure-noun lookahead. If pure, the noun literal is expanded to make-atom/make-cell token sequences (from nock.fs) and evaluated. If not pure, falls through to the Tier 14 no-op, preserving [ expr ] LITERAL behaviour.

Examples

[42] get-value       \ → 42 (atom-noun)
[42 99] is-cell?     \ → 1 (true)
[42 99] get-head get-value   \ → 42
[[1 2] 3] get-head is-cell?  \ → 1

Requires make-atom and make-cell from nock.fs to be loaded.

Test plan

  • All 288 test-north.sh tests pass (Tiers 0–21 unaffected)
  • All 34 test-nock.sh tests pass
  • [CHAR] A and [CHAR] 0 still work
  • Tier 14 [ expr ] LITERAL still 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

sigilante and others added 2 commits April 14, 2026 11:19
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]>
@sigilante sigilante merged commit 97ca094 into master Apr 14, 2026
1 check passed
@sigilante sigilante deleted the sigilante/noun-literals branch April 14, 2026 17:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant