Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
526 commits
Select commit Hold shift + click to select a range
7d370a8
docs: Minor docs TODO updates
dhedey Nov 22, 2025
2972f61
refactor: Remove SourceParseBuffer wrapper, make it a type alias
claude Nov 25, 2025
271e046
style: Apply rustfmt formatting
claude Nov 26, 2025
56e143a
Merge pull request #19 from dhedey/claude/remove-source-parse-buffer-…
dhedey Nov 26, 2025
6b7e028
docs: Update TODO
dhedey Nov 26, 2025
39f3e4d
refactor: Input lives in interpreter
dhedey Nov 27, 2025
0957640
fix: Fix benchmark compilation
dhedey Nov 27, 2025
3b33c0c
fix: Fix benchmarks
dhedey Nov 27, 2025
04922be
Merge pull request #20 from dhedey/inputs-in-interpreter
dhedey Nov 27, 2025
83042f2
refactor: Rename some types
dhedey Nov 28, 2025
3de2753
feat: Distinct inputs have distinct parser handles
dhedey Nov 28, 2025
0ebe247
feat: Add parse expression
dhedey Nov 29, 2025
b1576ed
fix: Style fix
dhedey Nov 29, 2025
c62e917
Merge pull request #21 from dhedey/parser-value
dhedey Nov 29, 2025
63e3e36
fix: Fix typos
dhedey Nov 29, 2025
56a44b5
refactor: Move files around
dhedey Nov 29, 2025
606dccb
docs: Update # Method Calls section
dhedey Nov 29, 2025
65d3ad3
docs: Add BinaryOperation migration plan for first PR
claude Nov 29, 2025
6740c23
docs: Add design decisions and short-circuiting analysis
claude Nov 29, 2025
e07d4f7
fix: Fix typos
dhedey Nov 29, 2025
ddf0c5a
Merge develop branch to get latest code structure
claude Nov 29, 2025
0b94ddf
feat: Add BinaryOperationInterface and migrate UntypedInteger addition
claude Nov 29, 2025
4cbd85b
feat: Add BinaryOperationInterface and migrate paired operations for …
claude Nov 29, 2025
987a01b
refactor: Require explicit binary_operations section in define_interf…
claude Nov 29, 2025
2df9980
refactor: Remove WrappedOp wrapper and move methods to Operation trait
claude Nov 29, 2025
6dbb385
tweak: Tweaks to operations
dhedey Nov 29, 2025
5db7e1a
Merge branch 'claude/plan-binary-operation-01LM7vmsPfPLnkZmfFgx6Jo1' …
dhedey Nov 29, 2025
db33a43
feat: Finish migrating addition operators
dhedey Nov 29, 2025
21de31e
feat: Migrate Subtraction, Multiplication, Division, Remainder operat…
claude Nov 29, 2025
08e6691
docs: Mark Subtraction/Multiplication/Division/Remainder migration as…
claude Nov 29, 2025
28f2228
feat: Migrate LogicalAnd and LogicalOr operations
claude Nov 29, 2025
370ab39
Merge pull request #24 from dhedey/claude/migrate-binary-operations-0…
dhedey Nov 29, 2025
efa4051
feat: Migrate BitXor, BitAnd, and BitOr operations
claude Nov 29, 2025
36d2d84
feat: Migrate comparison operations (Equal, NotEqual, LessThan, etc.)
claude Nov 29, 2025
3b3b784
docs: Mark Equal, NotEqual and comparison operations migration as com…
claude Nov 29, 2025
afa3e2c
refactor: Simplify boolean comparisons and use resolve_as in paired_c…
claude Nov 29, 2025
25b935d
Merge pull request #25 from dhedey/claude/migrate-binary-operations-0…
dhedey Nov 29, 2025
bf417f7
refactor: Migrate SHL/SHR
dhedey Nov 29, 2025
f79735e
refactor: Remove dead code
dhedey Nov 29, 2025
ebb867b
refactor: Minor tweak to resolve_untyped_to_match
dhedey Nov 30, 2025
80cecc5
refactor: Merge assignee frames with value frames
dhedey Nov 30, 2025
6aee824
refactor: Lots more renames
dhedey Nov 30, 2025
5671671
refactor: Further renames and deletions
dhedey Nov 30, 2025
7eb80e0
refactor: Move some files around
dhedey Nov 30, 2025
598fb0c
refactor: Rename expression value types to simplified names
claude Nov 30, 2025
0344410
Merge pull request #26 from dhedey/claude/rename-expression-types-01U…
dhedey Nov 30, 2025
1c57ca4
refactor: Merge HasValueType and ValueKind into unified trait system
claude Nov 30, 2025
5bebf40
feat: Add RangeKind enum for detailed range type descriptions
claude Nov 30, 2025
30244f5
Merge pull request #27 from dhedey/claude/merge-value-kind-traits-014…
dhedey Nov 30, 2025
fbf843e
feat: Migrated CompoundAssignments
dhedey Dec 1, 2025
8ed9a79
fix: Fix style (tests still broken)
dhedey Dec 1, 2025
8e18ec8
fix: Be more permissive about ownership in multiple-operand operations
dhedey Dec 2, 2025
020dfa2
refactor: Flatten BinaryOperation enum by combining three separate types
claude Dec 2, 2025
519cda3
fix: Fix formatting and clippy warnings after flattening BinaryOperation
claude Dec 2, 2025
948c631
Merge pull request #29 from dhedey/claude/binary-operation-migration-…
dhedey Dec 2, 2025
215c042
refactor: Migrate UntypedInteger to store FallbackInteger directly
claude Dec 2, 2025
62fc904
fix: Use try_into in UntypedInteger::into_kind with proper error hand…
claude Dec 2, 2025
c906fe1
fix: Various markups
dhedey Dec 2, 2025
738b0a7
fix: Fix style
dhedey Dec 2, 2025
ff591f3
Merge pull request #30 from dhedey/claude/migrate-untypedinteger-018H…
dhedey Dec 2, 2025
babaf24
refactor: Migrate comparison operators (<, <=, >, >=) to IntegerValue…
claude Dec 2, 2025
609afac
Merge pull request #31 from dhedey/claude/migrate-comparison-operator…
dhedey Dec 2, 2025
749fffd
fix: Improved articles for types in error messages
dhedey Dec 2, 2025
8f581ea
fix: Fix styling
dhedey Dec 2, 2025
6a0b407
Merge pull request #32 from dhedey/fix-articles-of-acronyms
dhedey Dec 2, 2025
f7ec7f1
docs: Tweak some TODOs
dhedey Dec 2, 2025
2e6aece
docs: Update TODOs
dhedey Dec 3, 2025
3e73306
feat: Add == and != support for all value types
claude Dec 3, 2025
9e23f15
refactor: Make values_equal exhaustive over Value variants
claude Dec 3, 2025
0c73b8d
refactor: Introduce ValuesEqual trait for value equality
claude Dec 3, 2025
b144576
test: Add comprehensive operations test coverage
claude Dec 3, 2025
6c35a01
refactor: Change ValuesEqual::typed_eq to use Spanned parameters
claude Dec 3, 2025
546e4b8
refactor: Introduce EqualityContext for flexible equality comparison
claude Dec 4, 2025
c706621
refactor: Change ValuesEqual to use C::Result with context methods
claude Dec 4, 2025
98411a0
feat: Add DebugEquality context for detailed assertion errors
claude Dec 5, 2025
f053ec8
feat: Add debug_display for value types and improve error messages
claude Dec 5, 2025
0d5164f
feat: Add remove_transparent_groups method and document equality sema…
claude Dec 5, 2025
3fdfb60
refactor: Preserve transparent groups in stream equality comparison
claude Dec 5, 2025
faac41a
docs: Fix stream equality note to reflect transparent group preservation
claude Dec 5, 2025
91a8424
test: Add compilation error test for object missing key assertion
claude Dec 5, 2025
a20f348
test: Add typed_eq compilation error test for object value type mismatch
claude Dec 5, 2025
e521139
refactor: Use exhaustive match pattern in IntegerValue and FloatValue…
claude Dec 6, 2025
ea5c5dc
docs: Condense equality methods documentation note in TODO.md
claude Dec 6, 2025
77c3218
refactor: Slight tweak to impl_delegated_resolvable_argument_for
dhedey Dec 6, 2025
d4d2f44
refactor: Various minor improvements to equality code
dhedey Dec 6, 2025
8716174
fix: Fix TODO spacing
dhedey Dec 6, 2025
a7935aa
tweak: Fix parser debug
dhedey Dec 6, 2025
51cacb8
Merge branch 'binary-operation-migration' into claude/add-equality-op…
dhedey Dec 6, 2025
4f4b048
fix: Remove duplicated imports
dhedey Dec 6, 2025
24494a0
Merge pull request #34 from dhedey/claude/add-equality-operators-01D8…
dhedey Dec 6, 2025
2edb46e
docs: Add TODO for non-finite float support (infinity, NaN)
claude Dec 6, 2025
4d5ff0d
Merge remote-tracking branch 'origin/binary-operation-migration' into…
claude Dec 6, 2025
b6d8834
refactor: Simplify compilation failure tests to use run!()
claude Dec 6, 2025
65106d1
refactor: Replace preinterpret_assert_eq macro with direct assert_eq …
claude Dec 6, 2025
21c415c
feat: Added support for type properties
dhedey Dec 6, 2025
22c0ba7
Merge binary-operation-migration branch
claude Dec 6, 2025
ec29fa6
feat: Add support for non-finite float values (infinity, NaN)
claude Dec 6, 2025
bebc619
refactor: Remove misleading array_add compilation failure test
claude Dec 6, 2025
f9d8cea
fix: Fixed linter
dhedey Dec 6, 2025
4a71281
Merge pull request #35 from dhedey/claude/add-operations-tests-018FQe…
dhedey Dec 6, 2025
4bf5787
docs: Update TODO.md
dhedey Dec 6, 2025
25d57e7
Merge pull request #23 from dhedey/binary-operation-migration
dhedey Dec 6, 2025
6bc75a8
feat: Added ParseTemplate literal and pattern
dhedey Dec 6, 2025
5dd79ee
fix: Fixed parse template pattern
dhedey Dec 6, 2025
f9e42f5
refactor: Migrate parsing tests from transforming.rs to parsing.rs
claude Dec 6, 2025
c98c75f
Merge pull request #37 from dhedey/claude/migrate-parsing-tests-01CU9…
dhedey Dec 6, 2025
912c250
tweak: Move some more tests
dhedey Dec 6, 2025
73940a2
refactor: Removed transformers
dhedey Dec 6, 2025
71d67ee
feat: Add input handler fork/commit/rollback for attempt block reversion
claude Dec 7, 2025
c5a083f
tests: Adds test for raw string literals
dhedey Dec 7, 2025
3c83a40
refactor: Redesign ParseStack with per-level fork stacks for nested f…
claude Dec 7, 2025
b92f7a7
feat: Add parser open/close methods and extensive attempt block parsi…
claude Dec 7, 2025
07eba6f
fix: Add delimiter validation to exit_group and test for mismatched d…
claude Dec 7, 2025
e98b7d3
refactor: Simplify revertible segment by matching result for commit/r…
claude Dec 7, 2025
fb8676a
fix: Use Owned<char> for open/close delimiter to get correct error span
claude Dec 7, 2025
44a2960
feat: Improve close error messages and add test for closing without open
claude Dec 7, 2025
5ddee41
fix: Improve close delimiter error messages for clarity
claude Dec 7, 2025
027ed4d
docs: Update TODO.md - mark reversion complete, add unclosed group issue
claude Dec 7, 2025
297ffd4
refactor: Improve test readability and use expect() for infallible ex…
claude Dec 7, 2025
5cc007d
feat: Add tests for open/close patterns and verify drop glue behavior
claude Dec 7, 2025
65e2b67
fix: Check for unclosed groups in finish_parse before dropping ParseS…
claude Dec 7, 2025
c7cd141
feat: Add tests for open/close patterns and verify drop glue behavior
claude Dec 7, 2025
3489020
fix: Improve error message for unclosed groups
claude Dec 7, 2025
fb37499
fix: Tiny tweaks
dhedey Dec 7, 2025
7369378
Merge pull request #38 from dhedey/claude/fix-attempt-reversion-01J8e…
dhedey Dec 7, 2025
fdcef1d
test: Add comprehensive tests for Parser methods
claude Dec 7, 2025
17869a0
Merge pull request #39 from dhedey/claude/add-parser-tests-01MJVe6AJB…
dhedey Dec 7, 2025
f789129
docs: Update TODOs
dhedey Dec 7, 2025
cdaf36b
docs: Added a TODO about hygiene
dhedey Dec 7, 2025
84fc16f
fix: Fix error messages
dhedey Dec 7, 2025
9ef6cac
Merge pull request #36 from dhedey/parsing-rework
dhedey Dec 7, 2025
8385e7a
docs: Small TODO updates
dhedey Dec 7, 2025
8e65ac4
sandbox: Add explorations of GATs and dyn
dhedey Dec 8, 2025
0aa0733
refactor: Change Spanned and Owned/Shared/Mutable to tuple structs (WIP)
claude Dec 8, 2025
5188a04
refactor: Continue updating type signatures for Spanned pattern
claude Dec 8, 2025
1026c69
refactor: Complete Spanned/Owned/Shared/Mutable tuple struct refactoring
claude Dec 8, 2025
2f22aeb
refactor: Change Leaf::Value to Spanned<SharedValue>
claude Dec 9, 2025
6bb4a61
refactor: Thread spans through expression evaluation system
claude Dec 9, 2025
ed71d07
refactor: Pass spans as explicit parameters to return methods
claude Dec 10, 2025
90f8037
fix: Restore proper span propagation to match old behavior
claude Dec 10, 2025
d66bc64
refactor: Simplify AssignmentCompletion to unit struct
claude Dec 10, 2025
5a86acc
docs: Add session summary for continuation
claude Dec 10, 2025
7734fb7
Document refactoring instructions for SpanRanges
dhedey Dec 10, 2025
ecb34fe
refactor: Thread spans through operation interfaces and ownership map…
claude Dec 10, 2025
a73b062
WIP: Add span parameters to resolution and argument traits
claude Dec 11, 2025
84df582
refactor: Complete span propagation through type resolution system
claude Dec 11, 2025
285d913
fix: Fix compile errors on MSRV
dhedey Dec 11, 2025
73e5d7c
refactor: Rename Evaluate trait methods and return Spanned from Expre…
claude Dec 11, 2025
c661b28
refactor: Thread spans through more expression evaluation paths
claude Dec 11, 2025
ddd8fac
refactor: Implement ResolveAs on Spanned<X> instead of taking span pa…
claude Dec 11, 2025
bb6e0cc
refactor: Thread spans through remaining call_site() usages
claude Dec 11, 2025
77ef402
refactor: Move enable/disable to Spanned wrappers for better span tra…
claude Dec 11, 2025
1485937
refactor: Remove SpannedArgumentValue type alias
claude Dec 11, 2025
5c682a6
Merge remote-tracking branch 'origin/develop' into claude/refactor-sp…
claude Dec 11, 2025
78ff4ef
fix: Update sandbox to use Spanned tuple struct syntax
claude Dec 11, 2025
e0b7419
refactor: ExecutionOutcome wraps Spanned<T>, map_from_owned takes Spa…
claude Dec 11, 2025
f3792dc
refactor: map_from_* methods take Spanned<X> and return Spanned<Reque…
claude Dec 11, 2025
d6052bc
refactor: Use Spanned<LateBoundValue> instead of internal span_range …
claude Dec 11, 2025
c760f8e
refactor: Context methods take Spanned<T> and WhileExpression uses wh…
claude Dec 11, 2025
90ae1fd
refactor: Move enable methods to Spanned<T> and fix transparent_clone…
claude Dec 11, 2025
c7d48eb
fix: Use into_owned_transparently for CopyOnWrite conversions
claude Dec 12, 2025
811726b
fix: Various span fixes
dhedey Dec 13, 2025
25c158c
fix: Fix argument parsing macros
dhedey Dec 13, 2025
6176b76
fix: Removed Spanned alises
dhedey Dec 13, 2025
b1e6f2c
fix: Fix variable naming
dhedey Dec 13, 2025
da70788
fix: Fix some more spans
dhedey Dec 13, 2025
637f0ad
fix: More small fixes
dhedey Dec 13, 2025
d5edb9a
fix: More fixes
dhedey Dec 13, 2025
63a0308
fix: Fixed various values
dhedey Dec 13, 2025
551fea3
fix: Further value fixes
dhedey Dec 13, 2025
d7155ff
fix: More fixes
dhedey Dec 13, 2025
6e8cfc8
fix: Final fixes to span refactor
dhedey Dec 13, 2025
2012834
fix: Final final span fixes
dhedey Dec 13, 2025
98f7054
fix: Fix benchmarks build
dhedey Dec 13, 2025
6214904
fix: Fix MSRV build
dhedey Dec 13, 2025
95258f8
fix: Remove sandbox from build
dhedey Dec 13, 2025
4399a27
fix: Fix build
dhedey Dec 13, 2025
0845fba
Merge pull request #41 from dhedey/claude/refactor-spanranges-019yX8q…
dhedey Dec 13, 2025
87bb665
refactor: Fix up some imports
dhedey Dec 13, 2025
02cffd7
Merge pull request #42 from dhedey/chore/normalize-imports
dhedey Dec 13, 2025
02145d1
feat: Start of expression concepts
dhedey Dec 15, 2025
df5fa8a
refactor: Small tweaks/fixes
dhedey Dec 16, 2025
2f9b393
fix: Fix MSRV
dhedey Jan 1, 2026
6f4931e
Merge branch 'main' into develop
dhedey Jan 1, 2026
84d7a2b
fix: Fix example compilation
dhedey Jan 1, 2026
1bb6765
feat: Add concatenated literals
dhedey Jan 1, 2026
8d92ddb
Merge pull request #46 from dhedey/feature/add-back-concatenated-lite…
dhedey Jan 1, 2026
fdaa568
feat: Add clarification for %xyz[] misparse
dhedey Jan 1, 2026
5666894
Merge pull request #47 from dhedey/docs/improve-error-message-on-stre…
dhedey Jan 1, 2026
33435fa
Merge branch 'develop' into refactor/gat-values
dhedey Jan 1, 2026
6391cbf
refactor: GAT improvements
dhedey Jan 2, 2026
fc9ff9b
refactor: Further concept improvements
dhedey Jan 2, 2026
0c1e9a0
refactor: Remove RangeKind, replace with RangeStructure
dhedey Jan 2, 2026
e77e355
feat: Further type macro additions
dhedey Jan 2, 2026
0fd758a
feat: Add type macro for each value
dhedey Jan 2, 2026
f7737dd
feat: Generated types are used for value kinds
dhedey Jan 3, 2026
106cadc
feature: Create Ref and Mut
dhedey Jan 3, 2026
6910a60
feat: Generate from_source_kind from macros
dhedey Jan 3, 2026
a19fc06
tweak: Tweak inlining
dhedey Jan 3, 2026
66ff59d
refactor: Rename value_kinds.rs to type_kinds.rs
dhedey Jan 3, 2026
826fa63
refactor: CastTarget wraps ValueLeafKind
dhedey Jan 4, 2026
5ee6741
feat: Dyn types can be implemented in leaf type macros
dhedey Jan 4, 2026
95f88e0
refactor: Rename MethodResolver to TypeFeatureResolver
dhedey Jan 4, 2026
f37f9a0
refactor: Migrate type feature resolution
dhedey Jan 4, 2026
58e4a19
refactor: Migrate parent type content
dhedey Jan 5, 2026
25cdcca
fix: Fix MSRV compilation
dhedey Jan 5, 2026
7426af5
fix: Fully fix MSRV compilation
dhedey Jan 5, 2026
1cd07c1
feat: Add compile time benchmarks
dhedey Jan 5, 2026
c80da37
feat: Partial completion of float migration
dhedey Jan 5, 2026
8b57f84
fix: An f32 can resolve from an unsuffixed literal
dhedey Jan 5, 2026
14e7a49
fix: Fix MSRV build
dhedey Jan 5, 2026
69782a8
Merge pull request #48 from dhedey/refactor/float-gat-values
dhedey Jan 5, 2026
58b3ecd
tweak: Removed Actual wrapper type
dhedey Jan 6, 2026
8ee1dc2
fix: Fix style
dhedey Jan 6, 2026
8d8c1ab
Merge pull request #49 from dhedey/refactor/remove-actual-wrapper
dhedey Jan 6, 2026
3148029
refactor: Extract impl_value_content_traits sub-macro
claude Jan 6, 2026
b363b40
feat: Add Assignee leaf type
dhedey Jan 7, 2026
ecef785
Merge remote-tracking branch 'origin/refactor/gat-values' into claude…
claude Jan 7, 2026
40efdba
feat: Add BeAssignee impls to impl_value_content_traits macro
claude Jan 7, 2026
0f157bd
Merge pull request #51 from dhedey/claude/extract-value-content-macro…
dhedey Jan 7, 2026
85ebdf6
refactor: Remove Owned wrapper from FloatValue
dhedey Jan 7, 2026
3aaf25e
refactor: Migrate value to AnyValue
dhedey Jan 8, 2026
15efe69
refactor: Remove `Owned` as its own wrapper
dhedey Jan 8, 2026
87ccd83
tweak: Prepare type aliases for Shared/Mutable/Assignee migration
dhedey Jan 8, 2026
9b157f2
tweak: Add LeafLifetimeCapture parameter to handle transmute
dhedey Jan 10, 2026
3616d01
refactor: Move out mappers to mapping.rs
dhedey Jan 10, 2026
d31da33
refactor: Partially revert parts
dhedey Jan 11, 2026
33881f8
fix: Fix benchmark compilation
dhedey Jan 11, 2026
c630687
refactor: Assume hierarchical types in more places
dhedey Jan 11, 2026
a3ee6a4
refactor: Simplify ref and mut mappers
dhedey Jan 11, 2026
ed3b87f
refactor: Migrate owned mapping
dhedey Jan 11, 2026
76e0d55
refactor: Remove MapperOutput
dhedey Jan 11, 2026
29a43e5
refactor: Form leaf is now a function of leaf type
dhedey Jan 11, 2026
1af52d7
refactor: Slight perf improvement to resolving as ref
dhedey Jan 11, 2026
03a84ac
refactor: Remove downcast_resolve_spanned in favour of downcast_resolve
dhedey Jan 11, 2026
054d900
refactor: `downcast` returns a result too
dhedey Jan 11, 2026
de83c1a
refactor: Create `map_via_leaf` for simpler leaf map code
dhedey Jan 12, 2026
6331276
refactor: Blanket impl leaf / content conversion for various forms
dhedey Jan 15, 2026
6dedf69
refactor: Content associated types have useful trait bounds
dhedey Jan 15, 2026
3b469b9
refactor: Remove the need for e.g. content_to_leaf methods
dhedey Jan 15, 2026
5edc0e7
feat: First impl of map for new CopyOnWrite
dhedey Jan 17, 2026
5eff453
refactor: Tweaks to map impl
dhedey Jan 17, 2026
d1e0134
refactor: Upcast and Downcast are form independent
dhedey Jan 17, 2026
9fcc3ff
fix: Fix styling
dhedey Jan 17, 2026
fa94cd8
feat: Resolve property/index access from type
dhedey Jan 17, 2026
aa82ede
refactor: Argument resolution works inside of new system
dhedey Jan 18, 2026
5210750
refactor: Return values can use new system
dhedey Jan 18, 2026
ca93b36
fix: Fix MSRV
dhedey Jan 18, 2026
e33ee65
docs: Update docs
dhedey Jan 18, 2026
9e1e780
Merge pull request #43 from dhedey/refactor/gat-values
dhedey Jan 24, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
29 changes: 27 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ permissions:
contents: read

