An open API service indexing awesome lists of open source software.

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

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)