Sure! Here's a detailed README.md file tailored for your uploaded C programs that implement:
- LL(1) Parser
- First and Follow computation
- Operator Precedence Parser
- Leading and Trailing computation
# 🔍 Parser Implementations in C
This repository contains C programs to implement various parsing techniques used in Compiler Design:
- ✅ LL(1) Parser
- ✅ FIRST and FOLLOW set computation
- ✅ Operator Precedence Parser
- ✅ LEADING and TRAILING set computation
---
## 📁 Files Included
| File | Description |
|------------------------------|-------------|
| `ll1_parser.c` | Implements an LL(1) parser using predictive parsing table |
| `first_follow.c` | Calculates the FIRST and FOLLOW sets of a given grammar |
| `operator_precedence.c` | Parses expressions using operator precedence relations |
| `leading_trailing.c` | Computes the LEADING and TRAILING sets for operator precedence grammars |
---
## ⚙️ How to Compile and Run
### Step 1: Compile
Use `gcc` to compile any of the source files. Example:
```bash
gcc ll1_parser.c -o ll1_parserExecute the compiled file:
./ll1_parserRepeat the steps for each individual file.
- Uses a predictive parsing table
- Requires FIRST and FOLLOW sets
- Input is parsed using a stack and table lookup
- FIRST: set of terminals that begin strings derivable from a non-terminal
- FOLLOW: set of terminals that can appear immediately to the right of a non-terminal in some sentential form
- Handles expressions like
i+i*i - Uses precedence relations (
<,>,=) to decide when to shift or reduce - Employs a precedence table for terminals
- Used in construction of operator precedence grammar
- LEADING: terminals that appear at the start of strings derived from a non-terminal
- TRAILING: terminals that appear at the end
- Expressions use
ias a placeholder for identifiers - Terminals such as
+,*,(,)are used in operator precedence - Ensure grammars are suitable (non-left-recursive for LL(1), operator precedence for others)
- LL(1): Grammar rules and a string to test
- FIRST/FOLLOW: Grammar in production form
- Operator Precedence: Expression like
i+i*i - LEADING/TRAILING: Grammar for precedence relation setup
Anuj Gupta
B.Tech CSE (Full Stack AI), UPES
This project is open-source and free to use for educational purposes.
---
Let me know if you want me to auto-generate a table of contents, add code samples, or convert this into a formatted `README.md` file you can directly push to GitHub.