env:
RUSTFLAGS: -Dwarnings
RUSTFLAGS: -Dwarnings # Deny warnings - i.e. warnings cause build errors

jobs:
test:
Expand All @@ -31,6 +31,8 @@ jobs:
- name: Enable type layout randomization
run: echo RUSTFLAGS=${RUSTFLAGS}\ -Zrandomize-layout >> $GITHUB_ENV
if: matrix.rust == 'nightly'
- name: Add TEST_RUST_MODE env variable
run: echo TEST_RUST_MODE=${{matrix.rust}} >> $GITHUB_ENV
- run: cargo test
- uses: actions/upload-artifact@v4
if: matrix.rust == 'nightly' && always()
Expand All @@ -39,7 +41,7 @@ jobs:
path: Cargo.lock

msrv:
name: Fresh install of MSRV across self (1.61) + latest dependencies (1.68) compiles
name: MSRV (1.68) Compiles
runs-on: ubuntu-latest
timeout-minutes: 45
steps:
Expand All @@ -61,6 +63,29 @@ jobs:
toolchain: stable
- run: ./style-check.sh

benches:
name: Benchmarks
runs-on: ubuntu-latest
timeout-minutes: 45
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
- run: ./bench_compilation.sh
- run: ./bench.sh

book:
name: Rust Book Test
runs-on: ubuntu-latest
timeout-minutes: 45
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
- run: ./book/test.sh

