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

#ifndef QMAKE_H_INCLUDED
#define QMAKE_H_INCLUDED

#include "qmaketokentype.h"
#include "qmakeast-fwd.h"
#include <kdev-pg-memory-pool.h>
#include <kdev-pg-allocator.h>
#include <kdev-pg-token-stream.h>
#include "QtCore/QString"

namespace QMake
{

class  Parser : public TokenTypeWrapper
{
public:
    typedef KDevPG::TokenStream::Token Token;
    KDevPG::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(KDevPG::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:

#line 32 "/build/kdevelop/src/kdevelop-26.07.90/plugins/qmakemanager/parser/qmake.g"

    /**
     * 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 );

    enum ProblemType
    {
        Error,
        Warning,
        Info
    };
    void reportProblem( Parser::ProblemType type, const QString& message );

    QString tokenText(qint64 begin, qint64 end) const;

    void setDebug( bool debug );


private:

#line 54 "/build/kdevelop/src/kdevelop-26.07.90/plugins/qmakemanager/parser/qmake.g"

    QString m_contents;
    bool m_debug;


public:
    Parser()
    {
        memoryPool = nullptr;
        tokenStream = nullptr;
        yytoken = Token_EOF;
        mBlockErrors = false;
    }

    virtual ~Parser() {}

    bool parseArgumentList(ArgumentListAst **yynode);
    bool parseElseBody(ElseBodyAst **yynode);
    bool parseFunctionArguments(FunctionArgumentsAst **yynode);
    bool parseIfElse(IfElseAst **yynode);
    bool parseItem(ItemAst **yynode);
    bool parseOp(OpAst **yynode);
    bool parseOrOperator(OrOperatorAst **yynode);
    bool parseProject(ProjectAst **yynode);
    bool parseScope(ScopeAst **yynode);
    bool parseScopeBody(ScopeBodyAst **yynode);
    bool parseStatement(StatementAst **yynode);
    bool parseValue(ValueAst **yynode);
    bool parseValueList(ValueListAst **yynode);
    bool parseVariableAssignment(VariableAssignmentAst **yynode);
};

} // end of namespace QMake

#endif

