/** * Test the `addOperator` and `getOperatorTable` accessors. */ public function testOperatorTableAccessors() { $operator = new BinaryOperator(1, 1, BinaryOperator::LEFT, function () { }); $token = new Token($operator->getCode(), 1, 1); $grammar = new Grammar(); $grammar->addOperator($operator); $this->assertSame($operator, $grammar->getOperatorTable()->getBinaryOperator($token)); }
/** * The class constructor. * * @param Grammar $grammar The grammar used for this parser. */ public function __construct(Grammar $grammar) { $this->grammar = $grammar; $this->operatorTable = $this->grammar->getOperatorTable(); $this->operandTable = $this->grammar->getOperandTable(); }