Skip to content

A toy compiler (lexer-parser) written in python viz RPLY and LLVMLite to calculate simple mathematical expressions.

Notifications You must be signed in to change notification settings

chumba-wamba/calc-it

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Calc-It

A toy compiler (lexer-parser) written in python viz RPLY and LLVMLite to calculate simple mathematical expressions.

To do:

  • Code Lexer. ✔
  • Code Parser. ✔
  • Code AST. ✔
  • Use LLVMLite for optimisation and conversion to machine code.

Installation

Follow the steps to run the web-app on your local machine:

  1. Clone the repository

    git clone https://github.com/chumba-wamba/Calc-It.git
  2. Install the Dependencies

    cd Calc-It
    pip install -r requirements.txt

Usage

  1. Enter the cloned repository

    cd Calc-It
  2. Edit the input string in run.py

    from calc_it.lexer import lexer
    from calc_it.parser import parser
    
    
    if __name__ == "__main__":
       input_string = "1+5**(2*3)"
       tokens = lexer.lex(input_string)
       print(parser.parse(tokens).eval())
  3. Execute the program

     python run.py

    Test

About

A toy compiler (lexer-parser) written in python viz RPLY and LLVMLite to calculate simple mathematical expressions.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages