OpenASIP  2.0
OperationDAGLanguageParser.hh
Go to the documentation of this file.
1 /**
2  * @file OperationDAGLanguageParser.hh
3  *
4  * OsalDAGLanguage parser based on Ansi C grammar checker.
5  *
6  * Modified to do other things that just validating.
7  *
8  * @author Mikael Lepistö 2007 (mikael.lepisto-no.spam-tut.fi)
9  * @author Pekka Jääskeläinen 2009
10  * @rating red
11  */
12 
13 #ifndef TTA_OPERATION_DAG_LANGUAGE_PARSER
14 #define TTA_OPERATION_DAG_LANGUAGE_PARSER
15 
16 /*===========================================================================
17  C Grammar checker
18  Requires Spirit v1.6.0 or later
19 
20  Copyright (c) 2001-2004 Hartmut Kaiser
21  http://spirit.sourceforge.net/
22 
23  Adapted from:
24  http://www.lysator.liu.se/c/ANSI-C-grammar-y.html
25  http://www.lysator.liu.se/c/ANSI-C-grammar-l.html
26 
27  Use, modification and distribution is subject to the Boost Software
28  License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
29  http://www.boost.org/LICENSE_1_0.txt)
30 ============================================================================*/
31 
32 //////////////////////////////////////////////////////////////////////////////
33 // version history
34 //
35 // TODO: Handling typedef's, without that we can't correctly parse
36 // auxilliary valid C sources. But hey it's a sample.
37 //
38 // Modified: 20.09.2002 21:58:45
39 // Ported to Spirit V1.5
40 //
41 // Modified: 18.10.2001 16:36:07
42 // Corrected: String literals may be splitted in several strings: "abc" "def"
43 // Corrected: String literals may have length 0 ("")
44 //
45 // Modified: 17.10.2001 10:56:57
46 // Rewritten: *_CONSTANT rules
47 // Introduced: operator '||' where possible
48 // Corrected: IDENTIFIER can start with '_' and can contain '$'
49 // Added: Skipping of '#line' and '#pragma' directives, which contained
50 // in preprocessed files of the Intel V5.0.1 compiler
51 //
52 // Modified: 16.10.2001 21:12:05
53 // Corrected: missing lexeme_d[] statements for *_CONSTANT
54 // Corrected: missing longest_d[] for CONSTANT
55 
56 #include <iostream>
57 #include <iomanip>
58 #include <fstream>
59 #include <vector>
60 #include <map>
61 
62 #if defined(_DEBUG)
63 // LLVM svn builds want to define _DEBUG which causes massive
64 // debug spam
65 //#define BOOST_SPIRIT_DEBUG
66 #endif // defined(_DEBUG)
67 
68 #include <boost/version.hpp>
69 
70 #include "CompilerWarnings.hh"
71 IGNORE_COMPILER_WARNING("-Wunused-parameter")
72 IGNORE_CLANG_WARNING("-Wunused-local-typedef")
73 #if BOOST_VERSION >= 103800
74 
75 #define PHOENIX_LIMIT 10
76 
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>
91 
92 using namespace boost::spirit::classic;
93 
94 #else
95 
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>
110 
111 using namespace boost::spirit;
112 
113 #endif
116 
117 #include "Conversion.hh"
118 
119 // There is a g++ (3.1 and 3.2) bug on MINGW that prohibits
120 // the use of the identifiers below. The following is a workaround.
121 
122 #if ((__GNUC__ == 3) && (__GNUC_MINOR__ == 1 || __GNUC_MINOR__ == 2) \
123  && defined(_WINNT_H))
124 # ifdef CONST
125 # undef CONST
126 # endif
127 # ifdef VOID
128 # undef VOID
129 # endif
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
135 #endif
136 
137 /////////////////////////////////////////////////////////////////////////////
138 // used namespaces
139 using namespace boost::spirit;
140 using namespace std;
141 
142 
143 /**
144  * Class which is used by Spirit parser to create tokenized
145  * tree form of the source code.
146  */
147 
149 public:
150 
151  /**
152  * List of different type tokens.
153  */
154  enum OperationID {
220  INVALID_TOKEN
221  };
222 
223  /**
224  * Prints string value for each token.
225  *
226  * @param id Token type.
227  * @return String for token type.
228  */
229  static std::string idString(OperationID id) {
230  switch (id) {
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:";
298  }
299  }
300 
301  /**
302  * Represents one token of source code.
303  */
304  class Token {
305  public:
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) {}
320 
321  bool isIdentifier() const {return isIdentifier_;}
322  bool isStringLiteral() const {return isStringLiteral_;}
323  bool isIntegerLiteral() const {return isIntegerLiteral_;}
324  bool isFloatLiteral() const {return isFloatLiteral_;}
325  bool isUnaryExpression() const {return isUnaryExpression_;}
326  bool isAddrofOperator() const {return isAddrofOperator_;}
327  bool isAsteriskOperator() const {return isAsteriskOperator_;}
328  bool isPlusOperator() const {return isPlusOperator_;}
329  bool isMinusOperator() const {return isMinusOperator_;}
330  bool isTildeOperator() const {return isTildeOperator_;}
331  bool isBangOperator() const {return isBangOperator_;}
332 
333  long intValue() const {
334  if (!isIntegerLiteral()) {
335  // TODO: throw exception
336  assert(false && "Node is not integer literal.");
337  }
338  return Conversion::toLong(strValue_);
339  }
340 
341  std::string stringValue() const {
342  return strValue_;
343  }
344 
345  bool isPostfixExpression() const {return false;}
346 
348  switch (id) {
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;
360  default: ;
361  }
362 
363  type_ = id;
364  }
365 
366  unsigned long start_;
367  unsigned long end_;
368  std::string strValue_;
370 
382  };
383 
384  /**
385  * One node of tree of tokens.
386  *
387  * Each node contains reference to it's token and it's sub-token-nodes..
388  *
389  * root
390  * \
391  * function
392  * / \
393  * name postfix
394  * / |
395  * name name
396  */
398  public:
399  TokenTreeNode() : data_(NULL) {}
400  TokenTreeNode(Token& token) : data_(&token) {}
401 
402  /**
403  * Returns true if node contain tokens of function call.
404  *
405  * leafs must be:
406  * PRIMARY_EXPRESSION, POSTFIX_EXPRESSION
407  *
408  * @return true if node is function call.
409  */
410  bool isFunctionCall() const {
411  if (leafCount() == 2 &&
412  leaf(0).token().type_ == PRIMARY_EXPRESSION &&
413  leaf(1).token().type_ == POSTFIX_EXPRESSION) {
414  return true;
415  }
416  return false;
417  }
418 
419  /**
420  * Returns true if node contain tokens of assignment
421  *
422  * leafs must be:
423  * ANY, ASSIGNMENT_OPERATOR, ANY
424  *
425  * @return true if node is assginment.
426  */
427  bool isAssignment() const {
428  if (leafCount() == 3 &&
429  leaf(1).token().type_ == ASSIGNMENT_OPERATOR) {
430  return true;
431  }
432  return false;
433  }
434 
435  /**
436  * Returns true if node contain integer value.
437  *
438  * leafs must be: none, or (+|-, isIntegerLiteral)
439  *
440  * @return true if node is integer value.
441  */
442  bool isInteger() const {
443  if (
444  // if two part integer e.g. -1 or +1
445  (leafCount() == 2 &&
446  leaf(1).token().isIntegerLiteral() &&
447  (leaf(0).token().isPlusOperator() ||
448  leaf(0).token().isMinusOperator())) ||
449 
450  // or if just number without prefix
451  (leafCount() == 0 && token().isIntegerLiteral())
452  ) {
453 
454  return true;
455  }
456 
457  return false;
458  }
459 
460  long intValue() const {
461  if (!isInteger()) {
462  // TODO: throw exception
463  assert(false && "Node is not integer.");
464  }
465 
466  long retVal = 0;
467 
468  if (leafCount() == 2) {
469  retVal = leaf(1).token().intValue();
470  if (leaf(0).token().isMinusOperator()) {
471  retVal = -retVal;
472  }
473  } else {
474  retVal = token().intValue();
475  }
476 
477  return retVal;
478  }
479 
480  /**
481  * Adds newly parsed token to tree under this token tree node.
482  *
483  * @param token Token to add token tree.
484  */
485  void addToTokenTree(Token& token) {
486  addToTokenTree(this, new TokenTreeNode(token));
487  }
488 
489  /**
490  * Returns referred token of token tree node.
491  *
492  * @returns Referred token of token tree node.
493  */
494  const Token& token() const {
495  return *data_;
496  }
497 
498  /**
499  * Returns number of leafs that this token tree node has.
500  *
501  * @return Number of leafs that this token tree node has.
502  */
503  int leafCount() const {
504  return leafs_.size();
505  }
506 
507  /**
508  * Returns leaf of requested index.
509  *
510  * @param index Index of leaf to return.
511  * @return leaf of requested index.
512  */
513  TokenTreeNode& leaf(int index) const {
514  assert(index < leafCount());
515  return *leafs_[index];
516  }
517 
518 
519  /**
520  * Returns node and its sub nodes as a string.
521  *
522  * @return Node and its sub nodes as a string.
523  */
524  std::string toStr() const {
525  static int recursioLevel = 0;
526 
527  recursioLevel++;
528  std::stringstream retVal;
529 
530  if (data_ == NULL) {
531  retVal << "Root node" << std::endl;
532  } else {
533  retVal << setw(5) << data_->start_ << ":"
534  << setw(5) << std::left << data_->end_ << std::right
535  << setw(30) << TokenizerData::idString(data_->type_)
536  << " ";
537 
538  for (int fill = 0; fill < (recursioLevel-2)*2; fill++) {
539  retVal << "*";
540  }
541 
542  retVal << " " << data_->strValue_ << std::endl;
543  }
544 
545  for (int i = 0; i < leafCount(); i++) {
546  retVal << " " << leaf(i).toStr();
547  }
548 
549  recursioLevel--;
550  return retVal.str();
551  }
552 
553  private:
554 
555  /**
556  * Adds token tree node to under other token tree node.
557  *
558  * @param currNode Node where to add new node.
559  * @param newToken Token tree node to add to currNode.
560  */
561  static void addToTokenTree(
562  TokenTreeNode* currNode, TokenTreeNode* newToken) {
563 
564  // check if token should be part of one of the leafs
565  for (std::vector<TokenTreeNode*>::iterator i =
566  currNode->leafs_.begin() ;
567  i != currNode->leafs_.end();i++) {
568  TokenTreeNode *currLeaf = *i;
569 
570  // if this token should be part of current leaf
571  if (newToken->data_->start_ >= currLeaf->data_->start_ &&
572  newToken->data_->end_ <= currLeaf->data_->end_) {
573 
574  addToTokenTree(currLeaf, newToken);
575  return;
576  }
577 
578  // move current leafs to inside this token
579  // if necessary
580  if (newToken->data_->start_ <= currLeaf->data_->start_ &&
581  newToken->data_->end_ >= currLeaf->data_->end_) {
582 
583  // remove from original
584  std::vector<TokenTreeNode*>::iterator temp = i;
585  i--;
586  currNode->leafs_.erase(temp);
587 
588  // add to new...
589  newToken->leafs_.push_back(currLeaf);
590  }
591 
592  // if start of current leaf is after end of this..
593  // add token to this point.
594  if (newToken->data_->end_ <= currLeaf->data_->start_) {
595  currNode->leafs_.insert(i, newToken);
596  return;
597  }
598  }
599 
600  // if there wasn't any sub nodes where value could go, add it to
601  // end of current node
602  currNode->leafs_.push_back(newToken);
603  return;
604  }
605 
606  /// Token of token tree node.
608 
609  /// Leafs of this node.
610  std::vector<TokenTreeNode*> leafs_;
611  };
612 
614 
615  /**
616  * Deletes all the parsed data.
617  */
619  while (!parsedTokens_.empty()) {
620  delete (parsedTokens_.begin()->second);
621  parsedTokens_.erase(parsedTokens_.begin());
622  }
623  // TODO: delete TokenTreeNodes
624  }
625 
626 
627  /**
628  * Creates new token based on parsed data or updates new type info
629  * for old token.
630  *
631  * @param start Start position of token.
632  * @param end End position of token.
633  * @param id Type of token.
634  * @param strVal String of token.
635  */
636  void addToken(const char* start, const char* end,
637  OperationID id, std::string strVal) {
638 
639  unsigned long startPos, endPos;
640 
641  if (parsedTokens_.empty()) {
642  startPos = 0;
643  endPos = end - start;
644  } else {
645  // in parsedTokens_.begin()->first.second is actually stored value
646  // (-start) of first parsed token. So we can add it to current
647  // start address for getting relative end and start positions.
648  startPos =
649  reinterpret_cast<unsigned long>(start) +
650  reinterpret_cast<unsigned long>(
651  parsedTokens_.begin()->first.second);
652 
653  endPos =
654  reinterpret_cast<unsigned long>(end) +
655  reinterpret_cast<unsigned long>(
656  parsedTokens_.begin()->first.second);
657  }
658 
659  // key for map is selected (end, -start) for automatically organizase
660  // tokens
661  std::pair<const char*, const char*>
662  tokenKey(end, (const char*)(-reinterpret_cast<unsigned long>(start)));
663 
664  if (parsedTokens_.find(tokenKey) == parsedTokens_.end()) {
665  parsedTokens_[tokenKey] = new Token(startPos, endPos, strVal);
666  root.addToTokenTree(*parsedTokens_[tokenKey]);
667  }
668 
669  parsedTokens_[tokenKey]->setProperty(id);
670  }
671 
672  /**
673  * Shows source code parsed to tokens.
674  */
676 
677  for (TokenContainerType::iterator i = parsedTokens_.begin();
678  i != parsedTokens_.end(); i++) {
679 
680  std::cerr << std::hex
681  << std::setw(4) << i->second->start_
682  << " - "
683  << std::setw(4) << i->second->end_
684 
685  << " : "
686  << std::setw(30) << idString(i->second->type_)
687 
688  << " : "
689  << i->second->strValue_
690  << std::endl;
691  }
692  }
693 
694  /**
695  * Returns root node of token tree.
696  *
697  * @return Root node of token tree.
698  */
699  const TokenTreeNode* tokenTree() const {
700  return &root;
701  }
702 
703 private:
704  typedef std::map<
705  std::pair<const char*, const char*>, Token*> TokenContainerType;
706 
709 };
710 
711 
712 /**
713  * Spirit actor for adding data to TokenizerData during parsing.
714  */
716 
718  data_(data), id_(id) { }
719 
722 
723  void operator()(const char* start, const char* end) const {
724  std::string temp(start,end);
725  data_.addToken(start, end, id_, temp);
726 
727  // std::cerr << "found: " << setw(10) << TokenizerData::idString(id_)
728  // << " " << temp << std::endl;
729  }
730 };
731 
732 /**
733  * Spirit actor for book keeping stripped strings.
734  */
736 
737  SetStripPairActor(std::pair<const char*, const char*> &aPair) :
738  thePair_(aPair) {}
739 
740  std::pair<const char*, const char*> &thePair_;
741 
742  void operator()(const char* start, const char* end) const {
743  thePair_ = std::pair<const char*, const char*>(start, end);
744  }
745 };
746 
747 /////////////////////////////////////////////////////////////////////////////
748 // parsing helper function
749 
750 // Here's our comment rule
751 struct skip_grammar : public grammar<skip_grammar>
752 {
753  template <typename ScannerT>
754  struct definition
755  {
757  {
758  skip =
759  (str_p("//") >> *(anychar_p - '\n') >> ch_p('\n'))
760  [SetStripPairActor(self.lastStrip)]
761  [push_back_a(self.strippedParts, self.lastStrip)]
762 
763  |
764  ("/*" >> *(anychar_p - "*/") >> "*/")
765  [SetStripPairActor(self.lastStrip)]
766  [push_back_a(self.strippedParts, self.lastStrip)]
767 
768  |
769  (+space_p)
770  [SetStripPairActor(self.lastStrip)]
771  [push_back_a(self.strippedParts, self.lastStrip)]
772  ;
773 
774  }
775 
776  rule<ScannerT> skip;
777 
778  rule<ScannerT> const&
779  start() const { return skip; }
780  };
781 
782 public:
783  mutable std::vector<std::pair<const char*, const char*> > strippedParts;
784  mutable std::pair<const char*, const char*> lastStrip;
785 };
786 
788  public grammar<OperationDAGLanguageGrammar>
789 {
790  template <typename ScannerT>
791  struct definition {
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("!="),
799 // SEMICOLON(';'),
800 // COMMA(','), COLON(':'), ASSIGN('='), LEFT_PAREN('('),
801 // RIGHT_PAREN(')'), DOT('.'), ADDROF('&'), BANG('!'), TILDE('~'),
802 // MINUS('-'), PLUS('+'), STAR('*'), SLASH('/'), PERCENT('%'),
803 // LT_OP('<'), GT_OP('>'), XOR('^'), OR('|'), QUEST('?') {
804  SEMICOLON(";"),
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("?") {
809 
810  // C keywords
811  keywords =
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",
817  "volatile", "while";
818 
819  // C operators
820 // LEFT_BRACE = chlit<>('{') | strlit<>("<%");
821 // RIGHT_BRACE = chlit<>('}') | strlit<>("%>");
822 // LEFT_BRACKET = chlit<>('[') | strlit<>("<:");
823 // RIGHT_BRACKET = chlit<>(']') | strlit<>(":>");
824  LEFT_BRACE = strlit<>("{") | strlit<>("<%");
825  RIGHT_BRACE = strlit<>("}") | strlit<>("%>");
826  LEFT_BRACKET = strlit<>("[") | strlit<>("<:");
827  RIGHT_BRACKET = strlit<>("]") | strlit<>(":>");
828 
829  // Tokens
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");
837  DO = strlit<>("do");
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");
845  IF = strlit<>("if");
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");
862 
863  // C identifiers
864  IDENTIFIER =
865  (lexeme_d[
866  ((alpha_p | '_' | '$') >> *(alnum_p | '_' | '$'))
867  - (keywords >> (anychar_p - (alnum_p | '_' | '$')))
868  ])
869  [TokenizerActor(self.tokenData_,
871 
872  ;
873 
874  // string literals
875  STRING_LITERAL_PART =
876  lexeme_d[
877  !chlit<>('L') >> chlit<>('\"') >>
878  *( strlit<>("\\\"") | ( anychar_p - chlit<>('\"') )) >>
879  chlit<>('\"')
880  ]
881  ;
882 
883  STRING_LITERAL =
884  (+STRING_LITERAL_PART)
885  [TokenizerActor(self.tokenData_,
887  ;
888 
889  // integer constants
890  INT_CONSTANT_HEX =
891  lexeme_d[
892  chlit<>('0') >>
893  as_lower_d[chlit<>('x')] >>
894  +xdigit_p >>
895  !as_lower_d[chlit<>('l') | chlit<>('u')]
896  ]
897  ;
898 
899  INT_CONSTANT_OCT
900  = lexeme_d[
901  chlit<>('0')
902  >> +range<>('0', '7')
903  >> !as_lower_d[chlit<>('l') | chlit<>('u')]
904  ]
905  ;
906 
907  INT_CONSTANT_DEC
908  = lexeme_d[
909  +digit_p
910  >> !as_lower_d[chlit<>('l') | chlit<>('u')]
911  ]
912  ;
913 
914  INT_CONSTANT_CHAR
915  = lexeme_d[
916  !chlit<>('L') >> chlit<>('\'') >>
917  longest_d[
918  anychar_p
919  | ( chlit<>('\\')
920  >> chlit<>('0')
921  >> repeat_p(0, 2)[range<>('0', '7')]
922  )
923  | (chlit<>('\\') >> anychar_p)
924  ] >>
925  chlit<>('\'')
926  ]
927  ;
928 
929  INT_CONSTANT =
930  (INT_CONSTANT_HEX
931  | INT_CONSTANT_OCT
932  | INT_CONSTANT_DEC
933  | INT_CONSTANT_CHAR)
934  [TokenizerActor(self.tokenData_,
936  ;
937 
938  // float constants
939  FLOAT_CONSTANT_1 // 12345[eE][+-]123[lLfF]?
940  = lexeme_d[
941  +digit_p
942  >> (chlit<>('e') | chlit<>('E'))
943  >> !(chlit<>('+') | chlit<>('-'))
944  >> +digit_p
945  >> !as_lower_d[chlit<>('l') | chlit<>('f')]
946  ]
947  ;
948 
949  FLOAT_CONSTANT_2 // .123([[eE][+-]123)?[lLfF]?
950  = lexeme_d[
951  *digit_p
952  >> chlit<>('.')
953  >> +digit_p
954  >> !((chlit<>('e') | chlit<>('E'))
955  >> !(chlit<>('+') | chlit<>('-'))
956  >> +digit_p
957  )
958  >> !as_lower_d[chlit<>('l') | chlit<>('f')]
959  ]
960  ;
961 
962  FLOAT_CONSTANT_3 // 12345.([[eE][+-]123)?[lLfF]?
963  = lexeme_d[
964  +digit_p
965  >> chlit<>('.')
966  >> *digit_p
967  >> !((chlit<>('e') | chlit<>('E'))
968  >> !(chlit<>('+') | chlit<>('-'))
969  >> +digit_p
970  )
971  >> !as_lower_d[chlit<>('l') | chlit<>('f')]
972  ]
973  ;
974 
975  FLOAT_CONSTANT =
976  (FLOAT_CONSTANT_1
977  | FLOAT_CONSTANT_2
978  | FLOAT_CONSTANT_3)
979  [TokenizerActor(self.tokenData_,
981  ;
982 
983  CONSTANT =
984  (longest_d[FLOAT_CONSTANT | INT_CONSTANT])
985  ;
986 
987  // debug support for terminals
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);
1032 
1033  // debug support for non terminals
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);
1111 
1112  // Rules
1113  primary_expression =
1114  (IDENTIFIER
1115  | CONSTANT
1116  | STRING_LITERAL
1117  | LEFT_PAREN >> expression >> RIGHT_PAREN)
1118  [TokenizerActor(self.tokenData_,
1120  ;
1121 
1122  // left recursion --> right recursion
1123  // postfix_expression
1124  // = primary_expression
1125  // | postfix_expression >>
1126  // (
1127  // LEFT_BRACKET >> expression >> RIGHT_BRACKET
1128  // | LEFT_PAREN >> !argument_expression_list >> RIGHT_PAREN
1129  // | DOT >> IDENTIFIER
1130  // | PTR_OP >> IDENTIFIER
1131  // | INC_OP
1132  // | DEC_OP
1133  // )
1134  // ;
1135  postfix_expression =
1136  (primary_expression >> postfix_expression_helper)
1137  ;
1138 
1139  postfix_expression_helper =
1140  ((LEFT_BRACKET >> expression >> RIGHT_BRACKET
1141  | LEFT_PAREN >> !argument_expression_list >> RIGHT_PAREN
1142  | DOT >> IDENTIFIER
1143  | PTR_OP >> IDENTIFIER
1144  | INC_OP
1145  | DEC_OP) >>
1146  postfix_expression_helper)
1147  [TokenizerActor(self.tokenData_,
1149  | epsilon_p
1150  ;
1151 
1152  argument_expression_list =
1153  (assignment_expression >> *(COMMA >> assignment_expression));
1154 
1155  unary_expression =
1156  (postfix_expression
1157  | INC_OP >> unary_expression
1158  | DEC_OP >> unary_expression
1159  | unary_operator >> cast_expression
1160  | SIZEOF >>
1161 
1162  (unary_expression
1163  | LEFT_PAREN >> type_name >> RIGHT_PAREN))
1164  [TokenizerActor(self.tokenData_,
1166  ;
1167 
1168  unary_operator =
1169  ADDROF
1170  [TokenizerActor(self.tokenData_,
1172 
1173  | STAR
1174  [TokenizerActor(self.tokenData_,
1176 
1177  | PLUS
1178  [TokenizerActor(self.tokenData_,
1180 
1181  | MINUS
1182  [TokenizerActor(self.tokenData_,
1184 
1185  | TILDE
1186  [TokenizerActor(self.tokenData_,
1188 
1189  | BANG
1190  [TokenizerActor(self.tokenData_,
1192 
1193  ;
1194 
1195  cast_expression =
1196  (LEFT_PAREN >> type_name >> RIGHT_PAREN >>
1197  cast_expression
1198  | unary_expression)
1199  [TokenizerActor(self.tokenData_,
1201 
1202  ;
1203 
1204  // left recursion --> right recursion
1205  // multiplicative_expression
1206  // = cast_expression
1207  // | multiplicative_expression >>
1208  // (
1209  // STAR >> cast_expression
1210  // | SLASH >> cast_expression
1211  // | PERCENT >> cast_expression
1212  // )
1213  // ;
1214  multiplicative_expression =
1215  (cast_expression >> multiplicative_expression_helper)
1216  ;
1217 
1218  multiplicative_expression_helper =
1219  ((STAR >> cast_expression
1220  | SLASH >> cast_expression
1221  | PERCENT >> cast_expression) >>
1222  multiplicative_expression_helper)
1223  [TokenizerActor(self.tokenData_,
1225  | epsilon_p
1226  ;
1227 
1228  // left recursion --> right recursion
1229  // additive_expression
1230  // = multiplicative_expression
1231  // | additive_expression >>
1232  // (
1233  // PLUS >> multiplicative_expression
1234  // | MINUS >> multiplicative_expression
1235  // )
1236  // ;
1237  additive_expression =
1238  (multiplicative_expression >> additive_expression_helper)
1239  ;
1240 
1241  additive_expression_helper =
1242  ((PLUS >> multiplicative_expression
1243  | MINUS >> multiplicative_expression) >>
1244  additive_expression_helper)
1245  [TokenizerActor(self.tokenData_,
1247 
1248  | epsilon_p
1249  ;
1250 
1251  // left recursion --> right recursion
1252  // shift_expression
1253  // = additive_expression
1254  // | shift_expression >>
1255  // (
1256  // LEFT_OP >> additive_expression
1257  // | RIGHT_OP >> additive_expression
1258  // )
1259  // ;
1260  shift_expression =
1261  (additive_expression >> shift_expression_helper)
1262  ;
1263 
1264  shift_expression_helper =
1265  ((LEFT_OP >> additive_expression
1266  | RIGHT_OP >> additive_expression) >>
1267  shift_expression_helper)
1268  [TokenizerActor(self.tokenData_,
1270  | epsilon_p
1271  ;
1272 
1273  // left recursion --> right recursion
1274  // relational_expression
1275  // = shift_expression
1276  // | relational_expression >>
1277  // (
1278  // LT_OP >> shift_expression
1279  // | GT_OP >> shift_expression
1280  // | LE_OP >> shift_expression
1281  // | GE_OP >> shift_expression
1282  // )
1283  // ;
1284  relational_expression =
1285  (shift_expression >> relational_expression_helper)
1286  ;
1287 
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)
1294  [TokenizerActor(self.tokenData_,
1296  | epsilon_p
1297  ;
1298 
1299  // left recursion --> right recursion
1300  // equality_expression
1301  // = relational_expression
1302  // | equality_expression >>
1303  // (
1304  // EQ_OP >> relational_expression
1305  // | NE_OP >> relational_expression
1306  // )
1307  // ;
1308  equality_expression =
1309  (relational_expression >> equality_expression_helper)
1310  ;
1311 
1312  equality_expression_helper =
1313  ((EQ_OP >> relational_expression
1314  | NE_OP >> relational_expression) >>
1315  equality_expression_helper)
1316  [TokenizerActor(self.tokenData_,
1318  | epsilon_p
1319  ;
1320 
1321  // left recursion --> right recursion
1322  // and_expression
1323  // = equality_expression
1324  // | and_expression >> ADDROF >> equality_expression
1325  // ;
1326  and_expression =
1327  (equality_expression >> and_expression_helper)
1328  ;
1329 
1330  and_expression_helper =
1331  (ADDROF >> equality_expression >>
1332  and_expression_helper)
1333  [TokenizerActor(self.tokenData_,
1335  | epsilon_p
1336  ;
1337 
1338  // left recursion --> right recursion
1339  // exclusive_or_expression
1340  // = and_expression
1341  // | exclusive_or_expression >> XOR >> and_expression
1342  // ;
1343  exclusive_or_expression =
1344  (and_expression >> exclusive_or_expression_helper)
1345  ;
1346 
1347  exclusive_or_expression_helper =
1348  (XOR >> and_expression >>
1349  exclusive_or_expression_helper)
1350  [TokenizerActor(self.tokenData_,
1352  | epsilon_p
1353  ;
1354 
1355  // left recursion --> right recursion
1356  // inclusive_or_expression
1357  // = exclusive_or_expression
1358  // | inclusive_or_expression >> OR >> exclusive_or_expression
1359  // ;
1360  inclusive_or_expression =
1361  (exclusive_or_expression >> inclusive_or_expression_helper)
1362  ;
1363 
1364  inclusive_or_expression_helper =
1365  (OR >> exclusive_or_expression >>
1366  inclusive_or_expression_helper)
1367  [TokenizerActor(self.tokenData_,
1369  | epsilon_p
1370  ;
1371 
1372  // left recursion --> right recursion
1373  // logical_and_expression
1374  // = inclusive_or_expression
1375  // | logical_and_expression >> AND_OP >> inclusive_or_expression
1376  // ;
1377  logical_and_expression =
1378  (inclusive_or_expression >> logical_and_expression_helper)
1379  ;
1380 
1381  logical_and_expression_helper =
1382  (AND_OP >> inclusive_or_expression >>
1383  logical_and_expression_helper)
1384  [TokenizerActor(self.tokenData_,
1386  | epsilon_p
1387  ;
1388 
1389  // left recursion --> right recursion
1390  // logical_or_expression
1391  // = logical_and_expression
1392  // | logical_or_expression >> OR_OP >> logical_and_expression
1393  // ;
1394  logical_or_expression =
1395  (logical_and_expression >> logical_or_expression_helper)
1396  ;
1397 
1398  logical_or_expression_helper =
1399  (OR_OP >> logical_and_expression >>
1400  logical_or_expression_helper)
1401  [TokenizerActor(self.tokenData_,
1403  | epsilon_p
1404  ;
1405 
1406  // left recursion --> right recursion
1407  // conditional_expression
1408  // = logical_or_expression
1409  // | logical_or_expression >> QUEST >> expression >> COLON >>
1410  // conditional_expression
1411  // ;
1412  conditional_expression =
1413  (logical_or_expression >> conditional_expression_helper)
1414  ;
1415 
1416  conditional_expression_helper =
1417  (QUEST >> expression >> COLON >>
1418  conditional_expression >> conditional_expression_helper)
1419  [TokenizerActor(self.tokenData_,
1421  | epsilon_p
1422  ;
1423 
1424  // assignment_expression =
1425  // (unary_expression >>
1426  // assignment_operator >>
1427  // assignment_expression
1428  // | conditional_expression)
1429  // [TokenizerActor(self.tokenData_,
1430  // TokenizerData::ASSIGNMENT_EXPRESSION)]
1431  // ;
1432 
1433  assignment_expression =
1434  (unary_expression >>
1435  assignment_operator >>
1436  assignment_expression
1437  | conditional_expression)
1438  [TokenizerActor(self.tokenData_,
1440  ;
1441 
1442  assignment_operator =
1443  (ASSIGN
1444  | MUL_ASSIGN
1445  | DIV_ASSIGN
1446  | MOD_ASSIGN
1447  | ADD_ASSIGN
1448  | SUB_ASSIGN
1449  | LEFT_ASSIGN
1450  | RIGHT_ASSIGN
1451  | AND_ASSIGN
1452  | XOR_ASSIGN
1453  | OR_ASSIGN)
1454  [TokenizerActor(self.tokenData_,
1456  ;
1457 
1458  // left recursion --> right recursion
1459  // expression
1460  // = assignment_expression
1461  // | expression >> COMMA >> assignment_expression
1462  // ;
1463  expression =
1464  (assignment_expression >> expression_helper)
1465  ;
1466 
1467  expression_helper =
1468  (COMMA >> assignment_expression >> expression_helper)
1469  [TokenizerActor(self.tokenData_,
1471  | epsilon_p
1472  ;
1473 
1474  constant_expression =
1475  conditional_expression
1476  [TokenizerActor(self.tokenData_,
1478  ;
1479 
1480  declaration =
1481  (declaration_specifiers >> !init_declarator_list >> SEMICOLON)
1482  [TokenizerActor(self.tokenData_,
1484  ;
1485 
1486  declaration_specifiers =
1487  ((storage_class_specifier
1488  | type_specifier
1489  | type_qualifier) >>
1490 
1491  !declaration_specifiers)
1492  [TokenizerActor(self.tokenData_,
1494  ;
1495 
1496  init_declarator_list =
1497  init_declarator >> *(COMMA >> init_declarator);
1498 
1499  init_declarator =
1500  (declarator >> !(ASSIGN >> initializer))
1501  [TokenizerActor(self.tokenData_,
1503  ;
1504 
1505  storage_class_specifier =
1506  (TYPEDEF | EXTERN | STATIC | AUTO | REGISTER)
1507  [TokenizerActor(self.tokenData_,
1509  ;
1510 
1511  // type_specifier =
1512  // (VOID
1513  // | CHAR
1514  // | SHORT
1515  // | INT
1516  // | LONG
1517  // | FLOAT
1518  // | DOUBLE
1519  // | SIGNED
1520  // | UNSIGNED
1521  // | struct_or_union_specifier
1522  // | enum_specifier
1523  // // | TYPE_NAME
1524  // )
1525  // [TokenizerActor(self.tokenData_,
1526  // TokenizerData::TYPE_SPECIFIER)]
1527  // ;
1528 
1529  type_specifier =
1530  (str_p("IntWord")
1531  | str_p("FloatWord")
1532  | str_p("DoubleWord")
1533  | str_p("SimValue")
1534  | str_p("Var")
1535  | struct_or_union_specifier
1536  | enum_specifier)
1537  [TokenizerActor(self.tokenData_,
1539  ;
1540 
1541  struct_or_union_specifier =
1542  (struct_or_union >>
1543  (IDENTIFIER >>
1544  !(LEFT_BRACE >> struct_declaration_list >>
1545  RIGHT_BRACE)
1546  |LEFT_BRACE >> struct_declaration_list >> RIGHT_BRACE))
1547  [TokenizerActor(self.tokenData_,
1549  ;
1550 
1551  struct_or_union =
1552  (STRUCT | UNION)
1553  [TokenizerActor(self.tokenData_,
1555  ;
1556 
1557  struct_declaration_list =
1558  +struct_declaration;
1559 
1560  struct_declaration =
1561  (specifier_qualifier_list >> struct_declarator_list >>
1562  SEMICOLON)
1563  [TokenizerActor(self.tokenData_,
1565 
1566  specifier_qualifier_list =
1567  ((type_specifier | type_qualifier) >>
1568  !specifier_qualifier_list) ;
1569 
1570  struct_declarator_list =
1571  struct_declarator >> *(COMMA >> struct_declarator)
1572  ;
1573 
1574  struct_declarator =
1575  (declarator || (COLON >> constant_expression))
1576  [TokenizerActor(self.tokenData_,
1578  ;
1579 
1580  enum_specifier =
1581  (ENUM >> !IDENTIFIER >> LEFT_BRACE >>
1582  enumerator_list >>
1583  RIGHT_BRACE)
1584  [TokenizerActor(self.tokenData_,
1586  ;
1587 
1588  enumerator_list =
1589  enumerator >> *(COMMA >> enumerator)
1590  ;
1591 
1592  enumerator =
1593  (IDENTIFIER >> !(ASSIGN >> constant_expression))
1594  [TokenizerActor(self.tokenData_,
1596  ;
1597 
1598  type_qualifier =
1599  (CONST
1600  [TokenizerActor(self.tokenData_,
1602 
1603  | VOLATILE
1604  [TokenizerActor(self.tokenData_,
1606 
1607  [TokenizerActor(self.tokenData_,
1609  ;
1610 
1611  declarator =
1612  (!pointer >> direct_declarator)
1613  [TokenizerActor(self.tokenData_, TokenizerData::DECLARATOR)]
1614  ;
1615 
1616  // left recursion --> right recursion
1617  // direct_declarator
1618  // = IDENTIFIER
1619  // | LEFT_PAREN >> declarator >> RIGHT_PAREN
1620  // | direct_declarator >>
1621  // (
1622  // LEFT_BRACKET >> !constant_expression >> RIGHT_BRACKET
1623  // | LEFT_PAREN >>
1624  // (
1625  // parameter_type_list >> RIGHT_PAREN
1626  // | identifier_list >> RIGHT_PAREN
1627  // | RIGHT_PAREN
1628  // )
1629  // )
1630  // ;
1631  direct_declarator =
1632  ((IDENTIFIER
1633  | LEFT_PAREN >> declarator >> RIGHT_PAREN) >>
1634  direct_declarator_helper)
1635  ;
1636 
1637  direct_declarator_helper =
1638  ((LEFT_BRACKET >> !constant_expression >> RIGHT_BRACKET
1639  | LEFT_PAREN >>
1640  ! (parameter_type_list
1641  | identifier_list) >>
1642  RIGHT_PAREN) >>
1643  direct_declarator_helper)
1644  [TokenizerActor(self.tokenData_,
1646  | epsilon_p
1647  ;
1648 
1649  pointer =
1650  (STAR >> !(type_qualifier_list || pointer))
1651  [TokenizerActor(self.tokenData_,
1653  ;
1654 
1655  type_qualifier_list =
1656  +type_qualifier
1657  ;
1658 
1659  parameter_type_list =
1660  (parameter_list >> !(COMMA >> ELLIPSIS))
1661  [TokenizerActor(self.tokenData_,
1663  ;
1664 
1665  parameter_list =
1666  (parameter_declaration >> *(COMMA >> parameter_declaration))
1667  [TokenizerActor(self.tokenData_,
1669  ;
1670 
1671  parameter_declaration =
1672  (declaration_specifiers >>
1673  !(declarator | abstract_declarator))
1674  [TokenizerActor(self.tokenData_,
1676  ;
1677 
1678  identifier_list =
1679  (IDENTIFIER >> *(COMMA >> IDENTIFIER))
1680  [TokenizerActor(self.tokenData_,
1682  ;
1683 
1684  type_name =
1685  (specifier_qualifier_list >> !abstract_declarator)
1686  [TokenizerActor(self.tokenData_,
1688  ;
1689 
1690  abstract_declarator =
1691  (pointer || direct_abstract_declarator)
1692  [TokenizerActor(self.tokenData_,
1694  ;
1695 
1696  // left recursion --> right recursion
1697  // direct_abstract_declarator
1698  // = LEFT_PAREN >>
1699  // (
1700  // abstract_declarator >> RIGHT_PAREN
1701  // | !parameter_type_list >> RIGHT_PAREN
1702  // )
1703  // | LEFT_BRACKET >> !constant_expression >> RIGHT_BRACKET
1704  // | direct_abstract_declarator >>
1705  // (
1706  // LEFT_BRACKET >> !constant_expression >> RIGHT_BRACKET
1707  // | LEFT_PAREN >> !parameter_type_list >> RIGHT_PAREN
1708  // )
1709  // ;
1710  direct_abstract_declarator =
1711  ((LEFT_PAREN >>
1712 
1713  (abstract_declarator >> RIGHT_PAREN
1714  | !parameter_type_list >> RIGHT_PAREN)
1715 
1716  | LEFT_BRACKET >> !constant_expression >> RIGHT_BRACKET) >>
1717 
1718  direct_abstract_declarator_helper)
1719  ;
1720 
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)
1725  [TokenizerActor(self.tokenData_,
1727  | epsilon_p
1728  ;
1729 
1730  initializer =
1731  (assignment_expression
1732  | LEFT_BRACE >> initializer_list >> !COMMA >> RIGHT_BRACE)
1733  [TokenizerActor(self.tokenData_,
1735  ;
1736 
1737  initializer_list =
1738  (initializer >> *(COMMA >> initializer))
1739  [TokenizerActor(self.tokenData_,
1741  ;
1742 
1743  statement =
1744  (labeled_statement
1745  | compound_statement
1746  | expression_statement
1747  | selection_statement
1748  | iteration_statement
1749  | jump_statement)
1750  [TokenizerActor(self.tokenData_,
1752 
1753  ;
1754 
1755  labeled_statement =
1756  (IDENTIFIER >> COLON >> statement
1757  | CASE >> constant_expression >> COLON >> statement
1758  | DEFAULT >> COLON >> statement)
1759  [TokenizerActor(self.tokenData_,
1761  ;
1762 
1763  compound_statement =
1764  (LEFT_BRACE >>
1765  !(declaration_list || statement_list) >>
1766  RIGHT_BRACE)
1767  [TokenizerActor(self.tokenData_,
1769  ;
1770 
1771  declaration_list = (+declaration)
1772  ;
1773 
1774  statement_list =
1775  (+statement)
1776  [TokenizerActor(self.tokenData_,
1778  ;
1779 
1780  expression_statement =
1781  (!expression >> SEMICOLON)
1782  [TokenizerActor(self.tokenData_,
1784  ;
1785 
1786  selection_statement =
1787  (IF >> LEFT_PAREN >> expression >> RIGHT_PAREN >>
1788  statement >> !(ELSE >> statement)
1789 
1790  | SWITCH >> LEFT_PAREN >> expression >> RIGHT_PAREN >>
1791  statement)
1792  [TokenizerActor(self.tokenData_,
1794  ;
1795 
1796  iteration_statement =
1797  (WHILE >>
1798  LEFT_PAREN >> expression >> RIGHT_PAREN >> statement
1799 
1800  | DO >> statement >> WHILE >>
1801  LEFT_PAREN >> expression >>
1802  RIGHT_PAREN >> SEMICOLON
1803 
1804  | FOR >> LEFT_PAREN >>
1805  expression_statement >>
1806  expression_statement >>
1807  !expression >> RIGHT_PAREN >> statement)
1808  [TokenizerActor(self.tokenData_,
1810  ;
1811 
1812  jump_statement =
1813  (GOTO >> IDENTIFIER >> SEMICOLON
1814  | CONTINUE >> SEMICOLON
1815  | BREAK >> SEMICOLON
1816  | RETURN >> !expression >> SEMICOLON)
1817  [TokenizerActor(self.tokenData_,
1819 
1820  ;
1821 
1822  function_definition =
1823  (!declaration_specifiers >>
1824  declarator >>
1825  !declaration_list >>
1826  compound_statement)
1827  [TokenizerActor(self.tokenData_,
1829  ;
1830 
1831  external_declaration =
1832  (function_definition | declaration)
1833  [TokenizerActor(self.tokenData_,
1835  ;
1836 
1837  // Original..
1838  // parser start symbol
1839  // translation_unit = *external_declaration ;
1840  //
1841 
1842  // We are only interested about expressions ended with semicolon
1843  translation_unit = *(expression_statement|declaration_list)
1844  ;
1845  }
1846 
1847  // keywords
1848  symbols<> keywords;
1849 
1850  // operators
1851  strlit<>
1852  ELLIPSIS, RIGHT_ASSIGN, LEFT_ASSIGN, ADD_ASSIGN, SUB_ASSIGN,
1853  MUL_ASSIGN, DIV_ASSIGN, MOD_ASSIGN, AND_ASSIGN, XOR_ASSIGN,
1854  OR_ASSIGN, RIGHT_OP, LEFT_OP, INC_OP, DEC_OP, PTR_OP, AND_OP,
1855  OR_OP, LE_OP, GE_OP, EQ_OP, NE_OP;
1856 // chit<>
1857  strlit<>
1858  SEMICOLON, COMMA, COLON, ASSIGN, LEFT_PAREN, RIGHT_PAREN,
1859  DOT, ADDROF, BANG, TILDE, MINUS, PLUS, STAR, SLASH, PERCENT,
1860  LT_OP, GT_OP, XOR, OR, QUEST;
1861 
1862  rule<ScannerT>
1863  LEFT_BRACE, RIGHT_BRACE, LEFT_BRACKET, RIGHT_BRACKET;
1864 
1865  // terminals
1866  rule<ScannerT>
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,
1871  STRING_LITERAL_PART, STRING_LITERAL, INT_CONSTANT_HEX, INT_CONSTANT,
1872  INT_CONSTANT_OCT, INT_CONSTANT_DEC, INT_CONSTANT_CHAR,
1873  FLOAT_CONSTANT,FLOAT_CONSTANT_1, FLOAT_CONSTANT_2, FLOAT_CONSTANT_3,
1875 
1876  // nonterminals
1877  rule<ScannerT>
1878  primary_expression, postfix_expression, postfix_expression_helper,
1879  argument_expression_list, unary_expression, unary_operator,
1881  multiplicative_expression, multiplicative_expression_helper,
1882  additive_expression, additive_expression_helper,
1883  shift_expression, shift_expression_helper,
1884  relational_expression, relational_expression_helper,
1885  equality_expression, equality_expression_helper,
1886  and_expression, and_expression_helper,
1887  exclusive_or_expression, exclusive_or_expression_helper,
1888  inclusive_or_expression, inclusive_or_expression_helper,
1889  logical_and_expression, logical_and_expression_helper,
1890  logical_or_expression, logical_or_expression_helper,
1891  conditional_expression, conditional_expression_helper,
1892  assignment_expression, assignment_operator,
1893  expression, expression_helper, constant_expression, declaration,
1894  declaration_specifiers, init_declarator_list, init_declarator,
1895  storage_class_specifier, type_specifier, struct_or_union_specifier,
1896  struct_or_union, struct_declaration_list, struct_declaration,
1897  specifier_qualifier_list, struct_declarator_list,
1898  struct_declarator, enum_specifier, enumerator_list, enumerator,
1899  type_qualifier, declarator,
1900  direct_declarator, direct_declarator_helper, pointer,
1901  type_qualifier_list, parameter_type_list, parameter_list,
1902  parameter_declaration, identifier_list, type_name,
1904  direct_abstract_declarator, direct_abstract_declarator_helper,
1905  initializer, initializer_list, statement, labeled_statement,
1906  compound_statement, declaration_list, statement_list,
1907  expression_statement, selection_statement, iteration_statement,
1908  jump_statement, translation_unit, external_declaration,
1909  // function_definition, last_comment_spirit_bugfix;
1910  function_definition, last_comment_spirit_bugfix;
1911 
1912  rule<ScannerT> const&
1913  start() const { return translation_unit; }
1914  };
1915 
1916 public:
1918 };
1919 
1920 #endif
TokenizerData::Token::isTildeOperator
bool isTildeOperator() const
Definition: OperationDAGLanguageParser.hh:330
TokenizerData::TokenTreeNode::intValue
long intValue() const
Definition: OperationDAGLanguageParser.hh:460
TokenizerData::Token::isUnaryExpression
bool isUnaryExpression() const
Definition: OperationDAGLanguageParser.hh:325
TokenizerData::EXPRESSION_STATEMENT
@ EXPRESSION_STATEMENT
Definition: OperationDAGLanguageParser.hh:214
OperationDAGLanguageGrammar::definition::INT_CONSTANT_OCT
rule< ScannerT > INT_CONSTANT_OCT
Definition: OperationDAGLanguageParser.hh:1872
TokenizerData::Token::isIdentifier
bool isIdentifier() const
Definition: OperationDAGLanguageParser.hh:321
TokenizerData::IDENTIFIER_LIST
@ IDENTIFIER_LIST
Definition: OperationDAGLanguageParser.hh:205
TokenizerActor::TokenizerActor
TokenizerActor(TokenizerData &data, TokenizerData::OperationID id)
Definition: OperationDAGLanguageParser.hh:717
skip_grammar::definition::definition
definition(skip_grammar const &self)
Definition: OperationDAGLanguageParser.hh:756
TokenizerData::DECLARATION_SPECIFIERS
@ DECLARATION_SPECIFIERS
Definition: OperationDAGLanguageParser.hh:185
POP_CLANG_DIAGS
#define POP_CLANG_DIAGS
Definition: CompilerWarnings.hh:96
OperationDAGLanguageGrammar::tokenData_
TokenizerData tokenData_
Definition: OperationDAGLanguageParser.hh:1917
OperationDAGLanguageGrammar::definition::additive_expression_helper
rule< ScannerT > additive_expression_helper
Definition: OperationDAGLanguageParser.hh:1882
TokenizerData::UNARY_MINUS
@ UNARY_MINUS
Definition: OperationDAGLanguageParser.hh:164
OperationDAGLanguageGrammar::definition::abstract_declarator
rule< ScannerT > abstract_declarator
Definition: OperationDAGLanguageParser.hh:1903
TokenizerData::LABELED_STATEMENT
@ LABELED_STATEMENT
Definition: OperationDAGLanguageParser.hh:211
TokenizerData::TokenTreeNode::isAssignment
bool isAssignment() const
Definition: OperationDAGLanguageParser.hh:427
TokenizerData::EQUALITY_EXPRESSION
@ EQUALITY_EXPRESSION
Definition: OperationDAGLanguageParser.hh:173
TokenizerData::STRUCT_OR_UNION_SPECIFIER
@ STRUCT_OR_UNION_SPECIFIER
Definition: OperationDAGLanguageParser.hh:189
TokenizerData::LOGICAL_OR_EXPRESSION
@ LOGICAL_OR_EXPRESSION
Definition: OperationDAGLanguageParser.hh:178
skip_grammar::definition::skip
rule< ScannerT > skip
Definition: OperationDAGLanguageParser.hh:776
TokenizerData::Token::isBangOperator
bool isBangOperator() const
Definition: OperationDAGLanguageParser.hh:331
TokenizerData::PARAMETER_DECLARATION
@ PARAMETER_DECLARATION
Definition: OperationDAGLanguageParser.hh:204
OperationDAGLanguageGrammar::definition
Definition: OperationDAGLanguageParser.hh:791
TokenizerData::EXPRESSION
@ EXPRESSION
Definition: OperationDAGLanguageParser.hh:182
TokenizerData::STORAGE_CLASS_SPECIFIER
@ STORAGE_CLASS_SPECIFIER
Definition: OperationDAGLanguageParser.hh:187
OperationDAGLanguageGrammar::definition::TILDE
strlit TILDE
Definition: OperationDAGLanguageParser.hh:1859
TokenizerData::Token::isPlusOperator_
bool isPlusOperator_
Definition: OperationDAGLanguageParser.hh:378
OperationDAGLanguageGrammar::definition::cast_expression
rule< ScannerT > cast_expression
Definition: OperationDAGLanguageParser.hh:1880
OperationDAGLanguageGrammar::definition::RIGHT_BRACKET
rule< ScannerT > RIGHT_BRACKET
Definition: OperationDAGLanguageParser.hh:1863
TokenizerData::OperationID
OperationID
Definition: OperationDAGLanguageParser.hh:154
TokenizerData::FUNCTION_DEFINITION
@ FUNCTION_DEFINITION
Definition: OperationDAGLanguageParser.hh:218
TokenizerData::root
TokenTreeNode root
Definition: OperationDAGLanguageParser.hh:708
TokenizerData::PARAMETER_LIST
@ PARAMETER_LIST
Definition: OperationDAGLanguageParser.hh:203
TokenizerData::Token::isFloatLiteral_
bool isFloatLiteral_
Definition: OperationDAGLanguageParser.hh:374
TokenizerData::STATEMENT
@ STATEMENT
Definition: OperationDAGLanguageParser.hh:210
TokenizerData::Token::isAsteriskOperator
bool isAsteriskOperator() const
Definition: OperationDAGLanguageParser.hh:327
TokenizerData::Token::isPlusOperator
bool isPlusOperator() const
Definition: OperationDAGLanguageParser.hh:328
TokenizerData::Token::isIntegerLiteral_
bool isIntegerLiteral_
Definition: OperationDAGLanguageParser.hh:373
OperationDAGLanguageGrammar::definition::relational_expression_helper
rule< ScannerT > relational_expression_helper
Definition: OperationDAGLanguageParser.hh:1884
skip_grammar
Definition: OperationDAGLanguageParser.hh:751
TokenizerData::Token::isIntegerLiteral
bool isIntegerLiteral() const
Definition: OperationDAGLanguageParser.hh:323
OperationDAGLanguageGrammar::definition::exclusive_or_expression_helper
rule< ScannerT > exclusive_or_expression_helper
Definition: OperationDAGLanguageParser.hh:1887
OperationDAGLanguageGrammar::definition::selection_statement
rule< ScannerT > selection_statement
Definition: OperationDAGLanguageParser.hh:1907
IGNORE_CLANG_WARNING
#define IGNORE_CLANG_WARNING(X)
Definition: CompilerWarnings.hh:85
OperationDAGLanguageGrammar::definition::keywords
symbols keywords
Definition: OperationDAGLanguageParser.hh:1848
TokenizerData::CONSTANT_EXPRESSION
@ CONSTANT_EXPRESSION
Definition: OperationDAGLanguageParser.hh:183
TokenizerData::INIT_DECLARATOR
@ INIT_DECLARATOR
Definition: OperationDAGLanguageParser.hh:186
OperationDAGLanguageGrammar::definition::logical_and_expression_helper
rule< ScannerT > logical_and_expression_helper
Definition: OperationDAGLanguageParser.hh:1889
TokenizerData::UNARY_BANG
@ UNARY_BANG
Definition: OperationDAGLanguageParser.hh:166
OperationDAGLanguageGrammar::definition::struct_declarator
rule< ScannerT > struct_declarator
Definition: OperationDAGLanguageParser.hh:1898
OperationDAGLanguageGrammar::definition::translation_unit
rule< ScannerT > translation_unit
Definition: OperationDAGLanguageParser.hh:1908
TokenizerData::STRUCT_DECLARATION
@ STRUCT_DECLARATION
Definition: OperationDAGLanguageParser.hh:191
TokenizerData::STATEMENT_LIST
@ STATEMENT_LIST
Definition: OperationDAGLanguageParser.hh:213
OperationDAGLanguageGrammar::definition::multiplicative_expression_helper
rule< ScannerT > multiplicative_expression_helper
Definition: OperationDAGLanguageParser.hh:1881
OperationDAGLanguageGrammar::definition::statement
rule< ScannerT > statement
Definition: OperationDAGLanguageParser.hh:1905
TokenizerData::SHIFT_EXPRESSION
@ SHIFT_EXPRESSION
Definition: OperationDAGLanguageParser.hh:171
OperationDAGLanguageGrammar::definition::RIGHT_OP
strlit RIGHT_OP
Definition: OperationDAGLanguageParser.hh:1854
TokenizerData::Token::isFloatLiteral
bool isFloatLiteral() const
Definition: OperationDAGLanguageParser.hh:324
TokenizerData::Token::isAddrofOperator_
bool isAddrofOperator_
Definition: OperationDAGLanguageParser.hh:376
TokenizerData::TokenTreeNode::isInteger
bool isInteger() const
Definition: OperationDAGLanguageParser.hh:442
TokenizerData::Token::end_
unsigned long end_
Definition: OperationDAGLanguageParser.hh:367
TokenizerData::DIRECT_ABSTRACT_DECLARATOR
@ DIRECT_ABSTRACT_DECLARATOR
Definition: OperationDAGLanguageParser.hh:208
OperationDAGLanguageGrammar::definition::type_specifier
rule< ScannerT > type_specifier
Definition: OperationDAGLanguageParser.hh:1895
OperationDAGLanguageGrammar::definition::REGISTER
rule< ScannerT > REGISTER
Definition: OperationDAGLanguageParser.hh:1868
TokenizerData::PRIMARY_EXPRESSION
@ PRIMARY_EXPRESSION
Definition: OperationDAGLanguageParser.hh:159
TokenizerData::RELATIONAL_EXPRESSION
@ RELATIONAL_EXPRESSION
Definition: OperationDAGLanguageParser.hh:172
TokenizerData::UNARY_PLUS
@ UNARY_PLUS
Definition: OperationDAGLanguageParser.hh:163
TokenizerData::TokenContainerType
std::map< std::pair< const char *, const char * >, Token * > TokenContainerType
Definition: OperationDAGLanguageParser.hh:705
TokenizerData::EXCLUSIVE_EXPRESSION
@ EXCLUSIVE_EXPRESSION
Definition: OperationDAGLanguageParser.hh:175
TokenizerData::Token::strValue_
std::string strValue_
Definition: OperationDAGLanguageParser.hh:368
OperationDAGLanguageGrammar::definition::type_qualifier_list
rule< ScannerT > type_qualifier_list
Definition: OperationDAGLanguageParser.hh:1901
TokenizerData::Token::isStringLiteral_
bool isStringLiteral_
Definition: OperationDAGLanguageParser.hh:372
OperationDAGLanguageGrammar::definition::expression_helper
rule< ScannerT > expression_helper
Definition: OperationDAGLanguageParser.hh:1893
TokenizerData::TokenTreeNode::TokenTreeNode
TokenTreeNode()
Definition: OperationDAGLanguageParser.hh:399
TokenizerData::STRUCT_DECLARATOR
@ STRUCT_DECLARATOR
Definition: OperationDAGLanguageParser.hh:192
TokenizerData::Token::isAddrofOperator
bool isAddrofOperator() const
Definition: OperationDAGLanguageParser.hh:326
TokenizerData::~TokenizerData
~TokenizerData()
Definition: OperationDAGLanguageParser.hh:618
TokenizerData::Token::Token
Token(unsigned long start, unsigned long end, std::string &strValue)
Definition: OperationDAGLanguageParser.hh:306
TokenizerData::TokenTreeNode::addToTokenTree
void addToTokenTree(Token &token)
Definition: OperationDAGLanguageParser.hh:485
OperationDAGLanguageGrammar::definition::unary_operator
rule< ScannerT > unary_operator
Definition: OperationDAGLanguageParser.hh:1879
TokenizerData::TYPE_SPECIFIER
@ TYPE_SPECIFIER
Definition: OperationDAGLanguageParser.hh:188
TokenizerData::FLOAT_LITERAL
@ FLOAT_LITERAL
Definition: OperationDAGLanguageParser.hh:158
TokenizerData::TokenTreeNode::data_
Token * data_
Token of token tree node.
Definition: OperationDAGLanguageParser.hh:607
TokenizerData::CONST_QUALIFER
@ CONST_QUALIFER
Definition: OperationDAGLanguageParser.hh:195
OperationDAGLanguageGrammar::definition::init_declarator_list
rule< ScannerT > init_declarator_list
Definition: OperationDAGLanguageParser.hh:1894
TokenizerData::INITIALIZER
@ INITIALIZER
Definition: OperationDAGLanguageParser.hh:199
TokenizerData::idString
static std::string idString(OperationID id)
Definition: OperationDAGLanguageParser.hh:229
assert
#define assert(condition)
Definition: Application.hh:86
TokenizerData::COMPOUND_STATEMENT
@ COMPOUND_STATEMENT
Definition: OperationDAGLanguageParser.hh:212
TokenizerData::TokenTreeNode::leaf
TokenTreeNode & leaf(int index) const
Definition: OperationDAGLanguageParser.hh:513
OperationDAGLanguageGrammar::definition::direct_abstract_declarator_helper
rule< ScannerT > direct_abstract_declarator_helper
Definition: OperationDAGLanguageParser.hh:1904
TokenizerData::TYPE_QUALIFER
@ TYPE_QUALIFER
Definition: OperationDAGLanguageParser.hh:197
TokenizerData::VOLATILE_QUALIFER
@ VOLATILE_QUALIFER
Definition: OperationDAGLanguageParser.hh:196
TokenizerData::UNARY_EXPRESSION
@ UNARY_EXPRESSION
Definition: OperationDAGLanguageParser.hh:160
skip_grammar::strippedParts
std::vector< std::pair< const char *, const char * > > strippedParts
Definition: OperationDAGLanguageParser.hh:783
OperationDAGLanguageGrammar::definition::and_expression_helper
rule< ScannerT > and_expression_helper
Definition: OperationDAGLanguageParser.hh:1886
TokenizerData::AND_EXPRESSION
@ AND_EXPRESSION
Definition: OperationDAGLanguageParser.hh:174
TokenizerData::DECLARATION
@ DECLARATION
Definition: OperationDAGLanguageParser.hh:184
TokenizerData::Token
Definition: OperationDAGLanguageParser.hh:304
OperationDAGLanguageGrammar
Definition: OperationDAGLanguageParser.hh:787
Conversion.hh
skip_grammar::lastStrip
std::pair< const char *, const char * > lastStrip
Definition: OperationDAGLanguageParser.hh:784
OperationDAGLanguageGrammar::definition::DOUBLE
rule< ScannerT > DOUBLE
Definition: OperationDAGLanguageParser.hh:1867
TokenizerActor::data_
TokenizerData & data_
Definition: OperationDAGLanguageParser.hh:720
TokenizerData::Token::isUnaryExpression_
bool isUnaryExpression_
Definition: OperationDAGLanguageParser.hh:375
TokenizerData::UNARY_TILDE
@ UNARY_TILDE
Definition: OperationDAGLanguageParser.hh:165
TokenizerData::TokenTreeNode
Definition: OperationDAGLanguageParser.hh:397
TokenizerData::Token::isPostfixExpression
bool isPostfixExpression() const
Definition: OperationDAGLanguageParser.hh:345
TokenizerData::ABSTRACT_DECLARATOR
@ ABSTRACT_DECLARATOR
Definition: OperationDAGLanguageParser.hh:207
TokenizerData::STRUCT_OR_UNION
@ STRUCT_OR_UNION
Definition: OperationDAGLanguageParser.hh:190
TokenizerData::TokenTreeNode::leafCount
int leafCount() const
Definition: OperationDAGLanguageParser.hh:503
TokenizerData::DECLARATOR
@ DECLARATOR
Definition: OperationDAGLanguageParser.hh:198
OperationDAGLanguageGrammar::definition::OR_OP
strlit OR_OP
Definition: OperationDAGLanguageParser.hh:1855
TokenizerData::parsedTokens_
TokenContainerType parsedTokens_
Definition: OperationDAGLanguageParser.hh:707
OperationDAGLanguageGrammar::definition::primary_expression
rule< ScannerT > primary_expression
Definition: OperationDAGLanguageParser.hh:1878
TokenizerData::Token::isTildeOperator_
bool isTildeOperator_
Definition: OperationDAGLanguageParser.hh:380
TokenizerData::UNARY_ADDROF
@ UNARY_ADDROF
Definition: OperationDAGLanguageParser.hh:161
SetStripPairActor::operator()
void operator()(const char *start, const char *end) const
Definition: OperationDAGLanguageParser.hh:742
OperationDAGLanguageGrammar::definition::last_comment_spirit_bugfix
rule< ScannerT > last_comment_spirit_bugfix
Definition: OperationDAGLanguageParser.hh:1910
skip_grammar::definition
Definition: OperationDAGLanguageParser.hh:754
TokenizerData::POSTFIX_EXPRESSION
@ POSTFIX_EXPRESSION
Definition: OperationDAGLanguageParser.hh:167
TokenizerData::JUMP_STATEMENT
@ JUMP_STATEMENT
Definition: OperationDAGLanguageParser.hh:217
TokenizerData::TokenTreeNode::toStr
std::string toStr() const
Definition: OperationDAGLanguageParser.hh:524
TokenizerData::EXTERNAL_DECLARATION
@ EXTERNAL_DECLARATION
Definition: OperationDAGLanguageParser.hh:219
TokenizerData::TokenTreeNode::isFunctionCall
bool isFunctionCall() const
Definition: OperationDAGLanguageParser.hh:410
OperationDAGLanguageGrammar::definition::FLOAT_CONSTANT_3
rule< ScannerT > FLOAT_CONSTANT_3
Definition: OperationDAGLanguageParser.hh:1873
TokenizerActor::id_
TokenizerData::OperationID id_
Definition: OperationDAGLanguageParser.hh:721
TokenizerData::Token::start_
unsigned long start_
Definition: OperationDAGLanguageParser.hh:366
TokenizerData::CAST_EXPRESSION
@ CAST_EXPRESSION
Definition: OperationDAGLanguageParser.hh:168
TokenizerData::showTokenizedSource
void showTokenizedSource()
Definition: OperationDAGLanguageParser.hh:675
TokenizerData::CONDITIONAL_EXPRESSION
@ CONDITIONAL_EXPRESSION
Definition: OperationDAGLanguageParser.hh:179
OperationDAGLanguageGrammar::definition::XOR
strlit XOR
Definition: OperationDAGLanguageParser.hh:1860
INT
@ INT
Definition: ExplorerPluginParameter.hh:40
TokenizerData::TYPE_NAME
@ TYPE_NAME
Definition: OperationDAGLanguageParser.hh:206
TokenizerData::INITIALIZER_LIST
@ INITIALIZER_LIST
Definition: OperationDAGLanguageParser.hh:209
TokenizerData::Token::isAsteriskOperator_
bool isAsteriskOperator_
Definition: OperationDAGLanguageParser.hh:377
TokenizerData::TokenTreeNode::addToTokenTree
static void addToTokenTree(TokenTreeNode *currNode, TokenTreeNode *newToken)
Definition: OperationDAGLanguageParser.hh:561
TokenizerData::SELECTION_STATEMENT
@ SELECTION_STATEMENT
Definition: OperationDAGLanguageParser.hh:215
LONG
#define LONG(OPERAND)
Definition: OSAL.hh:314
OperationDAGLanguageGrammar::definition::statement_list
rule< ScannerT > statement_list
Definition: OperationDAGLanguageParser.hh:1906
TokenizerData::Token::stringValue
std::string stringValue() const
Definition: OperationDAGLanguageParser.hh:341
OperationDAGLanguageGrammar::definition::WHILE
rule< ScannerT > WHILE
Definition: OperationDAGLanguageParser.hh:1870
TokenizerData::ENUMERATOR
@ ENUMERATOR
Definition: OperationDAGLanguageParser.hh:194
OperationDAGLanguageGrammar::definition::TYPEDEF
rule< ScannerT > TYPEDEF
Definition: OperationDAGLanguageParser.hh:1869
OperationDAGLanguageGrammar::definition::inclusive_or_expression_helper
rule< ScannerT > inclusive_or_expression_helper
Definition: OperationDAGLanguageParser.hh:1888
OperationDAGLanguageGrammar::definition::struct_or_union
rule< ScannerT > struct_or_union
Definition: OperationDAGLanguageParser.hh:1896
OperationDAGLanguageGrammar::definition::start
rule< ScannerT > const & start() const
Definition: OperationDAGLanguageParser.hh:1913
OperationDAGLanguageGrammar::definition::STRING_LITERAL_PART
rule< ScannerT > STRING_LITERAL_PART
Definition: OperationDAGLanguageParser.hh:1871
TokenizerData::Token::isBangOperator_
bool isBangOperator_
Definition: OperationDAGLanguageParser.hh:381
TokenizerData::INCLUSIVE_EXPRESSION
@ INCLUSIVE_EXPRESSION
Definition: OperationDAGLanguageParser.hh:176
OperationDAGLanguageGrammar::definition::type_name
rule< ScannerT > type_name
Definition: OperationDAGLanguageParser.hh:1902
IGNORE_COMPILER_WARNING
#define IGNORE_COMPILER_WARNING(X)
Definition: CompilerWarnings.hh:51
OperationDAGLanguageGrammar::definition::struct_declarator_list
rule< ScannerT > struct_declarator_list
Definition: OperationDAGLanguageParser.hh:1897
TokenizerData::MULTIPLICATIVE_EXPRESSION
@ MULTIPLICATIVE_EXPRESSION
Definition: OperationDAGLanguageParser.hh:169
TokenizerData::Token::isIdentifier_
bool isIdentifier_
Definition: OperationDAGLanguageParser.hh:371
false
find Finds info of the inner loops in the false
Definition: InnerLoopFinder.cc:81
OperationDAGLanguageGrammar::definition::conditional_expression_helper
rule< ScannerT > conditional_expression_helper
Definition: OperationDAGLanguageParser.hh:1891
OperationDAGLanguageGrammar::definition::shift_expression_helper
rule< ScannerT > shift_expression_helper
Definition: OperationDAGLanguageParser.hh:1883
TokenizerData::Token::setProperty
void setProperty(OperationID id)
Definition: OperationDAGLanguageParser.hh:347
OperationDAGLanguageGrammar::definition::pointer
rule< ScannerT > pointer
Definition: OperationDAGLanguageParser.hh:1900
TokenizerData
Definition: OperationDAGLanguageParser.hh:148
TokenizerActor
Definition: OperationDAGLanguageParser.hh:715
TokenizerData::POINTER
@ POINTER
Definition: OperationDAGLanguageParser.hh:201
TokenizerData::DIRECT_DECLARATOR
@ DIRECT_DECLARATOR
Definition: OperationDAGLanguageParser.hh:200
TokenizerData::Token::isMinusOperator
bool isMinusOperator() const
Definition: OperationDAGLanguageParser.hh:329
TokenizerData::ENUM_SPECIFIER
@ ENUM_SPECIFIER
Definition: OperationDAGLanguageParser.hh:193
POP_COMPILER_DIAGS
#define POP_COMPILER_DIAGS
Definition: CompilerWarnings.hh:68
TokenizerData::TokenizerData
TokenizerData()
Definition: OperationDAGLanguageParser.hh:613
TokenizerData::Token::isStringLiteral
bool isStringLiteral() const
Definition: OperationDAGLanguageParser.hh:322
TokenizerData::LOGICAL_AND_EXPRESSION
@ LOGICAL_AND_EXPRESSION
Definition: OperationDAGLanguageParser.hh:177
TokenizerData::ASSIGNMENT_EXPRESSION
@ ASSIGNMENT_EXPRESSION
Definition: OperationDAGLanguageParser.hh:180
SetStripPairActor::thePair_
std::pair< const char *, const char * > & thePair_
Definition: OperationDAGLanguageParser.hh:740
OperationDAGLanguageGrammar::definition::SEMICOLON
strlit SEMICOLON
Definition: OperationDAGLanguageParser.hh:1858
OperationDAGLanguageGrammar::definition::type_qualifier
rule< ScannerT > type_qualifier
Definition: OperationDAGLanguageParser.hh:1899
TokenizerData::STRING_LITERAL
@ STRING_LITERAL
Definition: OperationDAGLanguageParser.hh:156
TokenizerData::Token::intValue
long intValue() const
Definition: OperationDAGLanguageParser.hh:333
skip_grammar::definition::start
rule< ScannerT > const & start() const
Definition: OperationDAGLanguageParser.hh:779
Conversion::toLong
static SLongWord toLong(const T &source)
TokenizerData::ITERATION_STATEMENT
@ ITERATION_STATEMENT
Definition: OperationDAGLanguageParser.hh:216
TokenizerData::Token::type_
OperationID type_
Definition: OperationDAGLanguageParser.hh:369
SetStripPairActor
Definition: OperationDAGLanguageParser.hh:735
TokenizerData::PARAMETER_TYPE_LIST
@ PARAMETER_TYPE_LIST
Definition: OperationDAGLanguageParser.hh:202
OperationDAGLanguageGrammar::definition::assignment_operator
rule< ScannerT > assignment_operator
Definition: OperationDAGLanguageParser.hh:1892
TokenizerData::tokenTree
const TokenTreeNode * tokenTree() const
Definition: OperationDAGLanguageParser.hh:699
TokenizerActor::operator()
void operator()(const char *start, const char *end) const
Definition: OperationDAGLanguageParser.hh:723
TokenizerData::INTEGER_LITERAL
@ INTEGER_LITERAL
Definition: OperationDAGLanguageParser.hh:157
TokenizerData::Token::isMinusOperator_
bool isMinusOperator_
Definition: OperationDAGLanguageParser.hh:379
OperationDAGLanguageGrammar::definition::SUB_ASSIGN
strlit SUB_ASSIGN
Definition: OperationDAGLanguageParser.hh:1852
OperationDAGLanguageGrammar::definition::logical_or_expression_helper
rule< ScannerT > logical_or_expression_helper
Definition: OperationDAGLanguageParser.hh:1890
OperationDAGLanguageGrammar::definition::CONSTANT
rule< ScannerT > CONSTANT
Definition: OperationDAGLanguageParser.hh:1874
TokenizerData::ASSIGNMENT_OPERATOR
@ ASSIGNMENT_OPERATOR
Definition: OperationDAGLanguageParser.hh:181
TokenizerData::TokenTreeNode::token
const Token & token() const
Definition: OperationDAGLanguageParser.hh:494
CompilerWarnings.hh
OperationDAGLanguageGrammar::definition::definition
definition(OperationDAGLanguageGrammar const &self)
Definition: OperationDAGLanguageParser.hh:792
TokenizerData::IDENTIFIER
@ IDENTIFIER
Definition: OperationDAGLanguageParser.hh:155
TokenizerData::TokenTreeNode::leafs_
std::vector< TokenTreeNode * > leafs_
Leafs of this node.
Definition: OperationDAGLanguageParser.hh:610
OperationDAGLanguageGrammar::definition::XOR_ASSIGN
strlit XOR_ASSIGN
Definition: OperationDAGLanguageParser.hh:1853
TokenizerData::TokenTreeNode::TokenTreeNode
TokenTreeNode(Token &token)
Definition: OperationDAGLanguageParser.hh:400
TokenizerData::UNARY_STAR
@ UNARY_STAR
Definition: OperationDAGLanguageParser.hh:162
TokenizerData::addToken
void addToken(const char *start, const char *end, OperationID id, std::string strVal)
Definition: OperationDAGLanguageParser.hh:636
TokenizerData::ADDITIVE_EXPRESSION
@ ADDITIVE_EXPRESSION
Definition: OperationDAGLanguageParser.hh:170
OperationDAGLanguageGrammar::definition::equality_expression_helper
rule< ScannerT > equality_expression_helper
Definition: OperationDAGLanguageParser.hh:1885
SetStripPairActor::SetStripPairActor
SetStripPairActor(std::pair< const char *, const char * > &aPair)
Definition: OperationDAGLanguageParser.hh:737