Skip to content

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

📘 README.md

# 🔍 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_parser

Step 2: Run

Execute the compiled file:

./ll1_parser

Repeat the steps for each individual file.


🧠 Concepts Covered

1. LL(1) Parser

  • Uses a predictive parsing table
  • Requires FIRST and FOLLOW sets
  • Input is parsed using a stack and table lookup

2. FIRST and FOLLOW Sets

  • 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

3. Operator Precedence Parsing

  • Handles expressions like i+i*i
  • Uses precedence relations (<, >, =) to decide when to shift or reduce
  • Employs a precedence table for terminals

4. LEADING and TRAILING Sets

  • 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

📌 Notes

  • Expressions use i as 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)

🧪 Example Inputs

  • 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

👨‍💻 Author

Anuj Gupta
B.Tech CSE (Full Stack AI), UPES


📝 License

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.

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages