How do I build a LR state machine parser?
-
08-07-2019 - |
Question
I'm wanting to play around with creating an LR parser generators. Does anyone know of a good (free) resource describing how to create a state machine table from a grammar?
Solution
For a free resource, consider the Python source code for PLY - a full implementation of Lex and Yacc in Python.
I would recommend a book, however, and you can hardly do better than get The Dragon Book.
OTHER TIPS
The best resource I have come across is:
The obvious answer is the standard compiler text by Aho/Ullman/Ravi, Compilers: Principles, Techniques, and Tools
It has complete chapters on parsing. It isn't free, but it is worth every last penny, and if you are going to build parsers or other compiler-like tools, you are simply crazy if you don't have this book.
Maybe you find Grammatica useful. It's a free Parser generator for .NET. I have some experience with it and it was good. You can try it and study its code. http://grammatica.percederberg.net/