A simple package for compiler practice
In two phases
- Lexical analyzer
- Syntax analyzer
git clone https://github.com/amirsharifi74/my_compiler_exrecise.git
python3 lexical_analizer/scanner.py -i <input_file> -o <output_file>
Short_param | Long_param | description | default |
---|---|---|---|
-o | --output | path to input source code file | out.txt |
-i | --input | path to outout source code file | test.pp |
Simple grammer to detect array of our custum language(my language name is amir) Give output of Lexical analizer(tokens) and get the syntax error in CMD the rest of the language grammer is similar to this
type -> simple
| id
| array [simple] of type
symple -> integer
| char
| num dotdot num
Short_param | Long_param | description | default |
---|---|---|---|
-i | --input | path to input tokens file | out.txt |
python3 syntax_analizer/parser.py -i <your_tokens_file_path>
Dont forget to install pip install antlr4-python3-runtime
caution: for running my sample code you should generate code for python
cd antlr/
antlr4 -Dlanguage=Python3 Array.g4
First of all write your code in test.pp
cd antlr/
python3 ArrayDetector.py