1 | <?php |
||
11 | class Interpreter |
||
12 | { |
||
13 | protected ?ParserInterface $parser; |
||
|
|||
14 | |||
15 | public function parse(string $inputString): CompileNode |
||
16 | { |
||
17 | return $this->parser->parse($inputString); |
||
18 | } |
||
19 | |||
20 | public function evaluate(string $inputString, Dictionary $context) |
||
21 | { |
||
22 | $node = $this->parser->parse($inputString); |
||
23 | $node->setContext($context); |
||
24 | |||
25 | return $node->evaluate(); |
||
26 | } |
||
27 | |||
28 | public function setParser(ParserInterface $parser): void |
||
29 | { |
||
30 | $this->parser = $parser; |
||
31 | } |
||
32 | } |
||
33 |