// THIS FILE IS GENERATED BY kdev-pg-qt 2.4.0
// WARNING! All changes made in this file will be lost!

#ifndef PHP_H_INCLUDED
#define PHP_H_INCLUDED

#include "phptokentype.h"
#include "phpast-fwd.h"
#include <kdev-pg-memory-pool.h>
#include <kdev-pg-allocator.h>
#include "parser/tokenstream.h"
#include "QtCore/QString"
#include "language/duchain/problem.h"
#include "parser/phplexer.h"

#include "parserexport.h"
namespace Php
{

class KDEVPHPPARSER_EXPORT Parser : public TokenTypeWrapper
{
public:
    typedef TokenStream::Token Token;
    TokenStream *tokenStream;
    int yytoken;

    inline Token LA(qint64 k = 1) const
    {
        qint64 idx = tokenStream->index() - 1 + k - 1;
        qint64 oldidx = tokenStream->index();
        tokenStream->rewind(tokenStream->size());
        while(idx >= tokenStream->size()) tokenStream->read();
        tokenStream->rewind(oldidx);
        return tokenStream->at(idx);
    }
    inline int yylex()
    {
        yytoken = tokenStream->read().kind;
        return yytoken;
    }
    inline void rewind(qint64 index)
    {
        tokenStream->rewind(index);
        yylex();
    }

// token stream
    void setTokenStream(TokenStream *s)
    {
        tokenStream = s;
    }

// error handling
    void expectedSymbol(int kind, const QString& name);
    void expectedToken(int kind, qint64 token, const QString& name);

    bool mBlockErrors;
    inline bool blockErrors(bool block)
    {
        bool previous = mBlockErrors;
        mBlockErrors = block;
        return previous;
    }

// memory pool
    typedef KDevPG::MemoryPool memoryPoolType;

    KDevPG::MemoryPool *memoryPool;
    void setMemoryPool(KDevPG::MemoryPool *p)
    {
        memoryPool = p;
    }
    template <class T>
    inline T *create()
    {
        T *node = new (memoryPool->allocate(sizeof(T))) T();
        node->kind = T::KIND;
        return node;
    }
    template <class T>
    inline T *create(AstNode *u)
    {
        T *node = new (memoryPool->allocate(sizeof(T))) T(u);
        node->kind = T::KIND;
        return node;
    }

// user defined declarations:
public:

# 150 "/build/kdevelop-php/src/kdev-php-26.08.0/parser/php.g" 1

    /**
     * Transform the raw input into tokens.
     * When this method returns, the parser's token stream has been filled
     * and any parse*() method can be called.
     */
    void tokenize(const QString& contents, int initialState = Lexer::HtmlState);

    enum ProblemType
    {
        Error,
        Warning,
        Info,
        Todo
    };
    KDevelop::ProblemPointer reportProblem( Parser::ProblemType type, const QString& message, int tokenOffset = -1 );
    QList<KDevelop::ProblemPointer> problems()
    {
        return m_problems;
    }
    QString tokenText(qint64 begin, qint64 end);
    void setDebug(bool debug);
    void setCurrentDocument(KDevelop::IndexedString url);
    void setTodoMarkers(const QStringList& markers);
    void extractTodosFromComment(const QString& comment, qint64 offset);

    enum InitialLexerState
    {
        HtmlState = 0,
        DefaultState = 1
    };

    enum ParserUseImportType
    {
        NamespaceOrClassImport,
        ConstantImport,
        FunctionImport
    };
    ParserUseImportType m_useImportType;
    ParserUseImportType m_useCompoundImportType;

private:

# 189 "/build/kdevelop-php/src/kdev-php-26.08.0/parser/php.g" 1

    enum VarExpressionState
    {
        Normal,
        OnlyVariable,
        OnlyNewObject
    };
    QString m_contents;
    bool m_debug;
    KDevelop::IndexedString m_currentDocument;
    QList<KDevelop::ProblemPointer> m_problems;

