ROSE  0.11.51.0
AstMatching.h
1 #ifndef AST_MATCHING_H
2 #define AST_MATCHING_H
3 
4 /*************************************************************
5  * Author : Markus Schordan *
6  *************************************************************/
7 
8 #include "matcherparser_decls.h"
9 #include "MatchOperation.h"
10 #include "RoseAst.h"
11 #include <list>
12 #include <set>
13 
14 class SgNode;
15 
16 class MatchOperation;
17 
18 class AstMatching {
19  public:
20  AstMatching();
21  ~AstMatching();
22  AstMatching(std::string matchExpression,SgNode* root);
23  MatchResult performMatching(std::string matchExpression, SgNode* root);
24  MatchResult getResult();
25  /* This function is useful when reusing the same matcher object for
26  performing multiple matches. It allows to keep all nodes that
27  have been marked by a previous match using the '#' operator. The
28  subtrees of those nodes are not traversed in the subsequent match
29  either.
30  */
31  void setKeepMarkedLocations(bool keepMarked);
32  /* This function is only for information purposes. It prints the
33  sequence of internal match operations which are performed for a
34  provided match-pattern.
35  */
36  void printMatchOperationsSequence();
37  /* This function is only for information purposes. It prints the
38  set of all marked nodes (marked with the "#' operator).
39  */
40  void printMarkedLocations();
41  bool performSingleMatch(SgNode* node, MatchOperationList* matchOperationSequence);
42  private:
43  void performMatchingOnAst(SgNode* root);
44  void performMatching();
45  void generateMatchOperationsSequence();
46 
47  private:
48  std::string _matchExpression;
49  SgNode* _root;
50  MatchOperationList* _matchOperationsSequence;
51  MatchStatus _status;
52  bool _keepMarkedLocations;
53 };
54 
55 #endif
This class represents the base class for all IR nodes within Sage III.
Definition: Cxx_Grammar.h:9555