コード例 #1
0
ファイル: OperandTable.php プロジェクト: mohiva/pyramid
 /**
  * Check if an operand is registered for the given token.
  *
  * @param Token $token The token to check for.
  * @return boolean True if a operand for the given token exists, false otherwise.
  */
 public function isRegistered(Token $token)
 {
     if (isset($this->operands[$token->getCode()])) {
         return true;
     }
     return false;
 }
コード例 #2
0
ファイル: TokenTest.php プロジェクト: mohiva/pyramid
 /**
  * Test all getters for the values set with the constructor.
  */
 public function testConstructorAccessors()
 {
     $code = mt_rand(1, 30);
     $value = sha1(microtime(true));
     $offset = mt_rand(1, 100);
     $token = new Token($code, $value, $offset);
     $this->assertSame($code, $token->getCode());
     $this->assertSame($value, $token->getValue());
     $this->assertSame($offset, $token->getOffset());
 }
コード例 #3
0
ファイル: OperatorTable.php プロジェクト: mohiva/pyramid
 /**
  * Gets an ternary operator from table.
  *
  * @param Token $token The token for which the operator should be returned.
  * @return operators\TernaryOperator The operator object for the given token.
  * @throws UnsupportedOperatorException if the operator doesn't exists in table.
  */
 public function getTernaryOperator(Token $token)
 {
     if (isset($this->ternary['if'][$token->getCode()])) {
         return $this->ternary['if'][$token->getCode()];
     } else {
         if (isset($this->ternary['else'][$token->getCode()])) {
             return $this->ternary['else'][$token->getCode()];
         }
     }
     throw new UnsupportedOperatorException("No ternary operator with code `{$token->getCode()}` exists in table");
 }