diff options
author | David Beazley <dave@dabeaz.com> | 2007-11-28 17:34:20 +0000 |
---|---|---|
committer | David Beazley <dave@dabeaz.com> | 2007-11-28 17:34:20 +0000 |
commit | 671e375f19787ac3c4420ca0cbbb938d9dc7ae76 (patch) | |
tree | 72551ed9582e918c83e6f759b3f6dc6d9ec7c79e | |
parent | 167094f93b6c0e6d1915bc524d6c6ce9a33f9357 (diff) | |
download | ply-671e375f19787ac3c4420ca0cbbb938d9dc7ae76.tar.gz |
Modification that allows production rules and other information to be defined in inner functions (closures).
-rw-r--r-- | ply/yacc.py | 6 |
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: |