Exemplo n.º 1
0
 public function testIsAlphaNum()
 {
     foreach ($this->nums as $c) {
         $this->assertTrue(ScannerHelper::isAlphaNum($c), $c);
     }
     foreach ($this->lowAlpha as $c) {
         $this->assertTrue(ScannerHelper::isAlphaNum($c), $c);
     }
     foreach ($this->upAlpha as $c) {
         $this->assertTrue(ScannerHelper::isAlphaNum($c), $c);
     }
     foreach ($this->ops as $c) {
         $this->assertFalse(ScannerHelper::isAlphaNum($c), $c);
     }
     foreach ($this->ws as $c) {
         $this->assertFalse(ScannerHelper::isAlphaNum($c), $c);
     }
 }
Exemplo n.º 2
0
 /**
  * Scans an identifier [a-zA-Z\-_].
  *
  * @return Token
  */
 private function scannIdentifier()
 {
     $pos = $this->createPosition();
     $str = $this->currentCharacter();
     while ($this->hasNextCharacter()) {
         $this->nextCharacter();
         if (ScannerHelper::isAlphaNum($this->currentCharacter()) || ScannerHelper::isEquals($this->currentCharacter(), array("-", "_"))) {
             $str .= $this->currentCharacter();
         } else {
             $this->backupCharacter();
             break;
         }
     }
     return new Token(Token::IDENTIFIER, $str, $pos);
 }