13 #ifndef TTA_OPERATION_DAG_LANGUAGE_PARSER
14 #define TTA_OPERATION_DAG_LANGUAGE_PARSER
66 #endif // defined(_DEBUG)
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>
92 using 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>
111 using 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
133 # define INT INT_RULE
134 # define VOID VOID_RULE
139 using namespace boost::spirit;
231 case IDENTIFIER:
return "IDENTIFIER:";
232 case STRING_LITERAL:
return "STRING_LITERAL:";
233 case INTEGER_LITERAL:
return "INTEGER_LITERAL:";
234 case FLOAT_LITERAL:
return "FLOAT_LITERAL:";
235 case PRIMARY_EXPRESSION:
return "PRIMARY_EXPRESSION:";
236 case UNARY_EXPRESSION:
return "UNARY_EXPRESSION:";
237 case UNARY_ADDROF:
return "UNARY_ADDROF:";
238 case UNARY_STAR:
return "UNARY_STAR:";
239 case UNARY_PLUS:
return "UNARY_PLUS:";
240 case UNARY_MINUS:
return "UNARY_MINUS:";
241 case UNARY_TILDE:
return "UNARY_TILDE:";
242 case UNARY_BANG:
return "UNARY_BANG:";
243 case POSTFIX_EXPRESSION:
return "POSTFIX_EXPRESSION:";
244 case CAST_EXPRESSION:
return "CAST_EXPRESSION:";
245 case MULTIPLICATIVE_EXPRESSION:
return "MULTIPLICATIVE_EXPRESSION:";
246 case ADDITIVE_EXPRESSION:
return "ADDITIVE_EXPRESSION:";
247 case SHIFT_EXPRESSION:
return "SHIFT_EXPRESSION:";
248 case RELATIONAL_EXPRESSION:
return "RELATIONAL_EXPRESSION:";
249 case EQUALITY_EXPRESSION:
return "EQUALITY_EXPRESSION:";
250 case AND_EXPRESSION:
return "AND_EXPRESSION:";
251 case EXCLUSIVE_EXPRESSION:
return "EXCLUSIVE_EXPRESSION:";
252 case INCLUSIVE_EXPRESSION:
return "INCLUSIVE_EXPRESSION:";
253 case LOGICAL_AND_EXPRESSION:
return "LOGICAL_AND_EXPRESSION:";
254 case LOGICAL_OR_EXPRESSION:
return "LOGICAL_OR_EXPRESSION:";
255 case CONDITIONAL_EXPRESSION:
return "CONDITIONAL_EXPRESSION:";
256 case ASSIGNMENT_EXPRESSION:
return "ASSIGNMENT_EXPRESSION:";
257 case ASSIGNMENT_OPERATOR:
return "ASSIGNMENT_OPERATOR:";
258 case EXPRESSION:
return "EXPRESSION:";
259 case CONSTANT_EXPRESSION:
return "CONSTANT_EXPRESSION:";
260 case DECLARATION:
return "DECLARATION:";
261 case DECLARATION_SPECIFIERS:
return "DECLARATION_SPECIFIERS:";
262 case INIT_DECLARATOR:
return "INIT_DECLARATOR:";
263 case STORAGE_CLASS_SPECIFIER:
return "STORAGE_CLASS_SPECIFIER:";
264 case TYPE_SPECIFIER:
return "TYPE_SPECIFIER:";
265 case STRUCT_OR_UNION_SPECIFIER:
return "STRUCT_OR_UNION_SPECIFIER:";
266 case STRUCT_OR_UNION:
return "STRUCT_OR_UNION:";
267 case STRUCT_DECLARATION:
return "STRUCT_DECLARATION:";
268 case STRUCT_DECLARATOR:
return "STRUCT_DECLARATOR:";
269 case ENUM_SPECIFIER:
return "ENUM_SPECIFIER:";
270 case ENUMERATOR:
return "ENUMERATOR:";
271 case CONST_QUALIFER:
return "CONST_QUALIFER:";
272 case VOLATILE_QUALIFER:
return "VOLATILE_QUALIFER:";
273 case TYPE_QUALIFER:
return "TYPE_QUALIFER:";
274 case DECLARATOR:
return "DECLARATOR:";
275 case INITIALIZER:
return "INITIALIZER:";
276 case DIRECT_DECLARATOR:
return "DIRECT_DECLARATOR:";
277 case POINTER:
return "POINTER:";
278 case PARAMETER_TYPE_LIST:
return "PARAMETER_TYPE_LIST:";
279 case PARAMETER_LIST:
return "PARAMETER_LIST:";
280 case PARAMETER_DECLARATION:
return "PARAMETER_DECLARATION:";
281 case IDENTIFIER_LIST:
return "IDENTIFIER_LIST:";
282 case TYPE_NAME:
return "TYPE_NAME:";
283 case ABSTRACT_DECLARATOR:
return "ABSTRACT_DECLARATOR:";
284 case DIRECT_ABSTRACT_DECLARATOR:
return "DIRECT_ABSTRACT_DECLARATOR:";
285 case INITIALIZER_LIST:
return "INITIALIZER_LIST:";
286 case STATEMENT:
return "STATEMENT:";
287 case LABELED_STATEMENT:
return "LABELED_STATEMENT:";
288 case COMPOUND_STATEMENT:
return "COMPOUND_STATEMENT:";
289 case STATEMENT_LIST:
return "STATEMENT_LIST:";
290 case EXPRESSION_STATEMENT:
return "EXPRESSION_STATEMENT:";
291 case SELECTION_STATEMENT:
return "SELECTION_STATEMENT:";
292 case ITERATION_STATEMENT:
return "ITERATION_STATEMENT:";
293 case JUMP_STATEMENT:
return "JUMP_STATEMENT:";
294 case FUNCTION_DEFINITION:
return "FUNCTION_DEFINITION:";
295 case EXTERNAL_DECLARATION:
return "EXTERNAL_DECLARATION:";
296 case INVALID_TOKEN:
return "INVALID_TOKEN:";
297 default:
return "UNKNOWN_ID:";
306 Token(
unsigned long start,
unsigned long end, std::string& strValue) :
307 start_(start), end_(end), strValue_(strValue),
308 type_(INVALID_TOKEN),
309 isIdentifier_(
false),
310 isStringLiteral_(
false),
311 isIntegerLiteral_(
false),
312 isFloatLiteral_(
false),
313 isUnaryExpression_(
false),
314 isAddrofOperator_(
false),
315 isAsteriskOperator_(
false),
316 isPlusOperator_(
false),
317 isMinusOperator_(
false),
318 isTildeOperator_(
false),
319 isBangOperator_(
false) {}
334 if (!isIntegerLiteral()) {
336 assert(
false &&
"Node is not integer literal.");
349 case IDENTIFIER: isIdentifier_ =
true;
break;
350 case STRING_LITERAL: isStringLiteral_ =
true;
break;
351 case INTEGER_LITERAL: isIntegerLiteral_ =
true;
break;
352 case FLOAT_LITERAL: isFloatLiteral_ =
true;
break;
353 case UNARY_EXPRESSION: isUnaryExpression_ =
true;
break;
354 case UNARY_ADDROF: isAddrofOperator_ =
true;
break;
355 case UNARY_STAR: isAsteriskOperator_ =
true;
break;
356 case UNARY_PLUS: isPlusOperator_ =
true;
break;
357 case UNARY_MINUS: isMinusOperator_ =
true;
break;
358 case UNARY_TILDE: isTildeOperator_ =
true;
break;
359 case UNARY_BANG: isBangOperator_ =
true;
break;
411 if (leafCount() == 2 &&
412 leaf(0).token().type_ == PRIMARY_EXPRESSION &&
413 leaf(1).token().type_ == POSTFIX_EXPRESSION) {
428 if (leafCount() == 3 &&
429 leaf(1).token().type_ == ASSIGNMENT_OPERATOR) {
446 leaf(1).token().isIntegerLiteral() &&
447 (leaf(0).token().isPlusOperator() ||
448 leaf(0).token().isMinusOperator())) ||
451 (leafCount() == 0 && token().isIntegerLiteral())
463 assert(
false &&
"Node is not integer.");
468 if (leafCount() == 2) {
469 retVal = leaf(1).token().intValue();
470 if (leaf(0).token().isMinusOperator()) {
474 retVal = token().intValue();
504 return leafs_.size();
514 assert(index < leafCount());
515 return *leafs_[index];
525 static int recursioLevel = 0;
528 std::stringstream retVal;
531 retVal <<
"Root node" << std::endl;
533 retVal << setw(5) << data_->start_ <<
":"
534 << setw(5) << std::left << data_->end_ << std::right
538 for (
int fill = 0; fill < (recursioLevel-2)*2; fill++) {
542 retVal <<
" " << data_->strValue_ << std::endl;
545 for (
int i = 0; i < leafCount(); i++) {
546 retVal <<
" " << leaf(i).toStr();
565 for (std::vector<TokenTreeNode*>::iterator i =
566 currNode->
leafs_.begin() ;
567 i != currNode->
leafs_.end();i++) {
574 addToTokenTree(currLeaf, newToken);
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);
619 while (!parsedTokens_.empty()) {
620 delete (parsedTokens_.begin()->second);
621 parsedTokens_.erase(parsedTokens_.begin());
639 unsigned long startPos, endPos;
641 if (parsedTokens_.empty()) {
643 endPos = end - start;
649 reinterpret_cast<unsigned long>(start) +
650 reinterpret_cast<unsigned long>(
651 parsedTokens_.begin()->first.second);
654 reinterpret_cast<unsigned long>(end) +
655 reinterpret_cast<unsigned long>(
656 parsedTokens_.begin()->first.second);
661 std::pair<const char*, const char*>
662 tokenKey(end, (
const char*)(-
reinterpret_cast<unsigned long>(start)));
664 if (parsedTokens_.find(tokenKey) == parsedTokens_.end()) {
665 parsedTokens_[tokenKey] =
new Token(startPos, endPos, strVal);
666 root.addToTokenTree(*parsedTokens_[tokenKey]);
669 parsedTokens_[tokenKey]->setProperty(
id);
677 for (TokenContainerType::iterator i = parsedTokens_.begin();
678 i != parsedTokens_.end(); i++) {
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_
718 data_(data), id_(id) { }
724 std::string temp(start,end);
725 data_.
addToken(start, end, id_, temp);
743 thePair_ = std::pair<const char*, const char*>(start, end);
753 template <
typename ScannerT>
759 (str_p(
"//") >> *(anychar_p -
'\n') >> ch_p(
'\n'))
761 [push_back_a(
self.strippedParts,
self.lastStrip)]
764 (
"/*" >> *(anychar_p -
"*/") >>
"*/")
766 [push_back_a(
self.strippedParts,
self.lastStrip)]
771 [push_back_a(
self.strippedParts,
self.lastStrip)]
778 rule<ScannerT>
const&
788 public grammar<OperationDAGLanguageGrammar>
790 template <
typename ScannerT>
793 ELLIPSIS(
"..."), RIGHT_ASSIGN(
">>="), LEFT_ASSIGN(
"<<="),
794 ADD_ASSIGN(
"+="), SUB_ASSIGN(
"-="), MUL_ASSIGN(
"*="),
795 DIV_ASSIGN(
"/="), MOD_ASSIGN(
"%="), AND_ASSIGN(
"&="),
796 XOR_ASSIGN(
"^="), OR_ASSIGN(
"|="), RIGHT_OP(
">>"), LEFT_OP(
"<<"),
797 INC_OP(
"++"), DEC_OP(
"--"), PTR_OP(
"->"), AND_OP(
"&&"),
798 OR_OP(
"||"), LE_OP(
"<="), GE_OP(
">="), EQ_OP(
"=="), NE_OP(
"!="),
805 COMMA(
","), COLON(
":"), ASSIGN(
"="), LEFT_PAREN(
"("),
806 RIGHT_PAREN(
")"), DOT(
"."), ADDROF(
"&"), BANG(
"!"), TILDE(
"~"),
807 MINUS(
"-"), PLUS(
"+"), STAR(
"*"), SLASH(
"/"), PERCENT(
"%"),
808 LT_OP(
"<"), GT_OP(
">"), XOR(
"^"), OR(
"|"), QUEST(
"?") {
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",
824 LEFT_BRACE = strlit<>(
"{") | strlit<>(
"<%");
825 RIGHT_BRACE = strlit<>(
"}") | strlit<>(
"%>");
826 LEFT_BRACKET = strlit<>(
"[") | strlit<>(
"<:");
827 RIGHT_BRACKET = strlit<>(
"]") | strlit<>(
":>");
830 AUTO = strlit<>(
"auto");
831 BREAK = strlit<>(
"break");
832 CASE = strlit<>(
"case");
833 CHAR = strlit<>(
"char");
834 CONST = strlit<>(
"const");
835 CONTINUE = strlit<>(
"continue");
836 DEFAULT = strlit<>(
"default");
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");
848 REGISTER = strlit<>(
"register");
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");
856 TYPEDEF = strlit<>(
"typedef");
857 UNION = strlit<>(
"union");
858 UNSIGNED = strlit<>(
"unsigned");
859 VOID = strlit<>(
"void");
860 VOLATILE = strlit<>(
"volatile");
861 WHILE = strlit<>(
"while");
866 ((alpha_p |
'_' |
'$') >> *(alnum_p |
'_' |
'$'))
867 - (keywords >> (anychar_p - (alnum_p |
'_' |
'$')))
875 STRING_LITERAL_PART =
877 !chlit<>(
'L') >> chlit<>(
'\"') >>
878 *( strlit<>(
"\\\"") | ( anychar_p - chlit<>(
'\"') )) >>
884 (+STRING_LITERAL_PART)
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')]
984 (longest_d[FLOAT_CONSTANT | INT_CONSTANT])
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);
993 BOOST_SPIRIT_DEBUG_RULE(CONTINUE);
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);
1006 BOOST_SPIRIT_DEBUG_RULE(REGISTER);
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);
1016 BOOST_SPIRIT_DEBUG_RULE(UNSIGNED);
1017 BOOST_SPIRIT_DEBUG_RULE(VOID);
1018 BOOST_SPIRIT_DEBUG_RULE(VOLATILE);
1019 BOOST_SPIRIT_DEBUG_RULE(WHILE);
1020 BOOST_SPIRIT_DEBUG_RULE(IDENTIFIER);
1021 BOOST_SPIRIT_DEBUG_RULE(STRING_LITERAL);
1022 BOOST_SPIRIT_DEBUG_RULE(INT_CONSTANT_HEX);
1023 BOOST_SPIRIT_DEBUG_RULE(INT_CONSTANT_OCT);
1024 BOOST_SPIRIT_DEBUG_RULE(INT_CONSTANT_DEC);
1025 BOOST_SPIRIT_DEBUG_RULE(INT_CONSTANT_CHAR);
1026 BOOST_SPIRIT_DEBUG_RULE(INT_CONSTANT);
1027 BOOST_SPIRIT_DEBUG_RULE(FLOAT_CONSTANT_1);
1028 BOOST_SPIRIT_DEBUG_RULE(FLOAT_CONSTANT_2);
1029 BOOST_SPIRIT_DEBUG_RULE(FLOAT_CONSTANT_3);
1030 BOOST_SPIRIT_DEBUG_RULE(FLOAT_CONSTANT);
1031 BOOST_SPIRIT_DEBUG_RULE(CONSTANT);
1034 BOOST_SPIRIT_DEBUG_RULE(primary_expression);
1035 BOOST_SPIRIT_DEBUG_RULE(postfix_expression);
1036 BOOST_SPIRIT_DEBUG_RULE(postfix_expression_helper);
1037 BOOST_SPIRIT_DEBUG_RULE(argument_expression_list);
1038 BOOST_SPIRIT_DEBUG_RULE(unary_expression);
1039 BOOST_SPIRIT_DEBUG_RULE(unary_operator);
1040 BOOST_SPIRIT_DEBUG_RULE(cast_expression);
1041 BOOST_SPIRIT_DEBUG_RULE(multiplicative_expression);
1042 BOOST_SPIRIT_DEBUG_RULE(multiplicative_expression_helper);
1043 BOOST_SPIRIT_DEBUG_RULE(additive_expression);
1044 BOOST_SPIRIT_DEBUG_RULE(additive_expression_helper);
1045 BOOST_SPIRIT_DEBUG_RULE(shift_expression);
1046 BOOST_SPIRIT_DEBUG_RULE(shift_expression_helper);
1047 BOOST_SPIRIT_DEBUG_RULE(relational_expression);
1048 BOOST_SPIRIT_DEBUG_RULE(relational_expression_helper);
1049 BOOST_SPIRIT_DEBUG_RULE(equality_expression);
1050 BOOST_SPIRIT_DEBUG_RULE(equality_expression_helper);
1051 BOOST_SPIRIT_DEBUG_RULE(and_expression);
1052 BOOST_SPIRIT_DEBUG_RULE(and_expression_helper);
1053 BOOST_SPIRIT_DEBUG_RULE(exclusive_or_expression);
1054 BOOST_SPIRIT_DEBUG_RULE(exclusive_or_expression_helper);
1055 BOOST_SPIRIT_DEBUG_RULE(inclusive_or_expression);
1056 BOOST_SPIRIT_DEBUG_RULE(inclusive_or_expression_helper);
1057 BOOST_SPIRIT_DEBUG_RULE(logical_and_expression);
1058 BOOST_SPIRIT_DEBUG_RULE(logical_and_expression_helper);
1059 BOOST_SPIRIT_DEBUG_RULE(logical_or_expression);
1060 BOOST_SPIRIT_DEBUG_RULE(logical_or_expression_helper);
1061 BOOST_SPIRIT_DEBUG_RULE(conditional_expression);
1062 BOOST_SPIRIT_DEBUG_RULE(conditional_expression_helper);
1063 BOOST_SPIRIT_DEBUG_RULE(assignment_expression);
1064 BOOST_SPIRIT_DEBUG_RULE(assignment_operator);
1065 BOOST_SPIRIT_DEBUG_RULE(expression);
1066 BOOST_SPIRIT_DEBUG_RULE(constant_expression);
1067 BOOST_SPIRIT_DEBUG_RULE(declaration);
1068 BOOST_SPIRIT_DEBUG_RULE(declaration_specifiers);
1069 BOOST_SPIRIT_DEBUG_RULE(init_declarator_list);
1070 BOOST_SPIRIT_DEBUG_RULE(init_declarator);
1071 BOOST_SPIRIT_DEBUG_RULE(storage_class_specifier);
1072 BOOST_SPIRIT_DEBUG_RULE(type_specifier);
1073 BOOST_SPIRIT_DEBUG_RULE(struct_or_union_specifier);
1074 BOOST_SPIRIT_DEBUG_RULE(struct_or_union);
1075 BOOST_SPIRIT_DEBUG_RULE(struct_declaration_list);
1076 BOOST_SPIRIT_DEBUG_RULE(struct_declaration);
1077 BOOST_SPIRIT_DEBUG_RULE(specifier_qualifier_list);
1078 BOOST_SPIRIT_DEBUG_RULE(struct_declarator_list);
1079 BOOST_SPIRIT_DEBUG_RULE(struct_declarator);
1080 BOOST_SPIRIT_DEBUG_RULE(enum_specifier);
1081 BOOST_SPIRIT_DEBUG_RULE(enumerator_list);
1082 BOOST_SPIRIT_DEBUG_RULE(enumerator);
1083 BOOST_SPIRIT_DEBUG_RULE(type_qualifier);
1084 BOOST_SPIRIT_DEBUG_RULE(declarator);
1085 BOOST_SPIRIT_DEBUG_RULE(direct_declarator);
1086 BOOST_SPIRIT_DEBUG_RULE(direct_declarator_helper);
1087 BOOST_SPIRIT_DEBUG_RULE(pointer);
1088 BOOST_SPIRIT_DEBUG_RULE(type_qualifier_list);
1089 BOOST_SPIRIT_DEBUG_RULE(parameter_type_list);
1090 BOOST_SPIRIT_DEBUG_RULE(parameter_list);
1091 BOOST_SPIRIT_DEBUG_RULE(parameter_declaration);
1092 BOOST_SPIRIT_DEBUG_RULE(identifier_list);
1093 BOOST_SPIRIT_DEBUG_RULE(type_name);
1094 BOOST_SPIRIT_DEBUG_RULE(abstract_declarator);
1095 BOOST_SPIRIT_DEBUG_RULE(direct_abstract_declarator);
1096 BOOST_SPIRIT_DEBUG_RULE(direct_abstract_declarator_helper);
1097 BOOST_SPIRIT_DEBUG_RULE(initializer);
1098 BOOST_SPIRIT_DEBUG_RULE(initializer_list);
1099 BOOST_SPIRIT_DEBUG_RULE(statement);
1100 BOOST_SPIRIT_DEBUG_RULE(labeled_statement);
1101 BOOST_SPIRIT_DEBUG_RULE(compound_statement);
1102 BOOST_SPIRIT_DEBUG_RULE(declaration_list);
1103 BOOST_SPIRIT_DEBUG_RULE(statement_list);
1104 BOOST_SPIRIT_DEBUG_RULE(expression_statement);
1105 BOOST_SPIRIT_DEBUG_RULE(selection_statement);
1106 BOOST_SPIRIT_DEBUG_RULE(iteration_statement);
1107 BOOST_SPIRIT_DEBUG_RULE(jump_statement);
1108 BOOST_SPIRIT_DEBUG_RULE(translation_unit);
1109 BOOST_SPIRIT_DEBUG_RULE(external_declaration);
1110 BOOST_SPIRIT_DEBUG_RULE(function_definition);
1113 primary_expression =
1117 | LEFT_PAREN >> expression >> RIGHT_PAREN)
1135 postfix_expression =
1136 (primary_expression >> postfix_expression_helper)
1139 postfix_expression_helper =
1140 ((LEFT_BRACKET >> expression >> RIGHT_BRACKET
1141 | LEFT_PAREN >> !argument_expression_list >> RIGHT_PAREN
1143 | PTR_OP >> IDENTIFIER
1146 postfix_expression_helper)
1152 argument_expression_list =
1153 (assignment_expression >> *(COMMA >> assignment_expression));
1157 | INC_OP >> unary_expression
1158 | DEC_OP >> unary_expression
1159 | unary_operator >> cast_expression
1163 | LEFT_PAREN >> type_name >> RIGHT_PAREN))
1196 (LEFT_PAREN >> type_name >> RIGHT_PAREN >>
1214 multiplicative_expression =
1215 (cast_expression >> multiplicative_expression_helper)
1218 multiplicative_expression_helper =
1219 ((STAR >> cast_expression
1220 | SLASH >> cast_expression
1221 | PERCENT >> cast_expression) >>
1222 multiplicative_expression_helper)
1237 additive_expression =
1238 (multiplicative_expression >> additive_expression_helper)
1241 additive_expression_helper =
1242 ((PLUS >> multiplicative_expression
1243 | MINUS >> multiplicative_expression) >>
1244 additive_expression_helper)
1261 (additive_expression >> shift_expression_helper)
1264 shift_expression_helper =
1265 ((LEFT_OP >> additive_expression
1266 | RIGHT_OP >> additive_expression) >>
1267 shift_expression_helper)
1284 relational_expression =
1285 (shift_expression >> relational_expression_helper)
1288 relational_expression_helper =
1289 ((LT_OP >> shift_expression
1290 | GT_OP >> shift_expression
1291 | LE_OP >> shift_expression
1292 | GE_OP >> shift_expression) >>
1293 relational_expression_helper)
1308 equality_expression =
1309 (relational_expression >> equality_expression_helper)
1312 equality_expression_helper =
1313 ((EQ_OP >> relational_expression
1314 | NE_OP >> relational_expression) >>
1315 equality_expression_helper)
1327 (equality_expression >> and_expression_helper)
1330 and_expression_helper =
1331 (ADDROF >> equality_expression >>
1332 and_expression_helper)
1343 exclusive_or_expression =
1344 (and_expression >> exclusive_or_expression_helper)
1347 exclusive_or_expression_helper =
1348 (XOR >> and_expression >>
1349 exclusive_or_expression_helper)
1360 inclusive_or_expression =
1361 (exclusive_or_expression >> inclusive_or_expression_helper)
1364 inclusive_or_expression_helper =
1365 (OR >> exclusive_or_expression >>
1366 inclusive_or_expression_helper)
1377 logical_and_expression =
1378 (inclusive_or_expression >> logical_and_expression_helper)
1381 logical_and_expression_helper =
1382 (AND_OP >> inclusive_or_expression >>
1383 logical_and_expression_helper)
1394 logical_or_expression =
1395 (logical_and_expression >> logical_or_expression_helper)
1398 logical_or_expression_helper =
1399 (OR_OP >> logical_and_expression >>
1400 logical_or_expression_helper)
1412 conditional_expression =
1413 (logical_or_expression >> conditional_expression_helper)
1416 conditional_expression_helper =
1417 (QUEST >> expression >> COLON >>
1418 conditional_expression >> conditional_expression_helper)
1433 assignment_expression =
1434 (unary_expression >>
1435 assignment_operator >>
1436 assignment_expression
1437 | conditional_expression)
1442 assignment_operator =
1464 (assignment_expression >> expression_helper)
1468 (COMMA >> assignment_expression >> expression_helper)
1474 constant_expression =
1475 conditional_expression
1481 (declaration_specifiers >> !init_declarator_list >> SEMICOLON)
1486 declaration_specifiers =
1487 ((storage_class_specifier
1489 | type_qualifier) >>
1491 !declaration_specifiers)
1496 init_declarator_list =
1497 init_declarator >> *(COMMA >> init_declarator);
1500 (declarator >> !(ASSIGN >> initializer))
1505 storage_class_specifier =
1506 (TYPEDEF | EXTERN | STATIC | AUTO | REGISTER)
1531 | str_p(
"FloatWord")
1532 | str_p(
"DoubleWord")
1535 | struct_or_union_specifier
1541 struct_or_union_specifier =
1544 !(LEFT_BRACE >> struct_declaration_list >>
1546 |LEFT_BRACE >> struct_declaration_list >> RIGHT_BRACE))
1557 struct_declaration_list =
1558 +struct_declaration;
1560 struct_declaration =
1561 (specifier_qualifier_list >> struct_declarator_list >>
1566 specifier_qualifier_list =
1567 ((type_specifier | type_qualifier) >>
1568 !specifier_qualifier_list) ;
1570 struct_declarator_list =
1571 struct_declarator >> *(COMMA >> struct_declarator)
1575 (declarator || (COLON >> constant_expression))
1581 (ENUM >> !IDENTIFIER >> LEFT_BRACE >>
1589 enumerator >> *(COMMA >> enumerator)
1593 (IDENTIFIER >> !(ASSIGN >> constant_expression))
1612 (!pointer >> direct_declarator)
1633 | LEFT_PAREN >> declarator >> RIGHT_PAREN) >>
1634 direct_declarator_helper)
1637 direct_declarator_helper =
1638 ((LEFT_BRACKET >> !constant_expression >> RIGHT_BRACKET
1640 ! (parameter_type_list
1641 | identifier_list) >>
1643 direct_declarator_helper)
1650 (STAR >> !(type_qualifier_list || pointer))
1655 type_qualifier_list =
1659 parameter_type_list =
1660 (parameter_list >> !(COMMA >> ELLIPSIS))
1666 (parameter_declaration >> *(COMMA >> parameter_declaration))
1671 parameter_declaration =
1672 (declaration_specifiers >>
1673 !(declarator | abstract_declarator))
1679 (IDENTIFIER >> *(COMMA >> IDENTIFIER))
1685 (specifier_qualifier_list >> !abstract_declarator)
1690 abstract_declarator =
1691 (pointer || direct_abstract_declarator)
1710 direct_abstract_declarator =
1713 (abstract_declarator >> RIGHT_PAREN
1714 | !parameter_type_list >> RIGHT_PAREN)
1716 | LEFT_BRACKET >> !constant_expression >> RIGHT_BRACKET) >>
1718 direct_abstract_declarator_helper)
1721 direct_abstract_declarator_helper =
1722 ((LEFT_BRACKET >> !constant_expression >> RIGHT_BRACKET
1723 | LEFT_PAREN >> !parameter_type_list >> RIGHT_PAREN) >>
1724 direct_abstract_declarator_helper)
1731 (assignment_expression
1732 | LEFT_BRACE >> initializer_list >> !COMMA >> RIGHT_BRACE)
1738 (initializer >> *(COMMA >> initializer))
1745 | compound_statement
1746 | expression_statement
1747 | selection_statement
1748 | iteration_statement
1756 (IDENTIFIER >> COLON >> statement
1757 | CASE >> constant_expression >> COLON >> statement
1758 | DEFAULT >> COLON >> statement)
1763 compound_statement =
1765 !(declaration_list || statement_list) >>
1771 declaration_list = (+declaration)
1780 expression_statement =
1781 (!expression >> SEMICOLON)
1786 selection_statement =
1787 (IF >> LEFT_PAREN >> expression >> RIGHT_PAREN >>
1788 statement >> !(ELSE >> statement)
1790 | SWITCH >> LEFT_PAREN >> expression >> RIGHT_PAREN >>
1796 iteration_statement =
1798 LEFT_PAREN >> expression >> RIGHT_PAREN >> statement
1800 | DO >> statement >> WHILE >>
1801 LEFT_PAREN >> expression >>
1802 RIGHT_PAREN >> SEMICOLON
1804 | FOR >> LEFT_PAREN >>
1805 expression_statement >>
1806 expression_statement >>
1807 !expression >> RIGHT_PAREN >> statement)
1813 (GOTO >> IDENTIFIER >> SEMICOLON
1814 | CONTINUE >> SEMICOLON
1815 | BREAK >> SEMICOLON
1816 | RETURN >> !expression >> SEMICOLON)
1822 function_definition =
1823 (!declaration_specifiers >>
1825 !declaration_list >>
1831 external_declaration =
1832 (function_definition | declaration)
1843 translation_unit = *(expression_statement|declaration_list)
1854 OR_ASSIGN,
RIGHT_OP, LEFT_OP, INC_OP, DEC_OP, PTR_OP, AND_OP,
1859 DOT, ADDROF, BANG,
TILDE, MINUS, PLUS, STAR, SLASH, PERCENT,
1867 AUTO, BREAK, CASE, CHAR, CONST, CONTINUE, DEFAULT, DO,
DOUBLE,
1868 ELSE, ENUM, EXTERN, FOR, FLOAT, GOTO, IF,
INT,
LONG,
REGISTER,
1869 RETURN, SHORT, SIGNED, SIZEOF, STATIC, STRUCT, SWITCH,
TYPEDEF,
1870 UNION, UNSIGNED, VOID, VOLATILE,
WHILE, IDENTIFIER,
1900 direct_declarator, direct_declarator_helper,
pointer,
1905 initializer, initializer_list,
statement, labeled_statement,
1912 rule<ScannerT>
const&
1913 start()
const {
return translation_unit; }