News for hackers. Stuff that matters.
Re:The language of languages by stiff on Monday January 14, 2013 @04:43PM (#5056841)
If you want to learn to apply grammars and parsers in practice I recommend the antlr parser-generator:

http://www.antlr.org/

It can not only do the basic text->tree parsing from a file describing the grammar, but will also allow to specify additional grammars for traversing the generated tree and executing arbitrary code in your language of choice as particular nodes are recognized. I built a little compiler in it some years ago, I had a Xpl.g grammar file for parsing the program text and creating the abstract syntax tree, a SemanticAnalysis.g grammar file for doing a first pass through the tree, annotating it with additional information, filling the symbol table, checking semantic correctness and then finally CodeGeneration.g for emitting JVM bytecode using the annotated tree. The code for this is still on Github:

https://github.com/jaroslawr/xpl/tree/509120e66e23aac8493414...

There is a simpler example using the same functionalities described on the ANTLR wiki:

http://www.antlr.org/wiki/display/ANTLR3/Simple+tree-based+i...

I used the ANTLR reference book when learning it, but now there is also a real introductory manual:

http://pragprog.com/book/tpantlr2/the-definitive-antlr-4-ref... http://pragprog.com/book/tpdsl/language-implementation-patte...

I also used the Dragon Book and "Programming Language Pragmatics" for theory, both great books and PLP certainly deserves to be better known.

Re:The language of languages by Cyranix on Monday January 14, 2013 @07:21PM (#5057618)
Thanks for the additional information on antlr. I stumbled upon it last month when doing some prep work for long-term planning at my company. I immediately wished I could rip out most of the custom code my team had written for handling ARFF files (for Weka machine learning toolkit) and replace it with the antlr grammar file attached to the Weka wiki.