Online Resources for Writing a Parser

I want to write a parser for educational purposes and wondered if there are any interesting online resources or tutorials that explain how to write it. Something in the lines of "Let Build the Compiler" by Jack Crenshaw.

I want to write a parser generator for LR (1) grammar.

I have a decent understanding of the theory of creating actions and goto tables, but I need some kind of resource that will help me in its implementation.

Preferred languages ​​are C / C ++, Java, although even other languages ​​are fine.

Thanks.

+6
parsing parser-generator lr
source share
4 answers

I agree with others; Dragon's book is a good background for parsing LR.

If you are interested in recursive descent partisans, an extremely interesting learning experience is this website, which will help you create a fully autonomous compiler system that can compile itself and other languages:

MetaII Compilation Tutorial

All of this is based on Val Schorre’s amazing little 10-page technical article: META II: The Language of Writing a Syntax-Oriented Language from Honest to 1964 God. I learned how to build compilers from this point in 1970. There is an instant moment when you finally look at how the compiler can self-repair ....

I know the author of the website in my college days, but have nothing to do with the website.

+8
source share

If you want to go through the python route, I would recommend the following.

I found both of them to be very useful, and Paul McGuire, the author of pyparsing, really helps you deal with problems. The Python Text Processing book is just a handy link to have your fingers on the hints and helps you in the right mood when trying to build a parser.

I would also like to point out that OO is better suited as a mechanism for parsing the language, since it is extensible and polymorphism is the right way to do this (IMHO). Looking at the problem from the point of view of the state machine, rather than “Finding a semicolon at the end of xyz,” will demonstrate that your parser becomes much more reliable at the end.

Hope this helps!

+2
source share

Not really online, but the Dragon Book contains some pretty detailed discussions on how to parse LR.

+1
source share

It was easier for me to learn how to write recursive partisans before learning how to write LR parsers. Honestly, after many years of writing parsers, I never found it necessary to write an LR parser.

I recently wrote a tutorial in CodeProject called Implementing a Programming Language Tool in C # 4.0 , which describes methods for analyzing recursive descent.

0
source share

All Articles