    struct ParserState
    {
        VarExpressionState varExpressionState;
        bool varExpressionIsVariable;
    };
    ParserState m_state;

    QRegularExpression m_todoMarkers;


public:
// The copyCurrentState() and restoreState() methods are only declared
// if you are using try blocks in your grammar, and have to be
// implemented by yourself, and you also have to define a
// "struct ParserState" inside a %parserclass directive.

// This method should create a new ParserState object and return it,
// or return 0 if no state variables need to be saved.
    ParserState *copyCurrentState();

// This method is only called for ParserState objects != 0
// and should restore the parser state given as argument.
    void restoreState(ParserState *state);
    Parser()
    {
        memoryPool = nullptr;
        tokenStream = nullptr;
        yytoken = Token_EOF;
        mBlockErrors = false;

// user defined constructor code:

# 210 "/build/kdevelop-php/src/kdev-php-26.08.0/parser/php.g" 1

        m_state.varExpressionState = Normal;
        m_state.varExpressionIsVariable = false;

    }

    virtual ~Parser() {}

    bool parseAdditiveExpression(AdditiveExpressionAst **yynode);
    bool parseAdditiveExpressionRest(AdditiveExpressionRestAst **yynode);
    bool parseArrayIndexSpecifier(ArrayIndexSpecifierAst **yynode);
    bool parseArrayPairValue(ArrayPairValueAst **yynode);
    bool parseAssignmentExpression(AssignmentExpressionAst **yynode);
    bool parseAssignmentExpressionCheckIfVariable(AssignmentExpressionCheckIfVariableAst **yynode);
    bool parseAssignmentExpressionEqual(AssignmentExpressionEqualAst **yynode);
    bool parseAssignmentList(AssignmentListAst **yynode);
    bool parseAssignmentListElement(AssignmentListElementAst **yynode);
    bool parseBaseVariable(BaseVariableAst **yynode);
    bool parseBaseVariableWithFunctionCalls(BaseVariableWithFunctionCallsAst **yynode);
    bool parseBitAndExpression(BitAndExpressionAst **yynode);
    bool parseBitOrExpression(BitOrExpressionAst **yynode);
    bool parseBitXorExpression(BitXorExpressionAst **yynode);
    bool parseBooleanAndExpression(BooleanAndExpressionAst **yynode);
    bool parseBooleanOrExpression(BooleanOrExpressionAst **yynode);
    bool parseCaseList(CaseListAst **yynode);
    bool parseCase_item(Case_itemAst **yynode);
    bool parseCatchItem(CatchItemAst **yynode);
    bool parseClassBody(ClassBodyAst **yynode);
    bool parseClassConstant(ClassConstantAst **yynode);
    bool parseClassConstantDeclaration(ClassConstantDeclarationAst **yynode);
    bool parseClassDeclarationStatement(ClassDeclarationStatementAst **yynode);
    bool parseClassExtends(ClassExtendsAst **yynode);
    bool parseClassImplements(ClassImplementsAst **yynode);
    bool parseClassName(ClassNameAst **yynode);
    bool parseClassNameReference(ClassNameReferenceAst **yynode);
    bool parseClassProperty(ClassPropertyAst **yynode);
    bool parseClassStatement(ClassStatementAst **yynode);
    bool parseClassVariable(ClassVariableAst **yynode);
    bool parseClassVariableDeclaration(ClassVariableDeclarationAst **yynode);
    bool parseClosure(ClosureAst **yynode);
    bool parseCommonScalar(CommonScalarAst **yynode);
    bool parseCompoundNamespace(CompoundNamespaceAst **yynode);
    bool parseCompoundNamespaceStatement(CompoundNamespaceStatementAst **yynode);
    bool parseCompoundVariable(CompoundVariableAst **yynode);
    bool parseCompoundVariableWithSimpleIndirectReference(CompoundVariableWithSimpleIndirectReferenceAst **yynode);
    bool parseConditionalExpression(ConditionalExpressionAst **yynode);
    bool parseConstantDeclaration(ConstantDeclarationAst **yynode);
    bool parseConstantOrClassConst(ConstantOrClassConstAst **yynode);
    bool parseCtorArguments(CtorArgumentsAst **yynode);
    bool parseDeclareItem(DeclareItemAst **yynode);
    bool parseDeclareStatement(DeclareStatementAst **yynode);
    bool parseDimListItem(DimListItemAst **yynode);
    bool parseElseSingle(ElseSingleAst **yynode);
    bool parseElseifList(ElseifListAst **yynode);
    bool parseElseifListItem(ElseifListItemAst **yynode);
    bool parseEncaps(EncapsAst **yynode);
    bool parseEncapsList(EncapsListAst **yynode);
    bool parseEncapsVar(EncapsVarAst **yynode);
    bool parseEncapsVarOffset(EncapsVarOffsetAst **yynode);
    bool parseEqualityExpression(EqualityExpressionAst **yynode);
    bool parseEqualityExpressionRest(EqualityExpressionRestAst **yynode);
    bool parseExpr(ExprAst **yynode);
    bool parseForExpr(ForExprAst **yynode);
    bool parseForStatement(ForStatementAst **yynode);
    bool parseForeachStatement(ForeachStatementAst **yynode);
    bool parseForeachVariable(ForeachVariableAst **yynode);
    bool parseFunctionCall(FunctionCallAst **yynode);
    bool parseFunctionCallParameterList(FunctionCallParameterListAst **yynode);
    bool parseFunctionCallParameterListElement(FunctionCallParameterListElementAst **yynode);
    bool parseFunctionDeclarationStatement(FunctionDeclarationStatementAst **yynode);
    bool parseGenericTypeHint(GenericTypeHintAst **yynode);
    bool parseGlobalVar(GlobalVarAst **yynode);
    bool parseIdentifier(IdentifierAst **yynode);
    bool parseIifeSyntax(IifeSyntaxAst **yynode);
    bool parseInnerStatementList(InnerStatementListAst **yynode);
    bool parseInnerUseNamespace(InnerUseNamespaceAst **yynode);
    bool parseInstantiationAccess(InstantiationAccessAst **yynode);
    bool parseInterfaceDeclarationStatement(InterfaceDeclarationStatementAst **yynode);
    bool parseLexicalVar(LexicalVarAst **yynode);
    bool parseLexicalVarList(LexicalVarListAst **yynode);
    bool parseLogicalAndExpression(LogicalAndExpressionAst **yynode);
    bool parseLogicalOrExpression(LogicalOrExpressionAst **yynode);
    bool parseLogicalXorExpression(LogicalXorExpressionAst **yynode);
    bool parseMethodBody(MethodBodyAst **yynode);
    bool parseMultiplicativeExpression(MultiplicativeExpressionAst **yynode);
    bool parseMultiplicativeExpressionRest(MultiplicativeExpressionRestAst **yynode);
    bool parseNamespaceDeclarationStatement(NamespaceDeclarationStatementAst **yynode);
    bool parseNamespacedIdentifier(NamespacedIdentifierAst **yynode);
    bool parseNamespacedIdentifierBeforeGroupedNamespace(NamespacedIdentifierBeforeGroupedNamespaceAst **yynode);
    bool parseNewElseSingle(NewElseSingleAst **yynode);
    bool parseNewElseifList(NewElseifListAst **yynode);
    bool parseNewelseifListItem(NewelseifListItemAst **yynode);
    bool parseNullCoalesceExpression(NullCoalesceExpressionAst **yynode);
    bool parseObjectDimList(ObjectDimListAst **yynode);
    bool parseObjectOperator(ObjectOperatorAst **yynode);
    bool parseObjectProperty(ObjectPropertyAst **yynode);
    bool parseOptionalClassModifier(OptionalClassModifierAst **yynode);
    bool parseOptionalModifiers(OptionalModifiersAst **yynode);
    bool parseOuterTopStatement(OuterTopStatementAst **yynode);
    bool parseParameter(ParameterAst **yynode);
    bool parseParameterList(ParameterListAst **yynode);
    bool parseParameterType(ParameterTypeAst **yynode);
    bool parseParameterTypeHint(ParameterTypeHintAst **yynode);
    bool parsePostprefixOperator(PostprefixOperatorAst **yynode);
    bool parsePrintExpression(PrintExpressionAst **yynode);
    bool parsePropertyType(PropertyTypeAst **yynode);
    bool parsePropertyTypeHint(PropertyTypeHintAst **yynode);
    bool parseRelationalExpression(RelationalExpressionAst **yynode);
    bool parseRelationalExpressionRest(RelationalExpressionRestAst **yynode);
    bool parseReservedNonModifierIdentifier(ReservedNonModifierIdentifierAst **yynode);
    bool parseReservedNonModifiers(ReservedNonModifiersAst **yynode);
    bool parseReturnType(ReturnTypeAst **yynode);
    bool parseReturnTypeHint(ReturnTypeHintAst **yynode);
    bool parseScalar(ScalarAst **yynode);
    bool parseSemiReserved(SemiReservedAst **yynode);
    bool parseSemiReservedIdentifier(SemiReservedIdentifierAst **yynode);
    bool parseSemicolonOrCloseTag(SemicolonOrCloseTagAst **yynode);
    bool parseShiftExpression(ShiftExpressionAst **yynode);
    bool parseShiftExpressionRest(ShiftExpressionRestAst **yynode);
    bool parseStart(StartAst **yynode);
    bool parseStatement(StatementAst **yynode);
    bool parseStaticArrayPairValue(StaticArrayPairValueAst **yynode);
    bool parseStaticMember(StaticMemberAst **yynode);
    bool parseStaticProperty(StaticPropertyAst **yynode);
    bool parseStaticScalar(StaticScalarAst **yynode);
    bool parseStaticVar(StaticVarAst **yynode);
    bool parseStringIndexSpecifier(StringIndexSpecifierAst **yynode);
    bool parseSwitchCaseList(SwitchCaseListAst **yynode);
    bool parseTopStatement(TopStatementAst **yynode);
    bool parseTraitAliasDeclaration(TraitAliasDeclarationAst **yynode);
    bool parseTraitAliasIdentifier(TraitAliasIdentifierAst **yynode);
    bool parseTraitAliasStatement(TraitAliasStatementAst **yynode);
    bool parseTraitDeclarationStatement(TraitDeclarationStatementAst **yynode);
    bool parseTraitVisibilityModifiers(TraitVisibilityModifiersAst **yynode);
    bool parseUnaryExpression(UnaryExpressionAst **yynode);
    bool parseUnaryExpressionNotPlusminus(UnaryExpressionNotPlusminusAst **yynode);
    bool parseUnionParameterType(UnionParameterTypeAst **yynode);
    bool parseUnionPropertyType(UnionPropertyTypeAst **yynode);
    bool parseUnionReturnType(UnionReturnTypeAst **yynode);
    bool parseUseNamespaceOrUseGroupedNamespace(UseNamespaceOrUseGroupedNamespaceAst **yynode);
    bool parseUseStatement(UseStatementAst **yynode);
    bool parseVarExpression(VarExpressionAst **yynode);
    bool parseVarExpressionArray(VarExpressionArrayAst **yynode);
    bool parseVarExpressionNewObject(VarExpressionNewObjectAst **yynode);
    bool parseVarExpressionNormal(VarExpressionNormalAst **yynode);
    bool parseVariable(VariableAst **yynode);
    bool parseVariableIdentifier(VariableIdentifierAst **yynode);
    bool parseVariableName(VariableNameAst **yynode);
    bool parseVariableObjectProperty(VariableObjectPropertyAst **yynode);
    bool parseVariableProperty(VariablePropertyAst **yynode);
    bool parseVariableWithoutObjects(VariableWithoutObjectsAst **yynode);
    bool parseWhileStatement(WhileStatementAst **yynode);
};

} // end of namespace Php

#endif

