This project demonstrates the use of the PLY (Python Lex-Yacc) library to build lexical analyzers and parsers for a subset of Python constructs. It features:
- Syntax validation for function definitions
- Parsing for control structures (if/else, for, while)
- Support for list declarations
- Function declaration parsing
- If and If-Else conditional parsing
- For loop parsing (including range variations)
- While loop parsing with logical expressions
- List declaration parsing with support for integers, floats, and strings
- Error handling for invalid syntax and tokens
- Python 3.x
- PLY library (
pip install ply)
- Install Python 3.x and the PLY library (
pip install ply). - Clone or download the project files.
- Run any parser script (e.g.,
python function_parser.py). - Enter a code snippet when prompted to validate its syntax.
- function_parser.py: Parser for function declarations
- if_else_parser.py: Parser for if and if-else conditionals
- for_loop_parser.py: Parser for for loops
- while_loop_parser.py: Parser for while loops
- list_parser.py: Parser for list declarations
- This project is developed for educational purposes as part of AFLL coursework.
- Each parser handles a specific subset of Python syntax.