Skip to content

[cli] Initialize CLI calculator and implement basic tokenizer and parser#170

Merged
forfudan merged 2 commits intoclifrom
update
Feb 26, 2026
Merged

[cli] Initialize CLI calculator and implement basic tokenizer and parser#170
forfudan merged 2 commits intoclifrom
update

Conversation

@forfudan
Copy link
Copy Markdown
Owner

@forfudan forfudan commented Feb 26, 2026

This PR initializes a CLI calculator application for the Decimo library, implementing a complete expression evaluator with tokenization, parsing (shunting-yard algorithm), and evaluation using BigDecimal arithmetic. The implementation supports basic arithmetic operations (+, -, *, /), parentheses, and unary negation with arbitrary precision.

Changes:

  • Added CLI calculator engine with tokenizer, parser, and evaluator modules
  • Implemented comprehensive test suites for each component (tokenizer, parser, evaluator)
  • Added CLI entry point with ArgMojo for command-line argument parsing
  • Updated project documentation and build configuration

@forfudan forfudan requested a review from Copilot February 26, 2026 16:32
@forfudan forfudan changed the title [cli] Initialize CLI sub-project and implement basic tokenizer and parser [cli] Initialize CLI calculator and implement basic tokenizer and parser Feb 26, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR initializes a CLI calculator application for the Decimo library, implementing a complete expression evaluator with tokenization, parsing (shunting-yard algorithm), and evaluation using BigDecimal arithmetic. The implementation supports basic arithmetic operations (+, -, *, /), parentheses, and unary negation with arbitrary precision.

Changes:

  • Added CLI calculator engine with tokenizer, parser, and evaluator modules
  • Implemented comprehensive test suites for each component (tokenizer, parser, evaluator)
  • Added CLI entry point with ArgMojo for command-line argument parsing
  • Updated project documentation and build configuration

Reviewed changes

Copilot reviewed 13 out of 15 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/cli/main.mojo CLI entry point using ArgMojo for parsing command-line arguments
src/cli/calculator/tokenizer.mojo Lexical analyzer converting expression strings to tokens
src/cli/calculator/parser.mojo Shunting-yard algorithm converting infix to RPN notation
src/cli/calculator/evaluator.mojo RPN evaluator using BigDecimal for arithmetic operations
src/cli/calculator/init.mojo Package initialization exporting public API
tests/cli/test_tokenizer.mojo Comprehensive tokenizer test suite
tests/cli/test_parser.mojo Parser test suite validating precedence and associativity
tests/cli/test_evaluator.mojo End-to-end evaluator tests
tests/test_cli.sh Shell script to run CLI tests
tests/test_all.sh Updated to include CLI tests
pixi.toml Added CLI build tasks and Python dependency
pixi.lock Updated dependency lockfile
docs/readme_unreleased.md Added project structure section and CLI documentation
docs/plans/cli_calculator.md Added Phase 5 future enhancements
.gitignore Added CLI binary to ignore list

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +93 to +99
# Yuhao Zhu:
# I am seriously thinking that whether I should also support recoginizing
# full-width digits and operators, so that users can copy-paste expressions from
# other sources without having to manually convert them. This would be a nice
# feature for Chinese-Japanese-Korean (CJK) users.
# But it would also add some complexity to the tokenizer, because these
# full-width characters have different byte numbers.
Copy link

Copilot AI Feb 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Corrected spelling of 'recoginizing' to 'recognizing'.

Copilot uses AI. Check for mistakes.
Comment on lines +13 to +14
mojo = "==0.26.1"
python = ">=3.13,<3.14"
Copy link

Copilot AI Feb 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The mojo and python dependencies are not in alphabetical order. Consider placing them alphabetically (mojo before python) for consistency with the argmojo entry above.

Copilot uses AI. Check for mistakes.
| v0.6.0 | ==0.25.7 | pixi |
| v0.7.0 | ==0.26.1 | pixi |
| v0.8.0 | ==0.26.1 | pixi |
| libary | version | Mojo version | package manager |
Copy link

Copilot AI Feb 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Corrected spelling of 'libary' to 'library'.

Suggested change
| libary | version | Mojo version | package manager |
| library | version | Mojo version | package manager |

Copilot uses AI. Check for mistakes.
@forfudan forfudan merged commit 3f5d437 into cli Feb 26, 2026
4 of 5 checks passed
@forfudan forfudan deleted the update branch February 26, 2026 17:59
forfudan added a commit that referenced this pull request Mar 23, 2026
…ser (#170)

This PR initializes a CLI calculator application for the Decimo library,
implementing a complete expression evaluator with tokenization, parsing
(shunting-yard algorithm), and evaluation using BigDecimal arithmetic.
The implementation supports basic arithmetic operations (+, -, *, /),
parentheses, and unary negation with arbitrary precision.

**Changes:**
- Added CLI calculator engine with tokenizer, parser, and evaluator
modules
- Implemented comprehensive test suites for each component (tokenizer,
parser, evaluator)
- Added CLI entry point with ArgMojo for command-line argument parsing
- Updated project documentation and build configuration
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.

2 participants