TIP: Click on subject to list as thread! ANSI
echo: os2prog
to: Erik Huelsmann
from: Mario Semo
date: 1996-05-15 08:33:08
subject: Converting infix to postfix

Hello Erik,

On May 10 11:19 96, Erik Huelsmann of 2:500/19.1929 wrote:

 EH> I am looking for some routine that (helps me or does 
 EH> itself) converts infix-math-expressions to 
 EH> postfix-math-expressions.

a) The Art of Computer Programming. (Knuth). Part1 ? 

(Fundamental Algorithms). Page 336 talsk about preOrder, postOrder
presentation of formulas extracted from the binary tree presentation of the
formula. 

b) you have to parse the expression and build a parse tree and use
postorder traversal methods.

 EH> X*(X'*X)^(-1)*X'*y

 EH> X X ' X * -1 ^ X * y *

to parse such expressions, i would use an LEX/YACC tool. I don't know if
such a tool is available for Pascal. (the lexx/yacc i can write such a
parser/scanner in a few lines of code).

But of course you can implement the parser for yourself. if you don't know
how to write an lexical parser for an LR1 grammatic, i would suggest a book
about compiler construction. 


 WARPED!, Mario

--- Msgedsq/2 2.2e
* Origin: LC/32 Development Team-Vienna-Austria (2:310/14.11)
SEEN-BY: 50/99 270/101 620/243 711/401 409 410 413 430 808 809 934 955
SEEN-BY: 712/407 515 517 628 713/888 800/1
@PATH: 310/14 1 24/999 888 396/1 270/101 712/515 711/808 934

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.