miri:
name: Miri
runs-on: ubuntu-latest
Expand Down
44 changes: 44 additions & 0 deletions .github/workflows/publish_book.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Publish book to Github Pages

on:
push:
branches:
- main

permissions:
contents: read # to read the docs and build job
pages: write # to deploy to pages
id-token: write # to verify the deployment originates from an appropriate source

jobs:
# Build job - https://github.com/actions/upload-pages-artifact
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
# Sets up the repository configuration for github pages to be deployed from an action
- name: Setup Pages
uses: actions/configure-pages@v5
# Builds the book and outputs to book/book
- name: Build book
run: ./book/build.sh
# Creates a correctly compressed archive from the build HTML file, and outputs it as
# a `github-pages` artifact
- name: Upload static files as artifact
uses: actions/upload-pages-artifact@v3
with:
path: book/book

# Deployment job - https://github.com/actions/deploy-pages
deploy:
runs-on: ubuntu-latest
needs: build
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
# Deploys the artifact `github-pages` created by the `upload-pages-artifact` job
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
6 changes: 6 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
// I was getting errors such as this when Rust Analyzer starts:
// 'PrimeCaches#5' has overflowed its stack
// This setting apparently avoids this https://github.com/rust-lang/rust-analyzer/issues/19698#issuecomment-2833543017
"rust-analyzer.cachePriming.enable": false
}
115 changes: 115 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,118 @@
# Major Version 1.0

