Skip to content

joeCavZero/calculator-lexer-and-parser

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CALCULATOR LEXER AND PARSER

This project implements a simple calculator lexer and parser in Rust. It can tokenize mathematical expressions, parse into an abstract syntax tree (AST) and evaluate them.

Example Usage

>> 10 + 20
30
>> (5 * 6) - 4
26
>> 3.14 * (2 + 1)
9.42

The calculator supports basic arithmetic operations including addition, subtraction, multiplication, division, and power operations, as well as floating-point numbers. It also supports parentheses for grouping expressions.

Features

  • Tokenization of numbers, operators, and parentheses.
  • Parsing of expressions into an AST using the Pratt parsing technique.
  • Evaluation of expressions with support for floating-point numbers.
  • Error handling for invalid expressions and tokens.

Installation

To use this project, clone the repository and run:

  1. Clone the repository:
git clone https://github.com/joeCavZero/calculator-lexer-and-parser.git
  1. Navigate to the project directory:
cd calculator-lexer-and-parser
  1. Run or build the project:
cargo run
cargo build --release

About

A simple calculator lexer and parser made in rust

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages