diff options
author | Roberto Raggi <roberto.raggi@nokia.com> | 2009-11-12 17:35:48 +0100 |
---|---|---|
committer | Roberto Raggi <roberto.raggi@nokia.com> | 2009-11-12 18:03:05 +0100 |
commit | 5dcf449afd7755d0ab88e55638fcbd8bc98deded (patch) | |
tree | 2e9a0abdadc4474d5bbf513183ac8818dd2bbcd1 /src/shared/cplusplus/AST.cpp | |
parent | b2f6803329126c7f8f391e97ffd50f26b98064a0 (diff) | |
download | qt-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.cpp | 17 |
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; |