Reputation: 2387
I was wondering if somebody could suggest projects that implement simple lexers and parsers (without the help of tools like lex and yacc) for me to look at the source. I'm interested in the subject, and before I would like to see and study how they can be implemented manually.
Upvotes: 1
Views: 363
Reputation: 1511
The Dragon book is very good on this. Its a very in depth look at the entire compiler technology. This includes a large section on parsing and parse trees.
http://en.wikipedia.org/wiki/Compilers:_Principles,_Techniques,_and_Tools
Upvotes: 1
Reputation: 5538
If you want to see a code for handwritten parsers then I suggest looking for gcc and various xml parsers. You can start reading from here about gcc architecture. Type "xml parser source code" in your favorite search engine and you will have plenty of examples of xml parsers. If you are more interested in learning how to write native parser libraries, which don't require extra step of code generation, you can look at boost::Spirit (C++) or AXE (C++0x). Also check this table for various projects, some of them offer source code, but you will need to do mining yourself.
Upvotes: 0
Reputation: 39
Go to antlr.org and read about how ANTLR works. Also The Definitive ANTLR Reference is definitely worth the money. Plus ANTLR has a large and very helpful user community. Yes ANTLR is a tool but you can look at the source. Developing your own lexers and parsers is probably not something you want to do in the long run but you will, of course, write your own grammars. The ANTLR v3 grammar is very nice to use.
Upvotes: 0