public function readToken(): Token
    {
        if ($this->getBuffer()->isEnd()) {
            try {
                $token = $this
                    ->getScanner()
                    ->readToken();
            } catch (UnknownSyntaxException $e) {
                throw new UnknownSyntaxException(
                    "Unknown syntax error near position #{$this->getNextPosition()}",
                    $this->getNextPosition(),
                    $e
                );
            }
            $this->assertErrorToken($token);
            $this
                ->getBuffer()
                ->addToken($token);
        }
        return $this
            ->getBuffer()
            ->readToken();
    }
public function readToken(): Token
    {
        if ($this->getBuffer()->isEnd()) {
            try {
                $token = $this
                    ->getScanner()
                    ->readToken();
            } catch (UnknownSyntaxException $e) {
                throw new UnknownSyntaxException(
                    "Unknown syntax error near position #{$this->getNextPosition()}",
                    $this->getNextPosition(),
                    $e
                );
            }
            $this->assertErrorToken($token);
            $this
                ->getBuffer()
                ->addToken($token);
        }
        return $this
            ->getBuffer()
            ->readToken();
    }
public function readToken ( ) : Token { if ( $ this -> getBuffer ( ) -> isEnd ( ) ) { try { $ token = $ this -> getScanner ( ) -> readToken ( ) ; } catch ( UnknownSyntaxException $ e ) { throw new UnknownSyntaxException ( "Unknown syntax error near position #{$this->getNextPosition()}" , $ this -> getNextPosition ( ) , $ e ) ; } $ this -> assertErrorToken ( $ token ) ; $ this -> getBuffer ( ) -> addToken ( $ token ) ; } return $ this -> getBuffer ( ) -> readToken ( ) ; }
Reads next token from buffer.

@return Token
@throws UnknownSyntaxException
Reads next token from buffer .