On 4/10/06, Talin <[EMAIL PROTECTED]> wrote:
> I have a rather odd use case for this. A while back, I decided I wanted to
> write an algebraic solver, similar to what Mathematica does, except that
> I wanted to write it in Python. Not just implement it in Python, but have
> Python be the language in which the rules of formula manipulation were
> expressed.
[...]
> You can immediately see the problem - since I don't have syntactical
> support, I have to manually enter in the expression in an AST-like form,
> which is clumsy to say the least.

I've seen other packages like this (for different solvers) that solved
this by overloading various operators to produce a parse tree. All you
need is some primitive objects named X, Y, Z etc. and then X**2+Y**2
produces the appropriate parse tree.  Then the analyzer can walk the
parse tree.

Anyway, I'm not sure I consider this a strong use case for needing
access to Python's AST; the language you need to parse is much smaller
than Python and a custom parser would probably do just as well.

--
--Guido van Rossum (home page: http://www.python.org/~guido/)
_______________________________________________
Python-3000 mailing list
Python-3000@python.org
http://mail.python.org/mailman/listinfo/python-3000
Unsubscribe: 
http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com

Reply via email to