Skip to content

Commit

Permalink
Ensure the tab names are set correctly
Browse files Browse the repository at this point in the history
- Given the way default arguments work, this will need to be passed into
  the local parser at the optimization step like so.
  • Loading branch information
metatoaster committed Oct 28, 2023
1 parent cbe9aa1 commit 94e879c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
6 changes: 4 additions & 2 deletions src/calmjs/parse/parsers/es5.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,10 @@

asttypes = AstTypesFactory(pretty_print, ReprWalker())

# The default values for the `Parser` constructor, passed on to ply; they must
# be strings
# These default values for the `Parser` constructor, passed on to ply;
# they must be strings; these values are for reference only as
# modifications to this value will not change what's been set up as
# the Parser's default.
lextab, yacctab = generate_tab_names(__name__)


Expand Down
7 changes: 5 additions & 2 deletions src/calmjs/parse/parsers/optimize.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,15 @@ def optimize_build(module_name, assume_ply_version=True):
if assume_ply_version:
kws['_version'] = _assume_ply_version()

paths, missing = validate_imports(*generate_tab_names(module_name, **kws))
lextab, yacctab = generate_tab_names(module_name, **kws)
paths, missing = validate_imports(lextab, yacctab)
if missing:
# only import, purge and regenerate if any are missing.
unlink_modules(verify_paths(paths))
module = import_module(module_name)
module.Parser()
# use whatever assumed version or otherwise as set up by
# the local generation function.
module.Parser(lextab=lextab, yacctab=yacctab)


def reoptimize_all(monkey_patch=False, first_build=False):
Expand Down
4 changes: 2 additions & 2 deletions src/calmjs/parse/tests/test_parsers_optimize.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def test_reoptimize_monkey_patched(self):
def test_optimize_build(self):
called = []

def sentinel():
def sentinel(*a, **kw):
called.append(True)

fake_es5 = ModuleType('fake_namespace.fake_es5')
Expand Down Expand Up @@ -227,7 +227,7 @@ def test_optimize_build_assume_broken_ply(self):
optimize.ply_dist = None
called = []

def sentinel():
def sentinel(*a, **kw):
called.append(True)

fake_es5 = ModuleType('fake_namespace.fake_es5')
Expand Down

0 comments on commit 94e879c

Please sign in to comment.