Skip to content

C-based toolkit for context-free grammars: reads a grammar, performs left factoring and left recursion removal, computes FIRST/FOLLOW sets, and builds/prints an LL(1) parsing table. Includes sample grammars, Makefile, and a PowerShell build script for Windows.

License

Notifications You must be signed in to change notification settings

Umer-Farooq-CS/LL1-Parser-Toolkit

Repository files navigation

LL(1) Grammar Tools (Left Factoring, Left Recursion, FIRST/FOLLOW, Table)

C project that reads a context-free grammar, performs left factoring and left recursion removal, computes FIRST and FOLLOW sets, and builds an LL(1) parsing table. Includes sample grammars and a Makefile.

Features

  • Read grammar from grammar.txt
  • Left factoring transformation
  • Left recursion elimination
  • Compute FIRST and FOLLOW sets
  • Construct and display LL(1) parsing table

Project Structure

./
  grammar.txt         # Primary sample grammar
  grammar2.txt        # Additional samples
  grammar3.txt
  leftFactoring.c/.h
  leftRecursion.c/.h
  LL1Parser.c/.h
  utils.c/.h          # Shared data structures and helpers
  main.c              # Entry point
  Makefile            # Build and run targets
  README.md

Build

Using the provided Makefile (Linux/macOS with make, or Windows with make in MinGW/MSYS):

make

This produces the parser executable.

Run

make run

The program reads grammar.txt, applies transformations, prints FIRST/FOLLOW sets, and the LL(1) table.

Clean

make clean   # POSIX
make cleanW  # Windows

Notes

  • utils.c writes a space-stripped copy of the grammar to output.txt during processing.
  • Update grammar.txt to experiment with different grammars.
  • Compilation flags: -g -w (debugging enabled, warnings suppressed in Makefile).

About

C-based toolkit for context-free grammars: reads a grammar, performs left factoring and left recursion removal, computes FIRST/FOLLOW sets, and builds/prints an LL(1) parsing table. Includes sample grammars, Makefile, and a PowerShell build script for Windows.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published