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