#ifndef BUILDER_H #define BUILDER_H #include #include #include #include #include #include "build.tab.h" #include "parser.h" class Build; class BuildParser; class Function; class FunctionFactory; class Perform; class PerformFactory; class Target; class TargetFactory; #define YY_DECL int yylex( YYSTYPE *yylval_param, YYLTYPE *yylloc_param, BuildParser &bld ) YY_DECL; typedef std::list StringList; typedef std::list FunctionList; typedef std::list PerformList; typedef std::map VarMap; template class Triplet { public: Triplet( const tx &x, const ty &y, const tz &z ) : first( x ), second( y ), third( z ) {} Triplet( const Triplet &src ) : first( src.first ), second( src.second ), third( src.third ) {} tx first; ty second; tz third; }; enum eSetHow { setSet, setAdd }; class BuildParser : public Parser { typedef std::pair BuildListItem; typedef std::list BuildListCore; typedef std::pair BuildList; typedef Triplet SetVar; typedef std::list SetVarList; public: BuildParser(); virtual ~BuildParser(); Build *load( const std::string &sFile ); private: void scanBegin(); void scanEnd(); Build *genBuild(); public: // Target functions bool isTarget( const char *sType ); void newTarget(); void setTargetRule( const char *sRule ); void setTargetPrefix( const char *sPrefix ); void setTargetType( const char *sType ); void addTargetInput(); void addTargetRequires(); void addTargetSet( const char *sVar, const char *sVal, int nHow ); void addTargetGroup( const char *sGroup ); private: // Target variables TargetFactory &fTarget; class TargetInfo { public: std::string sRule; std::string sPrefix; std::string sType; BuildList lInput; BuildList lRequires; StringList lGroups; SetVarList lVar; }; typedef std::pair TargetTmp; typedef std::list TargetTmpList; TargetTmpList lTargetTmp; public: // Function functions bool isFunction( const char *sFunc ); void newFunctionCall( const char *sName ); void addFunctionParam( const char *sParam ); private: // Function variables Function *pTmpFunc; FunctionFactory &fFunction; public: // Perform functions bool isPerform( const char *sPerf ); void newPerform( const char *sName ); void addPerformParam( const char *sParam ); private: // Perform variables Perform *pTmpPerform; PerformFactory &fPerform; public: // List functions void newList(); void addListString( const char *str ); void addListFunc(); void filterList(); void buildListFilter( BuildList &lSrc ); StringList buildToStringList( const BuildList &lSrc, const StringList &lIn, Build *pPass=NULL ); StringList buildToStringListDup( const BuildList &lSrc, const StringList &lIn, Build &bld, const std::string &sCont, VarMap *mExtra, Build *pPass=NULL ); private: // List variables BuildList lTmp; public: // Rules functions void addRule( const char *sName ); void addRuleMatches(); void addRuleProduces(); void addRuleRequires(); void addRuleInputFilter(); void addRulePerform(); void setRuleAggregate(); private: // Rule variables class RuleInfo { public: std::string sName; Function *pMatches; BuildList lProduces; BuildList lRequires; FunctionList lFilter; PerformList lPerform; Function *pAggregate; }; typedef std::list RuleTmpList; RuleTmpList lRuleTmp; public: // Action functions void addAction(); void addAction( const char *sName ); void addCommand( int nType ); private: // Action variables typedef std::pair ActionTmpCmd; typedef std::list ActionTmpCmdList; typedef std::pair ActionTmp; typedef std::list ActionTmpList; ActionTmpList lActions; public: // Global variable functions void addGlobalSet( const char *sVar, const char *sValue, int nHow ); private: // Global variable variables SetVarList lGlobalVars; public: // Debug void debugDump(); void printBuildList( const BuildList &lst ); }; #endif