예제 #1
0
파일: Parser.php 프로젝트: creof/wkt-parser
 /**
  * Match token at current position in input
  *
  * @param $token
  */
 protected function match($token)
 {
     $lookaheadType = $this->lexer->lookahead['type'];
     if ($lookaheadType !== $token && ($token !== Lexer::T_TYPE || $lookaheadType <= Lexer::T_TYPE)) {
         throw $this->syntaxError($this->lexer->getLiteral($token));
     }
     $this->lexer->moveNext();
 }
예제 #2
0
 public function testTokenRecognitionReuseLexer()
 {
     $lexer = new Lexer();
     foreach ($this->tokenData() as $name => $testData) {
         $lexer->setInput($testData['value']);
         foreach ($testData['expected'] as $token) {
             $lexer->moveNext();
             $actual = $lexer->lookahead;
             $this->assertEquals($token[0], $actual['type']);
             $this->assertEquals($token[1], $actual['value']);
             $this->assertEquals($token[2], $actual['position']);
         }
     }
 }