Skip to content

Commit

Permalink
Codechange: Vendor in latest ply version
Browse files Browse the repository at this point in the history
  • Loading branch information
glx22 committed Oct 14, 2024
1 parent b30d0c9 commit fe8f527
Show file tree
Hide file tree
Showing 12 changed files with 3,399 additions and 76 deletions.
2 changes: 1 addition & 1 deletion .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ per-file-ignores =

exclude =
build
generated
ply
nml/actions/action2var_variables.py
nml/actions/action3_callbacks.py
2 changes: 1 addition & 1 deletion .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,4 @@ jobs:
run: |
python -m pip install --upgrade pip
pip install black
black -l 120 --exclude "(generated|nml/actions/action2var_variables.py|nml/actions/action3_callbacks.py)" --check --diff nml
black -l 120 --exclude "(ply|nml/actions/action2var_variables.py|nml/actions/action3_callbacks.py)" --check --diff nml
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ build/*
dist/*
**/__pycache__/*
nml/__version__.py
nml/generated/parsetab.py
nml/generated/lextab.py
**/.nmlcache
nml.egg-info/*
nml_lz77*
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MAKE?=make
PYTHON?=/usr/bin/env python3
BLACK_OPTIONS=-l 120 --exclude 'action2var_variables.py|action3_callbacks.py|generated'
BLACK_OPTIONS=-l 120 --exclude 'action2var_variables.py|action3_callbacks.py|ply'

.PHONY: regression test install extensions clean flake black

Expand Down
10 changes: 0 additions & 10 deletions nml/generated/__init__.py

This file was deleted.

12 changes: 1 addition & 11 deletions nml/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ def parse_cli(argv):
md5_filename=None,
keep_orphaned=True,
verbosity=generic.verbosity_level,
rebuild_parser=False,
debug_parser=False,
allow_extra_zoom=True,
allow_32bpp=True,
Expand Down Expand Up @@ -197,13 +196,6 @@ def parse_cli(argv):
generic.VERBOSITY_MAX
),
)
opt_parser.add_option(
"-R",
"--rebuild-parser",
action="store_true",
dest="rebuild_parser",
help="Force regeneration of parser tables.",
)
opt_parser.add_option(
"-D", "--debug-parser", action="store_true", dest="debug_parser", help="Enable debug mode for parser."
)
Expand Down Expand Up @@ -353,7 +345,6 @@ def main(argv):
opts.crop,
opts.forced_palette,
opts.md5_filename,
opts.rebuild_parser,
opts.debug_parser,
opts.disable_palette_validation,
)
Expand All @@ -376,7 +367,6 @@ def nml(
crop_sprites,
forced_palette,
md5_filename,
rebuild_parser,
debug_parser,
disable_palette_validation,
):
Expand Down Expand Up @@ -425,7 +415,7 @@ def nml(

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

nml_parser = parser.NMLParser(rebuild_parser, debug_parser)
nml_parser = parser.NMLParser(debug_parser)
if input_filename is None:
input_filename = "input"

Expand Down
18 changes: 4 additions & 14 deletions nml/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
with NML; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA."""

import ply.yacc as yacc
from .ply import yacc

from nml import expression, generic, nmlop, tokens, unit
from nml.actions import actionD, real_sprite
Expand Down Expand Up @@ -59,24 +59,14 @@ class NMLParser:
@type parser: L{ply.yacc}
"""

def __init__(self, rebuild=False, debug=False):
if debug:
try:
import os

os.remove(os.path.normpath(os.path.join(os.path.dirname(__file__), "generated", "parsetab.py")))
except FileNotFoundError:
# Tried to remove a non existing file
pass
def __init__(self, debug=False):
self.lexer = tokens.NMLLexer()
self.lexer.build(rebuild or debug)
self.lexer.build()
self.tokens = self.lexer.tokens
self.parser = yacc.yacc(
module=self,
debug=debug,
optimize=not (rebuild or debug),
write_tables=not debug,
tabmodule="nml.generated.parsetab",
optimize=not debug,
)

def parse(self, text, input_filename):
Expand Down
5 changes: 5 additions & 0 deletions nml/ply/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# PLY package
# Author: David Beazley ([email protected])
# https://github.com/dabeaz/ply

__version__ = '2022.10.27'
Loading

0 comments on commit fe8f527

Please sign in to comment.