From 5dcf449afd7755d0ab88e55638fcbd8bc98deded Mon Sep 17 00:00:00 2001 From: Roberto Raggi Date: Thu, 12 Nov 2009 17:35:48 +0100 Subject: Initial work on the pattern matcher for AST nodes. --- src/shared/cplusplus/AST.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/shared/cplusplus/AST.cpp') 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 @@ -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; -- cgit v1.2.1