## 1.0.0

This moves preinterpret to an expression-based language, inspired by Rust, but with some twists to make writing code generation code quicker:
* Token streams as a native feature
* Flexible Javascript-like objects/arrays
* New expressions such as `attempt { .. }` for trying alternatives

### Variable Expansions

* `#x` outputs the contents of `x`.
* `#(x.to_group())` outputs the contents of `x` in a transparent group.

### New Commands

* Core commands:
* Creating errors:
* `%[].error("Error Message")` to output a compile error at the macro call site
* `%[_].error("Error Message")` to output a compile error at the given line
* `%[$token].error("Error Message")` to output a compile error at the span of the tokens
* `%[].assert(<condition>, <message>)` to assert the condition is true, else output a compile error at the macro call site
* `%[_].assert(<condition>, <message>)` to assert the condition is true, else output a compile error at the given line
* `%[$token].assert(<condition>, <message>)` to assert the condition is true, else output a compile error at the span of the tokens
* `#(x += %[...];)` to add extra tokens to a variable's stream.
* `#(let _ = %[...];)` interprets its arguments but then ignores any outputs.
* `%[...]` can be used to just output its interpreted contents. It's useful to create a stream value inside an expression.
* `%[...].reinterpret_as_run()` is like an `eval` command in scripting languages. It takes a stream, and runs it as a preinterpret expression block content like `run!{ ... }`. Similarly, `%[...].reinterpret_as_stream()` runs it as a stream literal, like `stream!{ ... }`. Each is pure - the reinterpreted code can't read from or write to variables, and can only return values.
* `None.configure_preinterpret(%{ iteration_limit: XXX })` can be used to adjust the iteration limit.
* Expression commands:
* The expression block `#(let x = 123; let y = 1.0; y /= x; y + 1)` which is discussed in more detail below.
* Control flow commands:
* `[!if! <expression> { ... }]` and `[!if! <expression> { ... } !elif! <expression> { ... } !else! { ... }]`
* `[!while! <expression> { ... }]`
* `[!for! <destructuring> in [ ... ] { ... }]`
* `[!loop! { ... }]`
* `[!continue!]`
* `[!break!]`
* Token-stream utility commands:
* `<iterable>.is_empty()`
* `<iterable>.len()` which for streams gives the number of token trees in the token stream.
* `%group[...]` which wraps the tokens in a transparent group. Can be useful if using token streams as iteration sources, e.g. in `!for!`.
* `<any iterable>.intersperse(<separator (any value)>, <options>?)` which inserts the separator between each value from the iterator, and returns a vec. This can then be handled as a vector, embedded in a stream, or mapped with `to_string()` or `to_stream()` as required.
* `<stream>.split(<separator (stream)>, <options>?)` which can be used to split a stream with a given separating stream.
* `[countries, flags, capitals].zip()` or `%{ countries, flags, capitals }.zip()` which can be used to combine multiple streams together.

