Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds end-to-end variable support to the Decimo CLI calculator (tokenization → parsing → evaluation) and wires it into the interactive REPL with ans and name = expr assignment, plus corresponding tests and docs updates.
Changes:
- Introduce
TOKEN_VARIABLEand extend the tokenizer/parser/evaluator pipeline to handle variable references. - Add REPL variable store with
anstracking andname = exprassignment support (with reserved-name validation). - Add tests for variable tokenization and evaluation; update planning/docs and decimo exports (
Integeralias).
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/cli/test_tokenizer.mojo | Adds tokenizer tests for variable tokens and precedence vs funcs/constants. |
| tests/cli/test_evaluator.mojo | Adds evaluator tests for variable resolution (including ans) and undefined-variable errors. |
| src/decimo/prelude.mojo | Re-exports Integer from bigint in the prelude. |
| src/decimo/bigint/bigint.mojo | Adds comptime Integer = BigInt alias. |
| src/decimo/init.mojo | Exports Integer at the package root. |
| src/cli/calculator/tokenizer.mojo | Adds TOKEN_VARIABLE and optional known-variable handling during identifier lexing. |
| src/cli/calculator/repl.mojo | Implements REPL variable store, assignment parsing, reserved-name validation, and updates banner. |
| src/cli/calculator/parser.mojo | Treats TOKEN_VARIABLE like numbers/constants in shunting-yard output. |
| src/cli/calculator/evaluator.mojo | Resolves TOKEN_VARIABLE via a provided Dict[String, Decimal] and raises on undefined vars. |
| src/cli/calculator/engine.mojo | Threads variable names into tokenization and passes variable dict into evaluation; adds evaluate_and_return. |
| src/cli/calculator/init.mojo | Exports TOKEN_VARIABLE and evaluate_and_return. |
| docs/todo.md | Adds a TODO note about potentially flipping Decimal/BigDecimal naming. |
| docs/plans/cli_calculator.md | Marks Phase 4 variable features as complete and extends the plan table. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
This PR adds end-to-end variable support to the Decimo CLI calculator (tokenization → parsing → evaluation) and wires it into the interactive REPL with
ansandname = exprassignment, plus corresponding tests and docs updates.Changes:
TOKEN_VARIABLEand extend the tokenizer/parser/evaluator pipeline to handle variable references.anstracking andname = exprassignment support (with reserved-name validation).Integeralias).