当前位置: 首页>>代码示例>>PHP>>正文


PHP Token::getColumn方法代码示例

本文整理汇总了PHP中Token::getColumn方法的典型用法代码示例。如果您正苦于以下问题:PHP Token::getColumn方法的具体用法?PHP Token::getColumn怎么用?PHP Token::getColumn使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Token的用法示例。


在下文中一共展示了Token::getColumn方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getColumn

 /**
  * Returns the column in the source file the message refers to.
  * If this error message does not refer to a token (lint error),
  * the column number is 0.
  *
  * @returns integer
  */
 public function getColumn()
 {
     // Explicitly set column overrides token start column
     if ($this->column !== null) {
         return $this->column;
     }
     if (!$this->token instanceof Token) {
         return 0;
     }
     return $this->token->getColumn();
 }
开发者ID:spriebsch,项目名称:phpca,代码行数:18,代码来源:Message.php

示例2: testGetColumnReturnsRealValueWhenWhitespaceTokenHasNoLeadingNewLine

 /**
  * @covers spriebsch\PHPca\Token::__construct
  * @covers spriebsch\PHPca\Token::getColumn
  */
 public function testGetColumnReturnsRealValueWhenWhitespaceTokenHasNoLeadingNewLine()
 {
     $t = new Token(T_WHITESPACE, " ", 3, 7);
     $this->assertEquals(7, $t->getColumn());
 }
开发者ID:spriebsch,项目名称:phpca,代码行数:9,代码来源:TokenTest.php

示例3: procAssignment

 protected function procAssignment(Token $token)
 {
     $this->debug(__METHOD__, __LINE__, "identifier: {$token->getValue()}");
     // Validate the leftside
     if ($token->getType() != TokenType::IDENTIFIER) {
         throw new SyntaxException($token->getLine(), $token->getColumn() - mb_strlen($token->getValue()) + 1, "Invalid assignment identifier: '{$token->getValue()}'", __FILE__, __LINE__);
     }
     $name = $token->getValue();
     $token = $this->getToken();
     // Validate the operator
     switch ($token->getType()) {
         case TokenType::SYMBOL:
             switch ($token->getValue()) {
                 case ';':
                     if (!$this->memory->hasVar($name)) {
                         throw new SyntaxException($token->getLine(), $token->getColumn() - mb_strlen($name) + 1, "Unknown identifier: '{$name}'", __FILE__, __LINE__);
                     }
                     // Do nothing :\
                     return;
                     break;
                 case '=':
                     // allow =
                     break;
                 case '++':
                 case '--':
                     // allow ++ and --
                     break;
                 default:
                     throw new SyntaxException($token->getLine(), $token->getColumn() - mb_strlen($token->getValue()) + 1, "Invalid assignment operator: '{$token->getValue()}'", __FILE__, __LINE__);
             }
             break;
         default:
             throw new SyntaxException($token->getLine(), $token->getColumn() - mb_strlen($token->getValue()) + 1, "Invalid assignment operator: '{$token->getValue()}'", __FILE__, __LINE__);
     }
     $operator = $token->getValue();
     // Evaluate the rightside
     $type = $this->evalExp($value);
     // Perform action
     switch ($operator) {
         case '=':
             $this->memory->setVar($name, $value, $type);
             break;
         case '++':
             // number only
         // number only
         case '--':
             if (!$this->memory->hasVar($name)) {
                 throw new SyntaxException($token->getLine(), $token->getColumn(), "Unknown identifier: '{$name}'", __FILE__, __LINE__);
             }
             $value = $this->memory->getVar($name);
             if ($operator == '++') {
                 $newval = intval($value + 1);
             } else {
                 $newval = intval($value - 1);
             }
             $this->memory->setVar($name, $newval, $type);
             break;
         default:
             throw new SyntaxException($token->getLine(), $token->getColumn() - mb_strlen($operator) + 1, "Unknown operator: '{$operator}'", __FILE__, __LINE__);
             break;
     }
 }
开发者ID:g4z,项目名称:poop,代码行数:62,代码来源:Parser.php

示例4: buildNumberToken

 protected function buildNumberToken(Token $token, Character $char)
 {
     $token->setType(TokenType::INTEGER);
     $buffer = '';
     do {
         $buffer .= $char->getValue();
         try {
             $char = $this->getCharacter();
         } catch (EofException $e) {
             throw new SyntaxException($char->getLine(), $char->getColumn() - mb_strlen($buffer) + 1, "Found EOF reading number: '{$buffer}'", __FILE__, __LINE__);
         }
     } while ($char->isNumber() || $char->getValue() == '.');
     $this->ungetCharacter();
     // If number contains a period, is a FLOAT
     if (mb_strpos($buffer, '.') !== FALSE) {
         $token->setType(TokenType::FLOAT);
         // If period is not followed by numbers
         if (mb_substr($buffer, -1) == '.') {
             throw new SyntaxException($token->getLine(), $token->getColumn(), "Invalid FLOAT value: '{$buffer}'", __FILE__, __LINE__);
         }
     }
     switch ($token->getType()) {
         case TokenType::FLOAT:
             $token->setValue(floatval($buffer));
             break;
         case TokenType::INTEGER:
             $token->setValue(intval($buffer));
             break;
         default:
             throw new SyntaxException($char->getLine(), $char->getColumn(), 'Unknown number token type: "' . $buffer . '"', __FILE__, __LINE__);
             break;
     }
     return $token;
 }
开发者ID:g4z,项目名称:poop,代码行数:34,代码来源:Lexer.php


注:本文中的Token::getColumn方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。