summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Beazley <dave@dabeaz.com>2007-11-28 17:34:20 +0000
committerDavid Beazley <dave@dabeaz.com>2007-11-28 17:34:20 +0000
commit671e375f19787ac3c4420ca0cbbb938d9dc7ae76 (patch)
tree72551ed9582e918c83e6f759b3f6dc6d9ec7c79e
parent167094f93b6c0e6d1915bc524d6c6ce9a33f9357 (diff)
downloadply-671e375f19787ac3c4420ca0cbbb938d9dc7ae76.tar.gz
Modification that allows production rules and other information to be defined in inner functions (closures).
-rw-r--r--ply/yacc.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/ply/yacc.py b/ply/yacc.py
index ac298d7..44bef80 100644
--- a/ply/yacc.py
+++ b/ply/yacc.py
@@ -2024,7 +2024,11 @@ def yacc(method=default_lr, debug=yaccdebug, module=None, tabmodule=tab_module,
e,b,t = sys.exc_info()
f = t.tb_frame
f = f.f_back # Walk out to our calling function
- ldict = f.f_globals # Grab its globals dictionary
+ if f.f_globals is f.f_locals: # Collect global and local variations from caller
+ ldict = f.f_globals
+ else:
+ ldict = f.f_globals.copy()
+ ldict.update(f.f_locals)
# Add starting symbol to signature
if not start: