protected function syntaxError($expectedDesc, $actualToken = null)
    {
        if (null === $actualToken) {
            $actualToken = $this->lexer->next;
        }
        if (null === $actualToken) {
            $actualDesc = 'end of input';
        } else if ($actualToken[1] === 0) {
            $actualDesc = sprintf('"%s" of type %s at beginning of input', $actualToken[0], $this->lexer->getName($actualToken[2]));
        } else {
            $actualDesc = sprintf('"%s" of type %s at position %d (0-based)', $actualToken[0], $this->lexer->getName($actualToken[2]), $actualToken[1]);
        }

        $ex = new SyntaxErrorException(sprintf('Expected %s, but got %s%s.', $expectedDesc, $actualDesc, $this->context ? ' '.$this->context : ''));
        if (null !== $actualToken) {
            $ex->setActualToken($actualToken);
        }
        if (null !== $this->context) {
            $ex->setContext($this->context);
        }

        throw $ex;
    }
protected function syntaxError($expectedDesc, $actualToken = null)
    {
        if (null === $actualToken) {
            $actualToken = $this->lexer->next;
        }
        if (null === $actualToken) {
            $actualDesc = 'end of input';
        } else if ($actualToken[1] === 0) {
            $actualDesc = sprintf('"%s" of type %s at beginning of input', $actualToken[0], $this->lexer->getName($actualToken[2]));
        } else {
            $actualDesc = sprintf('"%s" of type %s at position %d (0-based)', $actualToken[0], $this->lexer->getName($actualToken[2]), $actualToken[1]);
        }

        $ex = new SyntaxErrorException(sprintf('Expected %s, but got %s%s.', $expectedDesc, $actualDesc, $this->context ? ' '.$this->context : ''));
        if (null !== $actualToken) {
            $ex->setActualToken($actualToken);
        }
        if (null !== $this->context) {
            $ex->setContext($this->context);
        }

        throw $ex;
    }
protected function syntaxError ( $ expectedDesc , $ actualToken = null ) { if ( null === $ actualToken ) { $ actualToken = $ this -> lexer -> next ; } if ( null === $ actualToken ) { $ actualDesc = 'end of input' ; } else if ( $ actualToken [ 1 ] === 0 ) { $ actualDesc = sprintf ( '"%s" of type %s at beginning of input' , $ actualToken [ 0 ] , $ this -> lexer -> getName ( $ actualToken [ 2 ] ) ) ; } else { $ actualDesc = sprintf ( '"%s" of type %s at position %d (0-based)' , $ actualToken [ 0 ] , $ this -> lexer -> getName ( $ actualToken [ 2 ] ) , $ actualToken [ 1 ] ) ; } $ ex = new SyntaxErrorException ( sprintf ( 'Expected %s, but got %s%s.' , $ expectedDesc , $ actualDesc , $ this -> context ? ' ' . $ this -> context : '' ) ) ; if ( null !== $ actualToken ) { $ ex -> setActualToken ( $ actualToken ) ; } if ( null !== $ this -> context ) { $ ex -> setContext ( $ this -> context ) ; } throw $ ex ; }
Raises a syntax error exception.

@param string $expectedDesc A human understandable explanation what was expected
@param array $actualToken The token that was found. If not given, next token will be assumed.
Raises a syntax error exception .