13#ifndef TTA_OPERATION_DAG_LANGUAGE_PARSER 
   14#define TTA_OPERATION_DAG_LANGUAGE_PARSER 
   68#include <boost/version.hpp> 
   73#if BOOST_VERSION >= 103800 
   75#define PHOENIX_LIMIT 10 
   77#include <boost/spirit/include/classic.hpp> 
   78#include <boost/spirit/include/classic_utility.hpp> 
   79#include <boost/spirit/include/classic_symbols.hpp> 
   80#include <boost/spirit/include/classic_assign_actor.hpp> 
   81#include <boost/spirit/include/classic_assign_key_actor.hpp> 
   82#include <boost/spirit/include/classic_clear_actor.hpp> 
   83#include <boost/spirit/include/classic_decrement_actor.hpp> 
   84#include <boost/spirit/include/classic_erase_actor.hpp>  
   85#include <boost/spirit/include/classic_increment_actor.hpp> 
   86#include <boost/spirit/include/classic_insert_key_actor.hpp> 
   87#include <boost/spirit/include/classic_insert_at_actor.hpp> 
   88#include <boost/spirit/include/classic_push_back_actor.hpp> 
   89#include <boost/spirit/include/classic_push_front_actor.hpp> 
   90#include <boost/spirit/include/classic_swap_actor.hpp> 
   92using namespace boost::spirit::classic;
 
   96#include <boost/spirit/core.hpp> 
   97#include <boost/spirit/utility.hpp> 
   98#include <boost/spirit/symbols.hpp> 
   99#include <boost/spirit/actor/assign_actor.hpp> 
  100#include <boost/spirit/actor/assign_key_actor.hpp> 
  101#include <boost/spirit/actor/clear_actor.hpp> 
  102#include <boost/spirit/actor/decrement_actor.hpp> 
  103#include <boost/spirit/actor/erase_actor.hpp>  
  104#include <boost/spirit/actor/increment_actor.hpp> 
  105#include <boost/spirit/actor/insert_key_actor.hpp> 
  106#include <boost/spirit/actor/insert_at_actor.hpp> 
  107#include <boost/spirit/actor/push_back_actor.hpp> 
  108#include <boost/spirit/actor/push_front_actor.hpp> 
  109#include <boost/spirit/actor/swap_actor.hpp> 
  111using namespace boost::spirit;
 
  122#if ((__GNUC__ == 3) && (__GNUC_MINOR__ == 1 || __GNUC_MINOR__ == 2) \ 
  123    && defined(_WINNT_H)) 
  130#  define CHAR CHAR_RULE 
  131#  define CONST CONST_RULE 
  132#  define FLOAT FLOAT_RULE 
  134#  define VOID VOID_RULE 
  139using namespace boost::spirit;
 
  277        case POINTER: 
return "POINTER:";
 
  297        default: 
return "UNKNOWN_ID:";
 
 
  306        Token(
unsigned long start, 
unsigned long end, std::string& strValue) : 
 
 
  336                assert(
false && 
"Node is not integer literal.");
 
 
 
  463                assert(
false && 
"Node is not integer.");
 
 
  525            static int recursioLevel = 0;
 
  528            std::stringstream retVal;            
 
  531                retVal << 
"Root node" << std::endl;
 
  534                       << setw(5) << std::left << 
