Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > build a syntax tree

Reply
Thread Tools

build a syntax tree

 
 
Federico
Guest
Posts: n/a
 
      12-18-2007
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
 
Reply With Quote
 
 
 
 
Arnaud Delobelle
Guest
Posts: n/a
 
      12-19-2007
On Dec 18, 10:43 pm, Federico <federico.bertola....@gmail.com> wrote:
> 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


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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
B+ Tree versus Ternary Search Tree Ramkumar Menon Java 2 08-16-2005 08:13 PM
B+ Tree versus Ternary Search Tree Ramkumar Menon Java 0 08-16-2005 09:01 AM
SWsoft Acronis Disk Director Suite 9.0 Build 508, Acronis OS Selector 8.0 Build 917, Acronis Partition Expert 2003 Build 292, Acronis Power Utilities 2004 Build 502, F-SECURE.ANTI vIRUS.PROXY v1.10.17.WINALL, F-SECURE.ANTI vIRUS v5.50.10260 for CITRI vvcd Computer Support 0 09-25-2004 01:38 AM
B tree, B+ tree and B* tree Stub C Programming 3 11-12-2003 01:51 PM
Spanning Tree And Per Vlan Spanning Tree Amy L. Cisco 0 07-24-2003 10:01 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57