public function visitToken(Token $token)
 {
     $this->parser->getTracker()->visitToken($token);
     // visit all rules
     $this->commentsFormatter->visitToken($token);
     $this->indentationFormatter->visitToken($token);
     $this->newlineFormatter->visitToken($token);
     $this->whitespaceFormatter->visitToken($token);
     $this->blanksFormatter->visitToken($token);
     $this->defaultFormatter->visitToken($token);
 }
 public function testTokenizer()
 {
     $parser = new Parser();
     $parser->parse($this->getRawContent('sample1'));
     $tokens = $parser->getTokens();
     $tracker = $parser->getTracker();
     $firstIf = $tokens->get(1);
     $firstIfOpen = $tokens->get(2);
     $this->assertEquals('if', $firstIf->contents);
     $this->assertEquals('(', $firstIfOpen->contents);
     $tracker->visitToken($firstIfOpen);
     $this->assertEquals($firstIf, $tracker->getPrevToken());
     $tracker->visitToken($firstIf);
     $this->assertEquals($firstIfOpen, $tracker->getNextToken());
 }
Esempio n. 3
0
 private function finish(Token $token)
 {
     if ($this->parser->getTracker()->isLastToken($token)) {
         $this->dumpCurrentUnit();
     }
 }
Esempio n. 4
0
 public function visitToken(Token $token)
 {
     $this->nextToken = $this->parser->getTracker()->getNextToken();
     $this->prevToken = $this->parser->getTracker()->getPrevToken();
     $this->doVisitToken($token);
 }