Ejemplo n.º 1
0
{
    protected function doInterpret(InterpreterContext $context, $result_l, $result_r)
    {
        $context->replace($this, $result_l || $result_r);
    }
}
class BooleanAndExpression extends OperatorExpression
{
    protected function doInterpret(InterpreterContext $context, $result_l, $result_r)
    {
        $context->replace($this, $result_l && $result_r);
    }
}
$n = "<br />";
$context = new InterpreterContext();
$literal = new LiteralExpression('Четыре');
$literal->interpret($context);
print $context->lookup($literal) . $n;
$context = new InterpreterContext();
$myvar = new VariableExpression('input', 'Четыре');
$myvar->interpret($context);
print $context->lookup($myvar) . $n;
$newvar = new VariableExpression('input');
$newvar->interpret($context);
print $context->lookup($myvar) . $n;
$myvar->setValue('Пять');
$myvar->interpret($context);
print $context->lookup($myvar) . $n;
print $context->lookup($newvar) . $n;
$context = new InterpreterContext();
$input = new VariableExpression('input');
Ejemplo n.º 2
0
<?php

$context = new InterpreterContext();
$myvar = new VariableExpression("input", "four");
$myvar->interpret($context);
echo $context->lookup($myvar) . "<br/>";
$new_var = new VariableExpression("input");
$new_var->interpret($context);
echo $context->lookup($new_var) . "<br/>";
$myvar->setValue("five");
$myvar->interpret($context);
echo $context->lookup($myvar) . "<br/>";
echo $context->lookup($new_var) . "<br/>";
$literal = new LiteralExpression("Four");
$literal->interpret($context);
echo $context->lookup($literal) . "<br/>";
Ejemplo n.º 3
0
 public function __construct($String)
 {
     parent::__construct($String);
 }