summaryrefslogtreecommitdiff
path: root/src/shared/cplusplus/AST.cpp
diff options
context:
space:
mode:
authorRoberto Raggi <roberto.raggi@nokia.com>2009-11-12 17:35:48 +0100
committerRoberto Raggi <roberto.raggi@nokia.com>2009-11-12 18:03:05 +0100
commit5dcf449afd7755d0ab88e55638fcbd8bc98deded (patch)
tree2e9a0abdadc4474d5bbf513183ac8818dd2bbcd1 /src/shared/cplusplus/AST.cpp
parentb2f6803329126c7f8f391e97ffd50f26b98064a0 (diff)
downloadqt-creator-5dcf449afd7755d0ab88e55638fcbd8bc98deded.tar.gz
Initial work on the pattern matcher for AST nodes.
Diffstat (limited to 'src/shared/cplusplus/AST.cpp')
-rw-r--r--src/shared/cplusplus/AST.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/shared/cplusplus/AST.cpp b/src/shared/cplusplus/AST.cpp
index 38f3050b00..1e6cae8969 100644
--- a/src/shared/cplusplus/AST.cpp
+++ b/src/shared/cplusplus/AST.cpp
@@ -48,6 +48,7 @@
#include "AST.h"
#include "ASTVisitor.h"
+#include "ASTMatcher.h"
#include "MemoryPool.h"
#include <cassert>
@@ -69,6 +70,22 @@ void AST::accept(ASTVisitor *visitor)
visitor->postVisit(this);
}
+bool AST::match(AST *ast, AST *pattern, ASTMatcher *matcher)
+{
+ if (ast == pattern)
+ return true;
+
+ else if (! ast || ! pattern)
+ return false;
+
+ return ast->match(pattern, matcher);
+}
+
+bool AST::match(AST *pattern, ASTMatcher *matcher)
+{
+ return match0(pattern, matcher);
+}
+
unsigned AttributeSpecifierAST::firstToken() const
{
return attribute_token;