Skip to content

Commit fe8f527

Browse files
committed
Codechange: Vendor in latest ply version
1 parent b30d0c9 commit fe8f527

File tree

12 files changed

+3399
-76
lines changed

12 files changed

+3399
-76
lines changed

.flake8

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ per-file-ignores =
1414

1515
exclude =
1616
build
17-
generated
17+
ply
1818
nml/actions/action2var_variables.py
1919
nml/actions/action3_callbacks.py

.github/workflows/testing.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,4 +79,4 @@ jobs:
7979
run: |
8080
python -m pip install --upgrade pip
8181
pip install black
82-
black -l 120 --exclude "(generated|nml/actions/action2var_variables.py|nml/actions/action3_callbacks.py)" --check --diff nml
82+
black -l 120 --exclude "(ply|nml/actions/action2var_variables.py|nml/actions/action3_callbacks.py)" --check --diff nml

.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ build/*
22
dist/*
33
**/__pycache__/*
44
nml/__version__.py
5-
nml/generated/parsetab.py
6-
nml/generated/lextab.py
75
**/.nmlcache
86
nml.egg-info/*
97
nml_lz77*

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MAKE?=make
22
PYTHON?=/usr/bin/env python3
3-
BLACK_OPTIONS=-l 120 --exclude 'action2var_variables.py|action3_callbacks.py|generated'
3+
BLACK_OPTIONS=-l 120 --exclude 'action2var_variables.py|action3_callbacks.py|ply'
44

55
.PHONY: regression test install extensions clean flake black
66

nml/generated/__init__.py

Lines changed: 0 additions & 10 deletions
This file was deleted.

nml/main.py

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ def parse_cli(argv):
8585
md5_filename=None,
8686
keep_orphaned=True,
8787
verbosity=generic.verbosity_level,
88-
rebuild_parser=False,
8988
debug_parser=False,
9089
allow_extra_zoom=True,
9190
allow_32bpp=True,
@@ -197,13 +196,6 @@ def parse_cli(argv):
197196
generic.VERBOSITY_MAX
198197
),
199198
)
200-
opt_parser.add_option(
201-
"-R",
202-
"--rebuild-parser",
203-
action="store_true",
204-
dest="rebuild_parser",
205-
help="Force regeneration of parser tables.",
206-
)
207199
opt_parser.add_option(
208200
"-D", "--debug-parser", action="store_true", dest="debug_parser", help="Enable debug mode for parser."
209201
)
@@ -353,7 +345,6 @@ def main(argv):
353345
opts.crop,
354346
opts.forced_palette,
355347
opts.md5_filename,
356-
opts.rebuild_parser,
357348
opts.debug_parser,
358349
opts.disable_palette_validation,
359350
)
@@ -376,7 +367,6 @@ def nml(
376367
crop_sprites,
377368
forced_palette,
378369
md5_filename,
379-
rebuild_parser,
380370
debug_parser,
381371
disable_palette_validation,
382372
):
@@ -425,7 +415,7 @@ def nml(
425415

426416
generic.print_progress("Init parser ...")
427417

428-
nml_parser = parser.NMLParser(rebuild_parser, debug_parser)
418+
nml_parser = parser.NMLParser(debug_parser)
429419
if input_filename is None:
430420
input_filename = "input"
431421

nml/parser.py

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
with NML; if not, write to the Free Software Foundation, Inc.,
1414
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA."""
1515

16-
import ply.yacc as yacc
16+
from .ply import yacc
1717

1818
from nml import expression, generic, nmlop, tokens, unit
1919
from nml.actions import actionD, real_sprite
@@ -59,24 +59,14 @@ class NMLParser:
5959
@type parser: L{ply.yacc}
6060
"""
6161

62-
def __init__(self, rebuild=False, debug=False):
63-
if debug:
64-
try:
65-
import os
66-
67-
os.remove(os.path.normpath(os.path.join(os.path.dirname(__file__), "generated", "parsetab.py")))
68-
except FileNotFoundError:
69-
# Tried to remove a non existing file
70-
pass
62+
def __init__(self, debug=False):
7163
self.lexer = tokens.NMLLexer()
72-
self.lexer.build(rebuild or debug)
64+
self.lexer.build()
7365
self.tokens = self.lexer.tokens
7466
self.parser = yacc.yacc(
7567
module=self,
7668
debug=debug,
77-
optimize=not (rebuild or debug),
78-
write_tables=not debug,
79-
tabmodule="nml.generated.parsetab",
69+
optimize=not debug,
8070
)
8171

8272
def parse(self, text, input_filename):

nml/ply/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# PLY package
2+
# Author: David Beazley ([email protected])
3+
# https://github.com/dabeaz/ply
4+
5+
__version__ = '2022.10.27'

0 commit comments

Comments
 (0)