[CentralOH] Custom Compilers

William McVey wam at cisco.com
Tue Oct 26 20:38:26 CEST 2010

On Tue, 2010-10-26 at 13:38 -0400, James - Atlantix wrote:
> I think it possible to build customer parser/generators (or
> declarative compilers, as I call them) with Python . . 

Sure, there are lots of parser tools available for Python. Many of the
tools are listed at: http://wiki.python.org/moin/LanguageParsing 

I have used PyParsing (http://pyparsing.wikispaces.com/) on several
projects and like it a lot. If I needed to parse a grammar that went
beyond the capabilities of pyparsing, I'd probably reach for ANTLR
(http://www.antlr.org/), which supports python as a target language.

> Python's ease of object orientation and structure is a bit better for
> that, although regex handling in Perl is still a "bit" more powerful
> in some cases . . . but I haven't written a line of Perl code in 3.5
> years now since using Python . . . 

Simple regexs (which python handles just fine) might be suitable for
building a tokenizer with, but if you start getting into the corner
cases of regexs that perl might outshine python in, then you're likely
going to have serious issues with your parse grammar when one of your
complex regexs gets stuck in a catastrophic backtrace or over/under

  -- William 

More information about the CentralOH mailing list