diff options
author | zhanyong.wan <zhanyong.wan@8415998a-534a-0410-bf83-d39667b30386> | 2009-06-02 20:41:21 +0000 |
---|---|---|
committer | zhanyong.wan <zhanyong.wan@8415998a-534a-0410-bf83-d39667b30386> | 2009-06-02 20:41:21 +0000 |
commit | c2ad46a5df4414fc2b804c53525f4578f01a3dfe (patch) | |
tree | bf86bd649c23056d841f1198d6c995a5add25ee6 /scripts/generator/cpp/ast.py | |
parent | 9413f2ff615ae1b933580576183d316c4cb6376c (diff) | |
download | googletest-c2ad46a5df4414fc2b804c53525f4578f01a3dfe.tar.gz googletest-c2ad46a5df4414fc2b804c53525f4578f01a3dfe.tar.bz2 googletest-c2ad46a5df4414fc2b804c53525f4578f01a3dfe.zip |
Improves gmock generator and adds a test for it (by Neal Norwitz).
Diffstat (limited to 'scripts/generator/cpp/ast.py')
-rwxr-xr-x | scripts/generator/cpp/ast.py | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/scripts/generator/cpp/ast.py b/scripts/generator/cpp/ast.py index 6d1c8d3e..47dc9a07 100755 --- a/scripts/generator/cpp/ast.py +++ b/scripts/generator/cpp/ast.py @@ -782,7 +782,7 @@ class AstBuilder(object): parts = self.converter.DeclarationToParts(temp_tokens, True) (name, type_name, templated_types, modifiers, default, unused_other_tokens) = parts - + t0 = temp_tokens[0] names = [t.name for t in temp_tokens] if templated_types: @@ -1551,18 +1551,22 @@ class AstBuilder(object): token = self._GetNextToken() self.namespace_stack.append(name) assert token.token_type == tokenize.SYNTAX, token + # Create an internal token that denotes when the namespace is complete. + internal_token = tokenize.Token(_INTERNAL_TOKEN, _NAMESPACE_POP, + None, None) + internal_token.whence = token.whence if token.name == '=': # TODO(nnorwitz): handle aliasing namespaces. name, next_token = self.GetName() assert next_token.name == ';', next_token + self._AddBackToken(internal_token) else: assert token.name == '{', token tokens = list(self.GetScope()) - del tokens[-1] # Remove trailing '}'. + # Replace the trailing } with the internal namespace pop token. + tokens[-1] = internal_token # Handle namespace with nothing in it. self._AddBackTokens(tokens) - token = tokenize.Token(_INTERNAL_TOKEN, _NAMESPACE_POP, None, None) - self._AddBackToken(token) return None def handle_using(self): @@ -1672,7 +1676,7 @@ def PrintIndentifiers(filename, should_print): if should_print(node): print(node.name) except KeyboardInterrupt: - return + return except: pass |