Parse mathematic expression to tree then RPN

Yoong Hor Meng <yhm@pacific.net.sg>
12 Feb 2003 13:40:48 -0500

          From comp.compilers

Related articles
Parse mathematic expression to tree then RPN yhm@pacific.net.sg (Yoong Hor Meng) (2003-02-12)
| List of all articles for this month |

From: Yoong Hor Meng <yhm@pacific.net.sg>
Newsgroups: comp.compilers
Date: 12 Feb 2003 13:40:48 -0500
Organization: Subscriber of Pacific Internet
Keywords: parse, question
Posted-Date: 12 Feb 2003 13:40:47 EST

Hi:


    I am hand writing a library to parse mathematic expression
such as


    Z = sin(A + B) + 33 * tan(C) + sqrt(D)


Converting this expression to tree would take a lots of backtracking
and consideration. Once it is stored in tree, using deep-first
travesal, RPN expression can be created very easily.


Could someone provides me information or resources to convert the
expression to tree format?


Thank you very much
Hor Meng
[Parsing an expression is the first example in just about every
compiler text. You can use a simple operator precedence parser
to parse it with no backtracking and to create RPN in one pass. -John]



Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.