diff options
author | eli.bendersky <devnull@localhost> | 2011-10-19 06:17:30 +0200 |
---|---|---|
committer | eli.bendersky <devnull@localhost> | 2011-10-19 06:17:30 +0200 |
commit | 171c99fd4dff5deef0ffa868122b66014529f426 (patch) | |
tree | be85e8170e8f46f0632f42f5e040439dbe78cfed /pycparser/c_parser.py | |
parent | 43cf0b28d5e5f7a89fc5b641738e0af07bfee2e5 (diff) | |
download | pycparser-171c99fd4dff5deef0ffa868122b66014529f426.tar.gz |
fixing previous fix:
- that rule created many conflicts. change it to having a check in the parse method instead
Diffstat (limited to 'pycparser/c_parser.py')
-rw-r--r-- | pycparser/c_parser.py | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/pycparser/c_parser.py b/pycparser/c_parser.py index 458d64f..f26fcd5 100644 --- a/pycparser/c_parser.py +++ b/pycparser/c_parser.py @@ -120,7 +120,10 @@ class CParser(PLYParser): self.clex.filename = filename self.clex.reset_lineno() self._scope_stack = [set()] - return self.cparser.parse(text, lexer=self.clex, debug=debuglevel) + if not text or text.isspace(): + return c_ast.FileAST([]) + else: + return self.cparser.parse(text, lexer=self.clex, debug=debuglevel) ######################-- PRIVATE --###################### @@ -356,11 +359,6 @@ class CParser(PLYParser): p[1].ext.extend(p[2]) p[0] = p[1] - def p_translation_unit_3(self, p): - """ translation_unit : - """ - p[0] = c_ast.FileAST([]) - # Declarations always come as lists (because they can be # several in one line), so we wrap the function definition # into a list as well, to make the return value of |