summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--TODO.txt1
-rw-r--r--examples/func_calls.py8
-rw-r--r--examples/func_defs.py6
-rw-r--r--pycparser/_c_ast.cfg2
-rw-r--r--pycparser/c_lexer.py5
-rw-r--r--pycparser/c_parser.py7
-rw-r--r--pycparser/portability.py18
-rw-r--r--z_test.py2
8 files changed, 14 insertions, 35 deletions
diff --git a/TODO.txt b/TODO.txt
index 2dde202..d672043 100644
--- a/TODO.txt
+++ b/TODO.txt
@@ -12,6 +12,7 @@ Fixes since last:
* Issue 19: anonymous structs & union fields
* pycparser is now on PyPI (Python Package Index)
* Created FAQ on the pycparser project page - the readme now points to it
+* No support for Python 2.5, only starting with 2.6 and 3.x
Version Update
diff --git a/examples/func_calls.py b/examples/func_calls.py
index eaa3a67..4789688 100644
--- a/examples/func_calls.py
+++ b/examples/func_calls.py
@@ -4,9 +4,10 @@
# Using pycparser for printing out all the calls of some function
# in a C file.
#
-# Copyright (C) 2008, Eli Bendersky
+# Copyright (C) 2008-2011, Eli Bendersky
# License: LGPL
#-----------------------------------------------------------------
+from __future__ import print_function
import sys
# This is not required if you've installed pycparser into
@@ -15,7 +16,6 @@ import sys
sys.path.insert(0, '..')
from pycparser import c_parser, c_ast, parse_file
-from pycparser.portability import printme
# A visitor with some state information (the funcname it's
@@ -27,7 +27,7 @@ class FuncCallVisitor(c_ast.NodeVisitor):
def visit_FuncCall(self, node):
if node.name.name == self.funcname:
- printme('%s called at %s\n' % (
+ print('%s called at %s' % (
self.funcname, node.name.coord))
@@ -39,7 +39,7 @@ def show_func_calls(filename, funcname):
if __name__ == "__main__":
if len(sys.argv) > 2:
- filename = sys.argv[1]
+ filename = sys.argv[1]
func = sys.argv[2]
else:
filename = 'c_files/hash.c'
diff --git a/examples/func_defs.py b/examples/func_defs.py
index fa15b38..1fd1191 100644
--- a/examples/func_defs.py
+++ b/examples/func_defs.py
@@ -7,9 +7,10 @@
# This is a simple example of traversing the AST generated by
# pycparser.
#
-# Copyright (C) 2008-2009, Eli Bendersky
+# Copyright (C) 2008-2011, Eli Bendersky
# License: LGPL
#-----------------------------------------------------------------
+from __future__ import print_function
import sys
# This is not required if you've installed pycparser into
@@ -18,7 +19,6 @@ import sys
sys.path.insert(0, '..')
from pycparser import c_parser, c_ast, parse_file
-from pycparser.portability import printme
# A simple visitor for FuncDef nodes that prints the names and
@@ -26,7 +26,7 @@ from pycparser.portability import printme
#
class FuncDefVisitor(c_ast.NodeVisitor):
def visit_FuncDef(self, node):
- printme('%s at %s\n' % (node.decl.name, node.decl.coord))
+ print('%s at %s' % (node.decl.name, node.decl.coord))
def show_func_defs(filename):
diff --git a/pycparser/_c_ast.cfg b/pycparser/_c_ast.cfg
index 1c78a73..9e74d1a 100644
--- a/pycparser/_c_ast.cfg
+++ b/pycparser/_c_ast.cfg
@@ -120,7 +120,7 @@ ID: [name]
# Holder for types that are a simple identifier (e.g. the built
# ins void, char etc. and typedef-defined types)
#
-IdentifierType: [names]
+IdentifierType: [name]
If: [cond*, iftrue*, iffalse*]
diff --git a/pycparser/c_lexer.py b/pycparser/c_lexer.py
index ab5f16c..3517975 100644
--- a/pycparser/c_lexer.py
+++ b/pycparser/c_lexer.py
@@ -3,7 +3,7 @@
#
# CLexer class: lexer for the C language
#
-# Copyright (C) 2008-2010, Eli Bendersky
+# Copyright (C) 2008-2011, Eli Bendersky
# License: LGPL
#-----------------------------------------------------------------
@@ -410,7 +410,6 @@ class CLexer(object):
if __name__ == "__main__":
- from portability import printme
filename = '../zp.c'
text = open(filename).read()
@@ -424,7 +423,7 @@ if __name__ == "__main__":
"""
def errfoo(msg, a, b):
- printme(msg)
+ sys.write(msg + "\n")
sys.exit()
def typelookup(namd):
diff --git a/pycparser/c_parser.py b/pycparser/c_parser.py
index b41a4eb..500f4a7 100644
--- a/pycparser/c_parser.py
+++ b/pycparser/c_parser.py
@@ -3,7 +3,7 @@
#
# CParser class: Parser and AST builder for the C language
#
-# Copyright (C) 2008-2010, Eli Bendersky
+# Copyright (C) 2008-2011, Eli Bendersky
# License: LGPL
#-----------------------------------------------------------------
import re
@@ -1363,12 +1363,11 @@ class CParser(PLYParser):
if __name__ == "__main__":
import pprint
- import time
- from portability import printme
+ import time, sys
t1 = time.time()
parser = CParser(lex_optimize=True, yacc_debug=True, yacc_optimize=False)
- printme(time.time() - t1)
+ sys.write(time.time() - t1)
buf = '''
int (*k)(int);
diff --git a/pycparser/portability.py b/pycparser/portability.py
deleted file mode 100644
index 3893cec..0000000
--- a/pycparser/portability.py
+++ /dev/null
@@ -1,18 +0,0 @@
-#-----------------------------------------------------------------
-# pycparser: portability.py
-#
-# Portability code for working with different versions of Python
-#
-# Copyright (C) 2008-2010, Eli Bendersky
-# License: LGPL
-#----------------------
-import sys
-
-
-def printme(s):
- sys.stdout.write(str(s))
-
-
-
-
- \ No newline at end of file
diff --git a/z_test.py b/z_test.py
index 9f92020..c35daad 100644
--- a/z_test.py
+++ b/z_test.py
@@ -64,12 +64,10 @@ if __name__ == "__main__":
{
long sa;
int sb;
- float;
};
"""
#--------------- Lexing
- #~ from pycparser.portability import printme
#~ def errfoo(msg, a, b):
#~ printme(msg)
#~ sys.exit()