data_->
end_ << std::right 
 
  538                for (
int fill = 0; fill < (recursioLevel-2)*2; fill++) {
 
 
  565            for (std::vector<TokenTreeNode*>::iterator i = 
 
  566                     currNode->
leafs_.begin() ;    
 
  567                 i != currNode->
leafs_.end();i++) {
 
  584                    std::vector<TokenTreeNode*>::iterator temp = i;
 
  586                    currNode->
leafs_.erase(temp);
 
  589                    newToken->
leafs_.push_back(currLeaf);
 
  595                    currNode->
leafs_.insert(i, newToken);
 
  602            currNode->
leafs_.push_back(newToken);
 
 
 
  639        unsigned long startPos, endPos;
 
  643            endPos = end - start;
 
  649                reinterpret_cast<unsigned long>(start) + 
 
  650                reinterpret_cast<unsigned long>(
 
  654                reinterpret_cast<unsigned long>(end) + 
 
  655                reinterpret_cast<unsigned long>(
 
  661        std::pair<const char*, const char*> 
 
  662            tokenKey(end, (
const char*)(-
reinterpret_cast<unsigned long>(start)));
 
 
  680            std::cerr << std::hex 
 
  681                      << std::setw(4) << i->second->start_
 
  683                      << std::setw(4) << i->second->end_ 
 
  686                      << std::setw(30) << 
idString(i->second->type_) 
 
  689                      << i->second->strValue_
 
 
 
  724        std::string temp(start,end);
 
 
 
  743    thePair_ = std::pair<const char*, const char*>(start, end);
 
 
 
  753   template <
typename ScannerT>
 
  759     (str_p(
"//") >> *(anychar_p - 
'\n') >> ch_p(
'\n'))
 
  764     (
"/*" >> *(anychar_p - 
"*/") >> 
"*/")
 
 
  778     rule<ScannerT> 
const&
 
 
 
  788    public grammar<OperationDAGLanguageGrammar>
 
  790    template <
typename ScannerT>
 
  812                "auto", 
"break", 
"case", 
"char", 
"const", 
"continue", 
 
  813                "default", 
"do", 
"double", 
"else", 
"enum", 
"extern", 
 
  814                "float", 
"for", 
"goto", 
"if", 
"int", 
"long", 
"register", 
 
  815                "return", 
"short", 
"signed", 
"sizeof", 
"static", 
"struct", 
 
  816                "switch", 
"typedef", 
"union", 
"unsigned", 
"void", 
 
  830            AUTO =       strlit<>(
"auto");
 
  831            BREAK =      strlit<>(
"break");
 
  832            CASE =       strlit<>(
"case");
 
  833            CHAR =       strlit<>(
"char");
 
  834            CONST =      strlit<>(
"const");
 
  838            DOUBLE =     strlit<>(
"double");
 
  839            ELSE =       strlit<>(
"else");
 
  840            ENUM =       strlit<>(
"enum");
 
  841            EXTERN =     strlit<>(
"extern");
 
  842            FOR =        strlit<>(
"for");
 
  843            FLOAT =      strlit<>(
"float");
 
  844            GOTO =       strlit<>(
"goto");
 
  846            INT =        strlit<>(
"int");
 
  847            LONG =       strlit<>(
"long");
 
  849            RETURN =     strlit<>(
"return");
 
  850            SHORT =      strlit<>(
"short");
 
  851            SIGNED =     strlit<>(
"signed");
 
  852            SIZEOF =     strlit<>(
"sizeof");
 
  853            STATIC =     strlit<>(
"static");
 
  854            STRUCT =     strlit<>(
"struct");
 
  855            SWITCH =     strlit<>(
"switch");
 
  857            UNION =      strlit<>(
"union");
 
  859            VOID =       strlit<>(
"void");
 
  861            WHILE =      strlit<>(
"while");
 
  866                    ((alpha_p | 
'_' | 
'$') >> *(alnum_p | 
'_' | 
'$'))
 
  867                    - (
keywords >> (anychar_p - (alnum_p | 
'_' | 
'$')))
 
  877                    !chlit<>(
'L') >> chlit<>(
'\"') >>
 
  878                    *( strlit<>(
"\\\"") | ( anychar_p - chlit<>(
'\"') )) >>
 
  893                    as_lower_d[chlit<>(
'x')] >> 
 
  895                    !as_lower_d[chlit<>(
'l') | chlit<>(
'u')]
 
  902                    >> +range<>(
'0', 
'7')
 
  903                    >> !as_lower_d[chlit<>(
'l') | chlit<>(
'u')]
 
  910                    >> !as_lower_d[chlit<>(
'l') | chlit<>(
'u')]
 
  916                    !chlit<>(
'L') >> chlit<>(
'\'') >>
 
  921                                >> repeat_p(0, 2)[range<>(
'0', 
'7')]
 
  923                        |   (chlit<>(
'\\') >> anychar_p)
 
  942                    >> (chlit<>(
'e') | chlit<>(
'E'))
 
  943                    >> !(chlit<>(
'+') | chlit<>(
'-'))
 
  945                    >> !as_lower_d[chlit<>(
'l') | chlit<>(
'f')]
 
  954                    >> !((chlit<>(
'e') | chlit<>(
'E'))
 
  955                         >> !(chlit<>(
'+') | chlit<>(
'-'))
 
  958                    >> !as_lower_d[chlit<>(
'l') | chlit<>(
'f')]
 
  967                    >> !((chlit<>(
'e') | chlit<>(
'E'))
 
  968                         >> !(chlit<>(
'+') | chlit<>(
'-'))
 
  971                    >> !as_lower_d[chlit<>(
'l') | chlit<>(
'f')]
 
  988            BOOST_SPIRIT_DEBUG_RULE(
AUTO);
 
  989            BOOST_SPIRIT_DEBUG_RULE(
BREAK);
 
  990            BOOST_SPIRIT_DEBUG_RULE(
CASE);
 
  991            BOOST_SPIRIT_DEBUG_RULE(
CHAR);
 
  992            BOOST_SPIRIT_DEBUG_RULE(
CONST);
 
  994            BOOST_SPIRIT_DEBUG_RULE(
DEFAULT);
 
  995            BOOST_SPIRIT_DEBUG_RULE(
DO);
 
  996            BOOST_SPIRIT_DEBUG_RULE(
DOUBLE);
 
  997            BOOST_SPIRIT_DEBUG_RULE(
ELSE);
 
  998            BOOST_SPIRIT_DEBUG_RULE(
ENUM);
 
  999            BOOST_SPIRIT_DEBUG_RULE(
EXTERN);
 
 1000            BOOST_SPIRIT_DEBUG_RULE(
FOR);
 
 1001            BOOST_SPIRIT_DEBUG_RULE(
FLOAT);
 
 1002            BOOST_SPIRIT_DEBUG_RULE(
GOTO);
 
 1003            BOOST_SPIRIT_DEBUG_RULE(
IF);
 
 1004            BOOST_SPIRIT_DEBUG_RULE(
INT);
 
 1005            BOOST_SPIRIT_DEBUG_RULE(
LONG);
 
 1007            BOOST_SPIRIT_DEBUG_RULE(
RETURN);
 
 1008            BOOST_SPIRIT_DEBUG_RULE(
SHORT);
 
 1009            BOOST_SPIRIT_DEBUG_RULE(
SIGNED);
 
 1010            BOOST_SPIRIT_DEBUG_RULE(
SIZEOF);
 
 1011            BOOST_SPIRIT_DEBUG_RULE(
STATIC);
 
 1012            BOOST_SPIRIT_DEBUG_RULE(
STRUCT);
 
 1013            BOOST_SPIRIT_DEBUG_RULE(
SWITCH);
 
 1014            BOOST_SPIRIT_DEBUG_RULE(
TYPEDEF);
 
 1015            BOOST_SPIRIT_DEBUG_RULE(
UNION);
 
 1017            BOOST_SPIRIT_DEBUG_RULE(
VOID);
 
 1019            BOOST_SPIRIT_DEBUG_RULE(
WHILE);
 
 1087            BOOST_SPIRIT_DEBUG_RULE(
pointer);
 
 1531                 | str_p(
"FloatWord")
 
 1532                 | str_p(
"DoubleWord")
 
 
 1868                ELSE, 
ENUM, 
EXTERN, 
FOR, 
FLOAT, 
GOTO, 
IF, 
INT, 
LONG, 
REGISTER,
 
 1912        rule<ScannerT> 
const&
 
 
 
#define assert(condition)
 
#define IGNORE_COMPILER_WARNING(X)
 
#define POP_COMPILER_DIAGS
 
#define IGNORE_CLANG_WARNING(X)
 
find Finds info of the inner loops in the false
 
static SLongWord toLong(const T &source)
 
bool isAssignment() const
 
TokenTreeNode(Token &token)
 
std::vector< TokenTreeNode * > leafs_
Leafs of this node.
 
bool isFunctionCall() const
 
Token * data_
Token of token tree node.
 
const Token & token() const
 
TokenTreeNode & leaf(int index) const
 
void addToTokenTree(Token &token)
 
static void addToTokenTree(TokenTreeNode *currNode, TokenTreeNode *newToken)
 
std::string toStr() const
 
bool isTildeOperator() const
 
void setProperty(OperationID id)
 
bool isUnaryExpression() const
 
bool isBangOperator() const
 
bool isIntegerLiteral() const
 
bool isStringLiteral() const
 
bool isMinusOperator() const
 
bool isAddrofOperator() const
 
bool isIdentifier() const
 
bool isAsteriskOperator() const
 
std::string stringValue() const
 
bool isPostfixExpression() const
 
Token(unsigned long start, unsigned long end, std::string &strValue)
 
bool isFloatLiteral() const
 
bool isPlusOperator() const
 
std::map< std::pair< const char *, const char * >, Token * > TokenContainerType
 
TokenContainerType parsedTokens_
 
static std::string idString(OperationID id)
 
void showTokenizedSource()
 
const TokenTreeNode * tokenTree() const
 
void addToken(const char *start, const char *end, OperationID id, std::string strVal)
 
@ DIRECT_ABSTRACT_DECLARATOR
 
@ MULTIPLICATIVE_EXPRESSION
 
@ STORAGE_CLASS_SPECIFIER
 
@ STRUCT_OR_UNION_SPECIFIER
 
rule< ScannerT > postfix_expression
 
rule< ScannerT > statement
 
rule< ScannerT > declaration_specifiers
 
rule< ScannerT > STRING_LITERAL
 
rule< ScannerT > statement_list
 
rule< ScannerT > struct_declaration
 
rule< ScannerT > assignment_expression
 
rule< ScannerT > jump_statement
 
rule< ScannerT > selection_statement
 
rule< ScannerT > and_expression_helper
 
rule< ScannerT > FLOAT_CONSTANT_1
 
rule< ScannerT > init_declarator_list
 
rule< ScannerT > logical_and_expression
 
rule< ScannerT > direct_declarator
 
rule< ScannerT > parameter_type_list
 
rule< ScannerT > exclusive_or_expression_helper
 
rule< ScannerT > init_declarator
 
rule< ScannerT > storage_class_specifier
 
rule< ScannerT > declaration_list
 
rule< ScannerT > RIGHT_BRACKET
 
rule< ScannerT > REGISTER
 
rule< ScannerT > IDENTIFIER
 
rule< ScannerT > initializer_list
 
rule< ScannerT > multiplicative_expression_helper
 
rule< ScannerT > type_specifier
 
rule< ScannerT > VOLATILE
 
rule< ScannerT > enum_specifier
 
rule< ScannerT > primary_expression
 
rule< ScannerT > constant_expression
 
rule< ScannerT > multiplicative_expression
 
rule< ScannerT > additive_expression
 
rule< ScannerT > logical_or_expression
 
rule< ScannerT > CONTINUE
 
rule< ScannerT > FLOAT_CONSTANT
 
rule< ScannerT > expression
 
rule< ScannerT > iteration_statement
 
rule< ScannerT > logical_or_expression_helper
 
rule< ScannerT > and_expression
 
rule< ScannerT > specifier_qualifier_list
 
rule< ScannerT > identifier_list
 
rule< ScannerT > struct_or_union_specifier
 
rule< ScannerT > postfix_expression_helper
 
rule< ScannerT > INT_CONSTANT_CHAR
 
rule< ScannerT > compound_statement
 
rule< ScannerT > assignment_operator
 
definition(OperationDAGLanguageGrammar const &self)
 
rule< ScannerT > unary_expression
 
rule< ScannerT > conditional_expression_helper
 
rule< ScannerT > equality_expression_helper
 
rule< ScannerT > STRING_LITERAL_PART
 
rule< ScannerT > relational_expression_helper
 
rule< ScannerT > enumerator
 
rule< ScannerT > enumerator_list
 
rule< ScannerT > unary_operator
 
rule< ScannerT > INT_CONSTANT_DEC
 
rule< ScannerT > type_qualifier
 
rule< ScannerT > logical_and_expression_helper
 
rule< ScannerT > LEFT_BRACE
 
rule< ScannerT > LEFT_BRACKET
 
rule< ScannerT > shift_expression_helper
 
rule< ScannerT > cast_expression
 
rule< ScannerT > abstract_declarator
 
rule< ScannerT > exclusive_or_expression
 
rule< ScannerT > FLOAT_CONSTANT_2
 
rule< ScannerT > RIGHT_BRACE
 
rule< ScannerT > struct_declarator_list
 
rule< ScannerT > inclusive_or_expression_helper
 
rule< ScannerT > declaration
 
rule< ScannerT > UNSIGNED
 
rule< ScannerT > relational_expression
 
rule< ScannerT > shift_expression
 
rule< ScannerT > function_definition
 
rule< ScannerT > direct_declarator_helper
 
rule< ScannerT > direct_abstract_declarator_helper
 
rule< ScannerT > external_declaration
 
rule< ScannerT > initializer
 
rule< ScannerT > inclusive_or_expression
 
rule< ScannerT > const & start() const
 
rule< ScannerT > type_qualifier_list
 
rule< ScannerT > labeled_statement
 
rule< ScannerT > argument_expression_list
 
rule< ScannerT > struct_or_union
 
rule< ScannerT > conditional_expression
 
rule< ScannerT > declarator
 
rule< ScannerT > additive_expression_helper
 
rule< ScannerT > last_comment_spirit_bugfix
 
rule< ScannerT > translation_unit
 
rule< ScannerT > INT_CONSTANT_HEX
 
rule< ScannerT > direct_abstract_declarator
 
rule< ScannerT > type_name
 
rule< ScannerT > INT_CONSTANT
 
rule< ScannerT > parameter_declaration
 
rule< ScannerT > CONSTANT
 
rule< ScannerT > parameter_list
 
rule< ScannerT > struct_declarator
 
rule< ScannerT > INT_CONSTANT_OCT
 
rule< ScannerT > expression_helper
 
rule< ScannerT > struct_declaration_list
 
rule< ScannerT > FLOAT_CONSTANT_3
 
rule< ScannerT > equality_expression
 
rule< ScannerT > expression_statement
 
std::pair< const char *, const char * > & thePair_
 
SetStripPairActor(std::pair< const char *, const char * > &aPair)
 
void operator()(const char *start, const char *end) const
 
TokenizerActor(TokenizerData &data, TokenizerData::OperationID id)
 
TokenizerData::OperationID id_
 
void operator()(const char *start, const char *end) const
 
definition(skip_grammar const &self)
 
rule< ScannerT > const & start() const
 
std::vector< std::pair< const char *, const char * > > strippedParts
 
std::pair< const char *, const char * > lastStrip