Yuce's Blog

Cognitive dissonance is yoga for the brain.*

Infix to Postfix Converter Class in Marvin

2005-04-16

Here is an object oriented version of the infix to postfix converter written in Marvin:

# infixoop.mar | Converts an infix expression into postfix

# This implementation uses the object data as a hash-table
#    for operator precedence.

"listop forth dequeop" use

@@Infix
    @new  # define the hash-table for operator precedence
        FALSE ^++ ^+- ^-+ ^-- ^*+ ^*- ^** ^*/ ^/+ ^/- ^/* ://
        TRUE ^+* ^+/ ^-* :-/ me ;

    @|> & pushfrom ;

    @string dfront NONE 

marvin, infix, postfix