professional-php-17-rpn.php / php
<?php require_once 'FSM.php'; function BeginBuildNumber(payload) { array_push(symbol); } function BuildNumber(payload) { payload); n . payload, symbol, n = array_pop(payload, (int)symbol, ar = array_pop(al = array_pop(symbol == '+') { array_push(al + symbol == '-') { array_push(al - symbol == '*') { array_push(al * symbol == '/') { array_push(al / symbol, payload) . "\n"; } function Error(payload) { echo "This does not compute: stack = array(); stack); fsm->addTransitionAny('INIT', 'INIT'); fsm->addTransitions(range(0,9), 'INIT', 'BUILDING_NUMBER', 'BeginBuildNumber'); fsm->addTransition(' ', 'BUILDING_NUMBER', 'INIT', 'EndBuildNumber'); stdin = fopen('php://stdin', 'r'); stdin)); //', expression, -1, PREG_SPLIT_NO_EMPTY); symbols);
(C) Æliens 20/2/2008
You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.