flex: plex?

Peter Kleiweg in.aqua.scribis at nl.invalid
Tue Aug 17 16:22:57 EDT 2004


Hi,

I am looking for a Python equivalent of Flex. After some
browsing, it seems that Plex is my best bet, but I would like to
hear suggestions before I dive in.

I have been using Flex a lot in combination with C programming.
I never use Yacc (or Bison), though Flex and Yacc are supposed
to be used together. But I found Yacc too cumbersome, and
unnecessary. Yacc is about context-free grammars, nice if you
like to describe an input language as a set of context-free
rewrite rules. Flex is about finite-state automata, but can be
extended to push-down automata (equivalent to context-free
grammars) and beyond, as long as it stays deterministic. I found
this to be very productive. I prefer automata over rewrite rules.

So, what I am looking for is a Python version of Flex that
supports the following capabilities, which are also supported by Plex:

- assigning any Python code to a matched input pattern

- input pattern recognition depending on 'states', which can be
  changed through actions

Things that seems to be missing from Plex:

- patterns like:
   A/B : match A only if followed by B, give A as result, keep B
         in the input stream

- actions like:
   REJECT: ask the flexer to come up with the next best match for the
           same input
   LESS(n): push n characters back into the input stream

All these are not really necessary, but they make some things
simpler.

So, are there any other packages that do these things better
than Plex?

-- 
Peter Kleiweg  L:NL,af,da,de,en,ia,nds,no,sv,(fr,it)  S:NL,de,en,(da,ia)
info: http://www.let.rug.nl/~kleiweg/ls.html




More information about the Python-list mailing list