Exemple #1
0
 protected function buildIdentifierToken(Token $token, Character $char)
 {
     $token->setType(TokenType::IDENTIFIER);
     do {
         $value = $token->getValue();
         $token->setValue($value . $char->getValue());
         try {
             $char = $this->getCharacter();
         } catch (EofException $e) {
             throw new SyntaxException($char->getLine(), $char->getColumn() - mb_strlen($token->getValue()) + 1, "Found EOF reading identifier: '{$token->getValue()}'", __FILE__, __LINE__);
         }
     } while ($char->isAlnum() || $char->getValue() == '_' || $char->getValue() == '.');
     $this->ungetCharacter();
     if (mb_substr($token->getValue(), 0, 1) == '.' || mb_substr($token->getValue(), mb_strlen($token->getValue()) - 1, 1) == '.') {
         throw new SyntaxException($char->getLine(), $char->getColumn(), 'Identifier can start or end with a dot "' . $token->getValue() . '"', __FILE__, __LINE__);
     }
     $this->debug(__METHOD__, __LINE__, 'Found IDENTIFIER: "' . $token->getValue() . '"');
     if ($token->contains('.')) {
         // Must be a function call
         if (!$this->getExtensionManager()->resolve($token->getValue())) {
             throw new SyntaxException($char->getLine(), $char->getColumn(), 'Function not found "' . $token->getValue() . '"', __FILE__, __LINE__);
         }
         $this->debug(__METHOD__, __LINE__, 'IDENTIFIER is a method invocation');
         $token->setType(TokenType::MINVOKE);
         return $token;
     }
     if ($this->isLanguageKeyword($token->getValue())) {
         $this->debug(__METHOD__, __LINE__, 'IDENTIFIER is a language keyword');
         $token->setType(TokenType::KEYWORD);
     }
     return $token;
 }