/** * Parse the operand. * * @return Node The node object for the operand. * @throws SyntaxErrorException if no operand parser can be found for * the current token. */ private function parseOperand() { /* @var Token $token */ $token = $this->stream->current(); try { /* @var Operand $operand */ $operand = $this->operandTable->getOperand($token); } catch (InvalidIdentifierException $e) { $message = "Cannot find operand parser for token `{$token->getValue()}`"; throw new SyntaxErrorException($message, 0, $e); } return $operand->parse($this->grammar, $this->stream); }
/** * Test if the `getOperand` method throws an exception if no operand for the given identifier exists. * * @expectedException \com\mohiva\pyramid\exceptions\InvalidIdentifierException */ public function testGetOperandThrowsException() { $token = new Token(1, 1, 1); $table = new OperandTable(); $table->getOperand($token); }