Beispiel #1
0
        while (count($op_stack) > 0) {
            $num_stack[] = Evaluator::eval_op_stack($op_stack, $num_stack, $back_track_pos);
        }
        return array_pop($num_stack);
    }
    # Currently only support single expression with no preceddence ,no boolean expression
    #    [expression] =  [optional binary] ? operant [ optional compare operant]
    #    [operant] = variable|string|numeric|boolean
    #    [compare] = > | < | == | >= | <=
    #    [binary]    = not | !
    static function exec($args, $context)
    {
        return Evaluator::eval_expression($args, $context);
    }
}
Evaluator::$op_precedence = array('(' => -1, 'not' => 0, 'or_' => 0, 'and_' => 0, 'eq' => 1, 'gt' => 1, 'lt' => 1, 'ge' => 1, 'le' => 1, 'mod' => 2, 'plus' => 3, 'minus' => 3, 'mul' => 4, 'div' => 4);
/**
 * $type of token, Block | Variable
 */
class H2o_Token
{
    function __construct($type, $content, $position)
    {
        $this->type = $type;
        $this->content = $content;
        $this->result = '';
        $this->position = $position;
    }
    function write($content)
    {
        $this->result = $content;