Scientific CLI Engine and Expression Parser
A C++ command-line calculator and expression parser designed to process arithmetic expressions, variables, parentheses, and calculation history. The project focuses on parsing logic, operator precedence, stacks, queues, tokenization, and file persistence.
Project Status
Core expression parsing and calculator functionality is implemented. Some features shown in the help screen are still planned or require refinement.
Feature Status
Implemented — Working
- Command-line calculator interface
- Addition, subtraction, multiplication, and division
- Parentheses
- Operator precedence
- Expression tokenization
- Basic decimal-number parsing
- Unary positive/negative number handling
- Variables from
atoz - Variable assignment
- Calculation history
- History persistence using
CHistory.txt - Help command
- Clear command
- Exit command
- Invalid-expression detection
- C++ STL containers including
map,stack,deque, andvector
Partially Implemented / Needs Refinement
- Expression evaluation — The parser/evaluator is implemented, but the current result assignment contains a code-level issue that can cause the displayed result to remain incorrect.
- Error handling — Invalid expressions are detected, but edge cases such as division by zero need stronger handling.
- Variable parsing — Basic variables work, but the parser can be improved for more complex expressions and assignments.
Planned — Coming Soon
The following features are not currently implemented or need to be completed:
- Scientific functions such as
sin(),cos(), andlog(). - More complete scientific operations.
- Stronger division-by-zero protection.
- Improved expression grammar and parser validation.
- Better result/error reporting.
- Expanded variable expressions.
- Unit and automated tests.
- Cleaner parser architecture.
How the Parser Works
User Expression
│
▼
Text Normalization
│
▼
Tokenization
│
▼
Operator / Operand Analysis
│
▼
Postfix / Polish-Notation Processing
│
▼
Expression Evaluation
│
▼
Result + History File
Example Expressions
5 + 2 * 3
(4 + 6) / 2
x = 5
x + 10
Available Commands
| Command | Purpose |
|---|---|
help |
Display the help screen |
history |
Display saved calculation history |
clear |
Clear the console |
exit |
Exit the application |
Technologies & Concepts
- C++
- Standard Template Library (STL)
- Expression parsing
- Tokenization
- Operator precedence
- Stack-based processing
- File I/O
- Object-oriented programming
Project Structure
Scientific CLI Engine and Expression Parser/
├── Scientific CLI Engine and Expression Parser.cpp
├── Scientific CLI Engine and Expression Parser.sln
├── Scientific CLI Engine and Expression Parser.vcxproj
├── CHistory.txt
└── README.md
Getting Started
- Open the
.slnfile in Visual Studio. - Build the project using the available C++ configuration.
- Run the executable.
- Enter an expression or one of the supported commands.
Learning Objectives
This project demonstrates practical work with:
- Lexical/token-level parsing.
- Operator precedence.
- Stack and queue based algorithms.
- Expression evaluation.
- Variables and state management.
- File persistence.
- Console application design.
Roadmap
The next updates will focus on completing scientific functions, improving parser reliability, strengthening error handling, and making the evaluation engine more robust.
Author
Aseelcoding
Built With
- and-calculation-history.-the-project-focuses-on-parsing-logic
- c++
- operator-precedence
- parentheses
- queues
- stacks
- tokenization
- variables
Log in or sign up for Devpost to join the conversation.