Help improve program for parsing simple rules

pruebauno at latinmail.com pruebauno at latinmail.com
Mon Apr 20 16:40:03 CEST 2009


On Apr 17, 5:32 pm, Paul McGuire <pt... at austin.rr.com> wrote:
> On Apr 17, 2:40 pm, prueba... at latinmail.com wrote:
>
>
>
> > On Apr 17, 11:26 am, Paul McGuire <pt... at austin.rr.com> wrote:
>
> > > On Apr 16, 10:57 am, prueba... at latinmail.com wrote:
>
> > > > Another interesting task for those that are looking for some
> > > > interesting problem:
> > > > I inherited some rule system that checks for programmers program
> > > > outputs that to be ported: given some simple rules and the values it
> > > > has to determine if the program is still working correctly and give
> > > > the details of what the values are. If you have a better idea of how
> > > > to do this kind of parsing please chime in. I am using tokenize but
> > > > that might be more complex than it needs to be. This is what I have
> > > > come up so far:
>
> > > I've been meaning to expand on pyparsing's simpleArith.py example for
> > > a while, to include the evaluation of the parsed tokens.  Here is the
> > > online version,http://pyparsing.wikispaces.com/file/view/eval_arith.py,
> > > it will be included in version 1.5.2 (coming shortly).  I took the
> > > liberty of including your rule set as a list of embedded test cases.
>
> > > -- Paul
>
> > That is fine with me. I don't know how feasible it is for me to use
> > pyparsing for this project considering I don't have admin access on
> > the box that is eventually going to run this. To add insult to injury
> > Python is in the version 2->3 transition (I really would like to push
> > the admins to install 3.1 by the end of the year before the amount of
> > code written by us gets any bigger) meaning that any third party
> > library is an additional burden on the future upgrade. I can't
> > remember if pyparsing is pure Python. If it is I might be able to
> > include it alongside my code if it is not too big.- Hide quoted text -
>
> > - Show quoted text -
>
> It *is* pure Python, and consists of a single source file for the very
> purpose of ease-of-inclusion.  A number of projects include their own
> versions of pyparsing for version compatibility management, matplotlib
> is one that comes to mind.
>
> The upcoming version 1.5.2 download includes a pyparsing_py3.py file
> for Python 3 compatibility, I should have that ready for users to
> download *VERY SOON NOW*!
>
> -- Paul

Thanks,
I will consider it. I have to admit that although it looks like it is
a very good solution, it is also longer and more complex than my
current code. Having to explicitly define standard python evaluation
and semantics is a bit overkill.



More information about the Python-list mailing list