### Expressions

Expressions can be evaluated with `#(...)` and are also used in the `!if!` and `!while!` loop conditions.

Expressions behave intuitively as you'd expect from writing regular rust code, except they are executed at compile time.

The `#(...)` expression block behaves much like a `{ .. }` block in rust. It supports multiple statements ending with `;` and optionally a final statement.

Statements are either expressions `EXPR` or `let x = EXPR`, `x = EXPR`, `x += EXPR` for some operator such as `+`.

Assigment:
* `let <pattern> = <value>` which supports patterns include ignore (`_`), array destructurings (`[a, b, ..]`), object destructurings `{ a: x, b, .. }`, and stream parsing `%[..]`.

The following are recognized values:
* Object literals `%{ x: "Hello", y, ["z"]: "World" }` behave similarly to Javascript objects.
* Token stream literals `%[...]` take any token stream, and support embedding `#variables` or `#(<..expressions..>)` inside them.
* Raw token stream literals `%raw[...]` are used to capture raw tokens, and are not interpreted (e.g. `#` has no special meaning).
* Integer literals, with or without a suffix
* Float literals, with or without a suffix
* Boolean literals
* String literals
* Char literals
* Other literals
* Rust [ranges](https://doc.rust-lang.org/reference/expressions/range-expr.html)
* Token streams which are defined as `[...]`.

The following operators are supported:
* The numeric operators: `+ - * / % & | ^`
* The lazy boolean operators: `|| &&`
* The comparison operators: `== != < > <= >=`
* The shift operators: `>> <<`
* The concatenation operator: `+` can be used to concatenate strings and streams.
* Casting with `as` including to untyped integers/floats with `as int` and `as float` and to a flattened stream with `as stream`.
* () and none-delimited groups for precedence

The following methods are supported:
* On all values:
* `.clone()` - converts a reference to a mutable value. You will be told in an error if this is needed.
* `.as_mut()` - converts an owned value to a mutable value. You will be told in an error if this is needed.
* `.take()` - takes the value from a mutable reference, and replaces it with `None`. Useful instead of cloning.
* `.debug()` - a debugging aid whilst writing code. Causes a compile error with the content of the value. Roughly equivalent to `%[_].error(x.to_debug_string())`
* `.to_debug_string()` - returns the value's contents as a string for debugging purposes
* On arrays: `len()` and `push()`
* On streams: `len()`

An expression also supports embedding commands `[!xxx! ...]`, other expression blocks, variables and flattened variables. The value type outputted by a command depends on the command.

### Transforming

Transforming performs parsing of a token stream, whilst also outputting a stream. The input stream must be parsed in its entirety.

Transform streams (or substreams) can be redirected to set variables or append to variables. Commands can also be injected to add to the output.

Inside a transform stream, the following grammar is supported:

* `@(...)`, `@(#x = ...)`, `@(#x += ...)` and `@(_ = ...)` - Explicit transform (sub)streams which either output, set, append or discard its output.
* Explicit punctuation, idents, literals and groups. These aren't output by default, except directly inside a `@[EXACT ...]` transformer.

* Named destructurings:
* `@IDENT` - Consumes and output any ident.
* `@PUNCT` - Consumes and outputs any punctation
* `@LITERAL` - Consumes and outputs any literal
* `@REST` - Consumes the rest of the input, until the end of the stream or content of the current group
* `@[UNTIL x]` - Consumes the rest of the input, until the end of stream OR until token `x`. `x` can be a group like `()` which matches the opening bracket `(`.
* `@[GROUP ...]` - Consumes a none-delimited group. Its arguments are used to transform the group's contents.
* `@[EXACT(%[..])]` - Takes an input stream expression. Expects to consume exactly that stream from the output (ignoring none-groups). It outputs the parsed stream.
* Commands: Their output is appended to the transform's output. Useful patterns include:
* If `@(inner = ...)` then `inner.to_group()` - wraps the output in a transparent group

# Major Version 0.2

## 0.2.1
Expand Down
71 changes: 71 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

## Project Overview

Preinterpret is a Rust procedural macro crate that provides macros which form a code generation toolkit that simplifies declarative macro development. It combines functionality from quote, paste, and syn crates to enable:

- Variable definition and substitution with `#(let var = %[...];)` and `#var`
- Commands for concatenation, case conversion, and token manipulation like `[!ident! ...]`, `[!string! ...]`, `[!ident_snake! ...]`
- Control flow and parsing capabilities

## Plans and Tasks

There are various files in the `./plans` folder, the "current vision" is `2025-09-vision.md` and the "todo list" is `TODO.md`.

## Architecture

The codebase is organized into several main modules:

- **src/lib.rs** - Main entry point and public API
- **src/interpretation/** - Core interpreter logic for processing commands and variables
- `interpreter.rs` - Main interpreter implementation
- `commands/` - Built-in command implementations (concat, transforming, control flow, etc.)
- `bindings.rs` - Variable binding management
- **src/expressions/** - Expression evaluation system for advanced features
- `evaluation/` - Expression evaluator with type resolution and frame management
- **src/transformation/** - Token stream transformation utilities
- **src/extensions/** - Helper traits and utilities for working with proc-macro2 tokens

## Development Commands

### Testing
- `cargo test` - Run all tests
- `cargo test --release` - Run tests in release mode
- `cargo miri test` - Run tests with Miri for memory safety

### Code Quality
- `./style-check.sh` - Check formatting and run clippy (equivalent to CI checks)
- `./style-fix.sh` - Auto-fix formatting and clippy issues
- `cargo fmt --check` - Check formatting only
- `cargo clippy --tests` - Run clippy lints

### Build & Check
- `cargo build` - Build the crate
- `cargo check` - Quick syntax/type check
- `./local-check-msrv.sh` - Test minimum supported Rust version (1.63)

### Documentation
- `cargo doc --open` - Build and open documentation
- `./book/test.sh` - Build the mdbook documentation

## Key Implementation Notes

This is a proc-macro crate (`proc-macro = true` in Cargo.toml) that:

- Uses syn 2.0 for parsing with full feature set enabled
- Supports minimum Rust version 1.63 (Edition 2021)
- Employs RefCell/Rc patterns for interior mutability in expression evaluation
- Uses trybuild for compile-time testing of macro expansions

The expression system (newer feature) provides advanced capabilities like mathematical operations and control flow, built on top of the core interpretation framework.

## Testing Strategy

Tests are located in the `tests/` directory and use trybuild for testing compilation failures. The CI runs tests on stable, beta, and nightly Rust versions with warnings treated as errors.

## Commit Strategy

* Run `style-fix.sh` before committing
* Use the conventional commits pattern for commit message prefixes.
25 changes: 20 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,29 @@ keywords = ["macros", "declarative-macros", "toolkit", "interpreter", "preproces
# And whilst there's a development-tools::procedural-macro-helpers, there's no declarative macro category.
categories = ["development-tools", "compilers"]
# MSRV 1.56.0 is the start of Edition 2021
# MSRV 1.61.0 was the old MSRV of syn
# MRSV 1.68.0 is the new latest MSRV of syn (as of syn 2.0.107 released on 19th October 2025) - but keeping on MSRV 1.61.0 for now
# MSRV 1.61.0 is the old MSRV of syn
# MRSV 1.63.0 is needed to support RefMut::filter_map
# MRSV 1.68.0 is the new latest MSRV of syn (as of syn 2.0.107 released on 19th October 2025)
# If changing this, also update the local-check-msrv.sh script and ci.yml
rust-version = "1.61"
rust-version = "1.68"

[lib]
proc-macro = true

[[bench]]
name = "basic"
harness = false
required-features = ["benchmark"]

[features]
benchmark = [] # For internal use only
debug = [] # Non-stable, for internal use only

[dependencies]
proc-macro2 = { version = "1.0" }
syn = { version = "2.0", default-features = false, features = ["parsing"] }
proc-macro2 = { version = "1.0.93" }
syn = { version = "2.0.107", default-features = false, features = ["parsing", "derive", "printing", "clone-impls", "full"] }
quote = { version = "1.0.38", default-features = false }
slotmap = { version = "1.0.7" }

[dev-dependencies]
trybuild = { version = "1.0.110", features = ["diff"] }
7 changes: 7 additions & 0 deletions KNOWN_ISSUES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Since Major Version 0.3.0

* `[MAX LITERAL]` - In an expression, the maximum negative integer literal is not valid, for example `-128i8`.
* By comparison, in `rustc`, there is special handling for such literals, so that e.g. `-128i8` and `--(-128i8)` are accepted.
* In rust analyzer, before the full pass, it seems to store literals as u128 and perform wrapping arithmetic on them. On a save / full pass, it does appear to reject literals which are out of bounds (e.g. 150i8).
* We could fix this by special casing maximal signed integer literals (e.g. 128 for an i8) which have yet to be involved in a non-unary expression.

Loading