| [reply] |
Are there any books/Resources
On my bookshelf: "Higher Order Perl" by Mark Jason Dominus has several chapters of interest. "Advanced Perl Programming" by Simon Cozens has a chapter on Parsing Techniques. | [reply] |
Since Perl is an excellent language for parsing data of almost any kind, has any body used it for more intense purposes like writing compilers and interpreters. I am not speaking of languages like Forth, but rather more serious production scale compilers for languages like Java, Scala etc
While Perl is good at parsing, it is not really terribly well suited for compiler writing, which really requires a completely different set of features. Languages like Haskell and ML are really nice and easy to write compilers/interpreters in, and in general if I were to write a compiler I would opt for a strongly typed language like Haskell, ML, Java, etc. instead of a dynamic language like Perl.
Are there any books/Resources which show how one can develop Compilers and Interpreters using Perl?
Well, there is an online book about writing a Schema interpreter in Perl and I have a mostly complete Scheme-ish Lambda Calculus interpreter on github. There is also a Javascript Interpreter on CPAN which (according the README) is alpha quality but works. If you search for "Interpreter" or "Language" on CPAN a dozen or so other ones come up for languages such as Piet, Befunge, Prolog and a subset of OCaml called MiniCaml, to name a few.
| [reply] |
Perhaps you might also want to look at my new parser generator, Marpa. Marpa is based on recent improvements to Earley's algorithm and is a general parser generator. It will parse from any grammar that you can write as BNF, without restriction. It handles ambiguity, left-recursion, right-recursion, you name it.
Speeds seem quite acceptable in practical instances. I've written an HTML parser based on Marpa, Marpa::HTML, which is also on CPAN. That distribution contains an HTML pretty-printing utility, which I find useful in my own work.
General BNF parsing has been neglected over the recent past and, despite signs it can be quite practical, has not resulted in any tools in widespread use. I hope Marpa will make BNF useable in the same way that regular expressions are now.
| [reply] |
| [reply] |