Fix up examples to run properly from the main source dir
diff --git a/examples/func_defs.py b/examples/func_defs.py
index 6cc5084..eacca41 100644
--- a/examples/func_defs.py
+++ b/examples/func_defs.py
@@ -7,7 +7,7 @@
# This is a simple example of traversing the AST generated by
# pycparser.
#
-# Copyright (C) 2008-2011, Eli Bendersky
+# Copyright (C) 2008-2015, Eli Bendersky
# License: BSD
#-----------------------------------------------------------------
from __future__ import print_function
@@ -15,7 +15,6 @@
# This is not required if you've installed pycparser into
# your site-packages/ with setup.py
-#
sys.path.extend(['.', '..'])
from pycparser import c_parser, c_ast, parse_file
@@ -23,7 +22,6 @@
# A simple visitor for FuncDef nodes that prints the names and
# locations of function definitions.
-#
class FuncDefVisitor(c_ast.NodeVisitor):
def visit_FuncDef(self, node):
print('%s at %s' % (node.decl.name, node.decl.coord))
@@ -32,7 +30,6 @@
def show_func_defs(filename):
# Note that cpp is used. Provide a path to your own cpp or
# make sure one exists in PATH.
- #
ast = parse_file(filename, use_cpp=True)
v = FuncDefVisitor()
@@ -43,6 +40,6 @@
if len(sys.argv) > 1:
filename = sys.argv[1]
else:
- filename = 'c_files/memmgr.c'
+ filename = 'examples/c_files/memmgr.c'
show_func_defs(filename)