Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

build a syntax tree

0 views
Skip to first unread message

Federico

unread,
Dec 18, 2007, 5:43:37 PM12/18/07
to
Hi I've some trivial question:

for exercise I want to parse a string that like this:

"x -34 + 65 * 96 = 102"

now if I had this ("(25+24)/2") is extremely easy to have a result but
I want to resolve the above string (for the 'x' variable) what can I
do?

Especially for symbolic function I think that I've to build an
'operations tree' with a variable table.
I want to know how Derive parse this kind of string.

If I've to build a tree, please give me resources and/or examples of
what physically is a tree and how to build on python.

Thanks :)

Arnaud Delobelle

unread,
Dec 19, 2007, 2:18:01 AM12/19/07
to

You can use a parser generator to build the syntax tree that you want.
See http://wiki.python.org/moin/LanguageParsing for a list.

Perhaps pyparsing is a good one to start with?
http://pyparsing.wikispaces.com/

HTH

--
Arnaud

0 new messages