https://github.com/alafty/cfg_epsilon_unit_elimination
Task 4 for the Compilers lab where the needed deliverables are two functions: one that removes epsilon rules from a CFG and another that removes unit rules from the same CFG
https://github.com/alafty/cfg_epsilon_unit_elimination
cfg compiler compiler-design context-free-grammar java
Last synced: about 1 month ago
JSON representation
Task 4 for the Compilers lab where the needed deliverables are two functions: one that removes epsilon rules from a CFG and another that removes unit rules from the same CFG
- Host: GitHub
- URL: https://github.com/alafty/cfg_epsilon_unit_elimination
- Owner: alafty
- Created: 2024-03-06T21:47:01.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-03-07T00:15:03.000Z (about 2 years ago)
- Last Synced: 2025-06-11T06:04:59.370Z (12 months ago)
- Topics: cfg, compiler, compiler-design, context-free-grammar, java
- Language: Java
- Homepage:
- Size: 2.2 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# CFG Epsilon and Unit Rule Elimination
This Java program performs epsilon and unit rule elimination on a context-free grammar (CFG). It provides functionality to parse a CFG, eliminate epsilon rules, and eliminate unit rules.
## Features
- Parses a formatted string representation of a CFG.
- Eliminates epsilon rules from the CFG.
- Eliminates unit rules from the CFG.
## Input Format
The input string representation of the CFG should follow the following format:
```
Variables#Terminals#Rules
```
- Variables: A semicolon-separated list of variables.
- Terminals: A semicolon-separated list of terminals.
- Rules: A semicolon-separated list of rules, where each rule is of the form `Variable/Production1,Production2,...`.
Example input:
```
S;A;B;C#a;b;c;d;x#S/aAb,xB;A/Bc,C,c,d;B/CACA,e;C/A,b,e
```
## Output
The program outputs the modified CFG after eliminating epsilon and unit rules.
## Authors
- [Mohamed El-Alafty](https://github.com/alafty)