This project is a simple compiler for a subset of the Python language ("MiniPy"), built using Flex (lexical analyzer) and Bison (parser generator). It demonstrates key concepts in compiler design, including lexical analysis, syntax analysis, symbol tables, and intermediate code generation. The key challenge is handling indentation.
projet.l— Flex specification for lexical analysis.projet.y— Bison specification for syntax analysis and parsing.TS.h— Symbol table implementation.quad.h— Quadruple/intermediate code representation.pile.h— Stack utilities for parsing or code generation.exemple.txt— Example MiniPy source code for testing.minipy.bat— Batch file for building or running the project (Windows).readme.md— Project documentation.
- Flex
- Bison
- GCC (or compatible C compiler)
- Generate the lexer and parser:
flex projet.l bison -d projet.y gcc -o minipy lex.yy.c projet.tab.c -lfl
- Run the compiler on an example file:
./minipy exemple.txt
- Tokenizes and parses a subset of Python syntax.
- Builds a symbol table for variables and functions.
- Generates intermediate code using quadruples.
- Demonstrates basic error handling.
Edit exemple.txt with your MiniPy code and run the compiler as shown above. The output will display parsing results and intermediate code.
For educational use.