{ 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');
<?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/>";
public function __construct($String) { parent::__construct($String); }