This project defines an SLR (Simple LR) grammar and implements both a lexical analyzer and a syntactical analyzer using Java.
- SLR Grammar Definition: Define and process SLR grammars.
- Lexical Analyzer: Tokenize input strings based on the grammar.
- Syntactical Analyzer: Parse tokens and validate input strings against the defined grammar.
- Lexical Analyzer: Responsible for breaking input strings into tokens.
- Syntactical Analyzer: Implements the SLR parsing algorithm to validate and parse input strings.
- SLR Grammar Definition: Encodes the rules and structure of the grammar to be parsed.
- Java Development Kit (JDK) 11 or later.
-
Clone the Repository:
git clone https://github.com/eyabesbes/SLR-Grammar-Parser.git cd SLR-Grammar-Parser
-
Compile the Java Files:
javac -d bin src/**/*.java
-
Run the Application:
java -cp bin Main
-
Input Your Grammar and Strings:
- Follow the prompts to input your grammar rules and validate strings.
-
Define a grammar:
S -> A B A -> a B -> b
-
Input a string to parse:
Input: ab
-
The program will validate whether the string conforms to the grammar.
Feel free to contribute to this project by submitting issues or pull requests. Contributions are welcome for the following:
- Enhancements to the grammar definition.
- Optimization of the lexical and syntactical analysis processes.
- Bug fixes or new features.
Developed by Eya Besbes.
- Inspiration for the project came from compiler design concepts.
- Thanks to resources and guides on SLR grammar and Java programming.