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.
- Read grammar from
grammar.txt
- Left factoring transformation
- Left recursion elimination
- Compute FIRST and FOLLOW sets
- Construct and display LL(1) parsing table
./
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
Using the provided Makefile (Linux/macOS with make, or Windows with make in MinGW/MSYS):
make
This produces the parser
executable.
make run
The program reads grammar.txt
, applies transformations, prints FIRST/FOLLOW sets, and the LL(1) table.
make clean # POSIX
make cleanW # Windows
utils.c
writes a space-stripped copy of the grammar tooutput.txt
during processing.- Update
grammar.txt
to experiment with different grammars. - Compilation flags:
-g -w
(debugging enabled, warnings suppressed in Makefile).