This is a parser generator I wrote when reading the book Modern Compiler Design in my spare time, while also learning Ruby.
There are two scripts:
- gen.rb generates a C program that parses an input array consisting of tokens. It doesn't process the input; it only verifies that it is grammatically intact.
- grammar.rb is the library. It has helpful functions, like Grammar.terminal? or Grammar.alternative_tails.
Please not that this probably has a lot of bugs. The are only a few tests.
But it's still fun.