Esempio n. 1
0
 /**
  * Test the `addOperand` and `getOperandTable` accessors.
  */
 public function testOperandTableAccessors()
 {
     /* @var \PHPUnit_Framework_MockObject_MockObject $operand */
     $operand = $this->getMock('com\\mohiva\\pyramid\\Operand');
     $operand->expects($this->any())->method('getIdentifiers')->will($this->returnValue(array(1)));
     /* @var \com\mohiva\pyramid\Operand $operand */
     $token = new Token(1, 1, 1);
     $grammar = new Grammar();
     $grammar->addOperand($operand);
     $this->assertSame($operand, $grammar->getOperandTable()->getOperand($token));
 }
Esempio n. 2
0
 /**
  * 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();
 }