summaryrefslogtreecommitdiff
path: root/src/tools/cplusplus
diff options
context:
space:
mode:
authorRoberto Raggi <roberto.raggi@nokia.com>2009-11-13 11:54:22 +0100
committerRoberto Raggi <roberto.raggi@nokia.com>2009-11-13 11:54:22 +0100
commit5644775d2f9a275b6bc0b8081cdb26e8fca29e16 (patch)
treecd7ab53683081e961d4e008479f506709898821b /src/tools/cplusplus
parentf8beeea6ddc258bf19d813caf0fd1bed3457abfd (diff)
downloadqt-creator-5644775d2f9a275b6bc0b8081cdb26e8fca29e16.tar.gz
Also match the identifiers and the token types.
Diffstat (limited to 'src/tools/cplusplus')
-rw-r--r--src/tools/cplusplus/Main.cpp15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/tools/cplusplus/Main.cpp b/src/tools/cplusplus/Main.cpp
index 5169436347..ea2ca82a9d 100644
--- a/src/tools/cplusplus/Main.cpp
+++ b/src/tools/cplusplus/Main.cpp
@@ -387,6 +387,19 @@ public:
<< endl
<< "void ASTMatcher::getTokenEndPosition(unsigned index, unsigned *line, unsigned *column) const" << endl
<< "{ getPosition(tokenAt(index).end(), line, column); }" << endl
+ << endl
+ << "bool ASTMatcher::matchToken(unsigned index, unsigned otherIndex) const" << endl
+ << "{" << endl
+ << " const Token &token = tokenAt(index);" << endl
+ << " const Token &otherToken = tokenAt(otherIndex);" << endl
+ << " if (token.f.kind != otherToken.f.kind)" << endl
+ << " return false;" << endl
+ << " else if (token.is(T_IDENTIFIER)) {" << endl
+ << " if (token.identifier != otherToken.identifier)" << endl
+ << " return false;" << endl
+ << " }" << endl
+ << " return true;" << endl
+ << "}" << endl
<< endl;
accept(ast);
@@ -425,7 +438,7 @@ protected:
if (member->type().isUnsigned() && memberName.endsWith("_token")) {
// nothing to do. The member is a token.
- *out << " if (node->" << memberName << " != pattern->" << memberName << ")" << endl
+ *out << " if (! matchToken(node->" << memberName << ", pattern->" << memberName << "))" << endl
<< " return false;" << endl;
} else if (PointerType *ptrTy = member->type()->asPointerType()) {