[Python-ideas] New pattern-matching library

M.-A. Lemburg mal at egenix.com
Wed Mar 2 00:21:38 CET 2011


Greg Ewing wrote:
> Guido van Rossum wrote:
> 
>> It's been tried before without much success. I think it may have been
>> a decade ago that Ka-Ping Yee created a pattern matching library that
>> used function calls ... It didn't get much use.
> 
> That may largely be due to marketing issues. A potential
> user would have to know that Ka-Ping's module existed, or
> be sufficiently dissatisfied with the status quo to go
> looking for something like it. Probably it has never even
> occurred to many people familiar with REs from other contexts
> that there might be another way.

If someone wants to experiment with these things, I suggest
you use mxTextTools' tagging engine as basis:

    http://www.egenix.com/products/python/mxBase/mxTextTools/

It provides a really fast matching machine which can be
programmed from Python using simple tuples.

There are already a few libraries that use it as basis for
e.g. grammar-based parsing.

It's flexible enough for many different kinds of parsing
approaches, can parse a lot more than what you can do
with REs and would also allow creating toy-language
implementations that implement parsing in ways different
than REs.

We've used it to parse HTML (including broken HTML), XML,
custom macro languages similar to the Excel VBA macros,
RTF, various templating languages, etc.

The BioPython project uses it to parse genome data.

-- 
Marc-Andre Lemburg
eGenix.com

Professional Python Services directly from the Source  (#1, Mar 02 2011)
>>> Python/Zope Consulting and Support ...        http://www.egenix.com/
>>> mxODBC.Zope.Database.Adapter ...             http://zope.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ...        http://python.egenix.com/
________________________________________________________________________

::: Try our new mxODBC.Connect Python Database Interface for free ! ::::


   eGenix.com Software, Skills and Services GmbH  Pastor-Loeh-Str.48
    D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
           Registered at Amtsgericht Duesseldorf: HRB 46611
               http://www.egenix.com/company/contact/



More information about the Python-ideas mailing list