Fix parsing of empty declarations on the file-level (issue 17)
diff --git a/z_test.py b/z_test.py
index e254bf9..9fabe3b 100644
--- a/z_test.py
+++ b/z_test.py
@@ -1,5 +1,7 @@
+import sys
from pycparser.c_ast import *
from pycparser.c_parser import CParser, Coord, ParseError
+from pycparser.c_lexer import CLexer
def expand_decl(decl):
@@ -57,6 +59,27 @@
}
"""
+ source_code = """
+ int foo;;
+
+ """
+
+ #--------------- Lexing
+ #~ from pycparser.portability import printme
+ #~ def errfoo(msg, a, b):
+ #~ printme(msg)
+ #~ sys.exit()
+ #~ clex = CLexer(errfoo, lambda t: False)
+ #~ clex.build()
+ #~ clex.input(source_code)
+
+ #~ while 1:
+ #~ tok = clex.token()
+ #~ if not tok: break
+
+ #~ printme([tok.value, tok.type, tok.lineno, clex.filename, tok.lexpos])
+
+ #--------------- Parsing
parser = CParser()
ast = parser.parse(source_code)