Home | Reviews | GUIpedia | Forum | Fun500


JasonInfix to RPN Expression Converter
'+-----------------------------------+ '| iNFiX TO RPN EXPRESSiON CONVERTER | '| --------------------------------- | '| ORiGiNAL AUTHOR: DiCK | '| MODiFiED BY: HORATiO | '| --------------------------------- | '| CREATED: 08APR12 | '| LAST MODiFiED: 10APR12 | '+-----------------------------------+ DEFINT A-Z DECLARE FUNCTION convert$ (expression$) DECLARE FUNCTION precedence% (operator$) DECLARE FUNCTION pop$ () DECLARE SUB push (value$) CONST stackMax% = 64 DIM SHARED stack$(stackMax%) DIM SHARED size% INPUT "", expression$ PRINT convert$(expression$) FUNCTION convert$ (expression$) FOR position% = 1 TO LEN(expression$) byte$ = MID$(expression$, position%, 1) flag% = 0 IF ASC(byte$) >= ASC("0") AND ASC(byte$) <= ASC("9") OR ASC(LCASE$(byte$)) >= ASC("a") AND ASC(LCASE$(byte$)) <= ASC("z") OR byte$ = "." THEN flag% = -1 output$ = output$ + byte$ END IF IF byte$ = CHR$(34) THEN flag% = -1 DO output$ = output$ + byte$ byte$ = MID$(expression$, position%, 1) position% = position% + 1 LOOP UNTIL byte$ = CHR$(34) END IF IF byte$ + MID$(expression$, position% + 1, 1) = "!=" THEN byte$ = "!=" position% = position + 1 END IF IF INSTR("<= >=", byte$ + MID$(expression$, position% + 1, 1)) THEN byte$ = byte$ + "=" position% = position% + 1 END IF IF byte$ = "!" THEN flag% = -1 output$ = output$ + ", 255, ^" END IF IF NOT flag% THEN SELECT CASE byte$ CASE "(" push byte$ CASE ")" DO byte$ = pop$ IF byte$ = "(" THEN EXIT DO output$ = output$ + byte$ LOOP CASE ELSE output$ = output$ + ", " o2$ = stack$(size%) IF precedence%(byte$) <= precedence%(o2$) THEN output$ = output$ + pop$ + ", " END IF push byte$ END SELECT END IF NEXT position% FOR element% = 1 TO size% output$ = output$ + ", " + pop$ NEXT element% convert$ = output$ END FUNCTION FUNCTION pop$ pop$ = stack$(size%) size% = size% - 1 END FUNCTION FUNCTION precedence% (operator$) SELECT CASE operator$ CASE "*", "/", "\" precedence% = 7 CASE "+", "-", "$" precedence% = 6 CASE "<", "<=", ">", ">=" precedence% = 5 CASE "=", "!=", "<>" precedence% = 4 CASE "&" precedence% = 3 CASE "|" precedence% = 2 CASE "^" precedence% = 1 END SELECT END FUNCTION SUB push (value$) size% = size% + 1 stack$(size%) = value$ END SUB
2012-04-092:08 PM

HorvatMRe:Infix to RPN Expression Converter
The box with the credits at the top makes it demoscene-like. But it could use some ASCII art. :D
2012-04-093:40 PM

JasonRe:Infix to RPN Expression Converter
i couldn't help myself.
2012-04-104:30 AM

Code


2021 Brandon Cornell


Fatal error: Uncaught Error: Call to a member function close() on null in /homepages/11/d157582457/htdocs/mblog/footer.php:20 Stack trace: #0 /homepages/11/d157582457/htdocs/mblog/forum.php(88): include() #1 {main} thrown in /homepages/11/d157582457/htdocs/mblog/footer.php on line 20