This project aims to develop a custom lexer and parser in Python using PLY (Python Lex-Yacc) to validate common syntax in the Java programming language.
- Custom Lexer: Tokenizes input Java code according to defined regular expressions.
- Custom Parser: Parses tokenized input according to specified grammar rules to validate syntax.
- Modular Design: Easily extendable for adding more syntax validations.
-
Clone this repository:
git clone https://github.com/your_username/java-syntax-validator.git
-
Install the required Python packages:
pip install ply
-
Navigate to the project directory.
-
Run the following command:
python code_array.py
-
Enter a sample array declaration statement when prompted, e.g.
int[] arr = new int[50];. -
The program will output whether the input statement is a valid Java array declaration or not.
- Repeat steps 2-4 from the above section, replacing
code_array.pywith the corresponding validator script (e.g.,code_construct.py).
Note: This project is intended for educational purposes and may not cover the full spectrum of Java syntax. Use at your discretion.