What is our project?
Compiler-like algebraic expression simplifier
- It can simplify the algebraic expression
What is our project?
Tools
- Tokenizer, parser, and optimizer
- Python3, LLVMPY, and PLY
Why These Tools?
- Python3 is easy to use
- PLY is based on Python,
- contains LAX as tokenizor
- YACC as parser
- LLVMPY is the optimizer, python version of LLVM
Motivation
- Chemical formula translator
- Get a better understanding of the compiler by using easier objects
- Solve the real life problem
The Grammer
- Operators: PLUS, MINUS, TIMES, etc
- Constants: ln2, 2^2, etc
- Regular numbers
- Variables: x^2, y^23
e.g. x^2 + 2x^2 + ln3 =
The Precedence of Parser
It is simple shift-reduce parser (LR(1)), because they are simple expressions
The precedence:
('left','PLUS','MINUS')
('left','TIMES','DIVIDE')
('right','UMINUS') e.g. (-5)
Challange
- Rugular expression
- Get familiar with new tools
- Constract rules
Where to Go From Here?
Dedending on how many time we left, we can finish the parser or optimizer