Skip to content

Commit d74bab8

Browse files
committed
Move ply into src
1 parent 7120d60 commit d74bab8

17 files changed

Lines changed: 44 additions & 53 deletions

File tree

libzxbasm/asmlex.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,12 @@
88
# This program is Free Software and is released under the terms of
99
# the GNU General License
1010
#
11-
# This is the Lexer for the ZXBpp (ZXBasic Preprocessor)
11+
# This is the Lexer for the zxbasm (ZXBasic Assembler)
1212
# ----------------------------------------------------------------------
1313

14-
import ply.lex as lex
1514
import sys
15+
16+
from src.ply import lex
1617
from src.api.config import OPTIONS
1718
from src.api.errmsg import error
1819

libzxbasm/asmparse.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
import os
1515
import re
1616
from . import asmlex, basic
17-
import ply.yacc as yacc
17+
import src.ply.yacc as yacc
1818

1919
from .asmlex import tokens # noqa
2020
from .asm import AsmInstruction, Error

libzxbpp/zxbasmpplex.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
import os
1414
import sys
15-
from ply import lex
15+
from src.ply import lex
1616
import src.api.utils
1717
from libzxbpp.prepro.output import warning, error
1818

libzxbpp/zxbpp.py

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,17 @@
1818
from typing import NamedTuple, List
1919

2020
from .zxbpplex import tokens # noqa
21-
from . import zxbpplex, zxbasmpplex
22-
from ply import yacc
21+
from . import zxbpplex
22+
from . import zxbasmpplex
23+
from src.ply import yacc
2324

2425
from src.api.config import OPTIONS
2526
from src.api import global_
2627
import src.api.utils
28+
29+
from .prepro import output
2730
from .prepro.output import warning
2831
from .prepro.output import error
29-
from .prepro.output import CURRENT_FILE
3032
from .prepro import DefinesTable, ID, MacroCall, Arg, ArgList
3133
from .prepro.exceptions import PreprocError
3234

@@ -75,7 +77,6 @@ def init():
7577
global ENABLED
7678
global IFDEFS
7779
global ID_TABLE
78-
global CURRENT_FILE
7980

8081
OPTIONS.add_option_if_not_defined('debug_zxbpp', bool, False)
8182
global_.FILENAME = '(stdin)'
@@ -88,7 +89,7 @@ def init():
8889
global_.error_msg_cache.clear()
8990
parser.defaulted_states = {}
9091
ID_TABLE = DefinesTable()
91-
del CURRENT_FILE[:]
92+
del output.CURRENT_FILE[:]
9293

9394

9495
def get_include_path():
@@ -152,16 +153,15 @@ def include_file(filename, lineno, local_first):
152153
This is used when doing a #include "filename".
153154
"""
154155
global CURRENT_DIR
155-
global CURRENT_FILE
156156

157157
filename = search_filename(filename, lineno, local_first)
158158
if filename not in INCLUDED.keys():
159159
INCLUDED[filename] = []
160160

161-
if len(CURRENT_FILE) > 0: # Added from which file, line
162-
INCLUDED[filename].append((CURRENT_FILE[-1], lineno))
161+
if len(output.CURRENT_FILE) > 0: # Added from which file, line
162+
INCLUDED[filename].append((output.CURRENT_FILE[-1], lineno))
163163

164-
CURRENT_FILE.append(filename)
164+
output.CURRENT_FILE.append(filename)
165165
CURRENT_DIR = os.path.dirname(filename)
166166
return LEXER.include(filename)
167167

@@ -284,8 +284,8 @@ def p_include_file(p):
284284
"""
285285
global CURRENT_DIR
286286
p[0] = [p[1] + p[2]] + p[3] + [p[4]]
287-
CURRENT_FILE.pop() # Remove top of the stack
288-
CURRENT_DIR = os.path.dirname(CURRENT_FILE[-1])
287+
output.CURRENT_FILE.pop() # Remove top of the stack
288+
CURRENT_DIR = os.path.dirname(output.CURRENT_FILE[-1])
289289

290290

291291
def p_include_file_empty(p):
@@ -305,8 +305,8 @@ def p_include_once_ok(p):
305305
"""
306306
global CURRENT_DIR
307307
p[0] = [p[1] + p[2]] + p[3] + [p[4]]
308-
CURRENT_FILE.pop() # Remove top of the stack
309-
CURRENT_DIR = os.path.dirname(CURRENT_FILE[-1])
308+
output.CURRENT_FILE.pop() # Remove top of the stack
309+
CURRENT_DIR = os.path.dirname(output.CURRENT_FILE[-1])
310310

311311

312312
def p_include(p):
@@ -422,7 +422,7 @@ def p_define(p):
422422
warning(p.lineno(1), "missing whitespace after the macro name")
423423

424424
ID_TABLE.define(p[2], args=p[3], value=p[4], lineno=p.lineno(2),
425-
fname=CURRENT_FILE[-1])
425+
fname=output.CURRENT_FILE[-1])
426426
p[0] = []
427427

428428

@@ -437,7 +437,7 @@ def p_define_params_empty(p):
437437
"""
438438
# Defines the 'epsilon' parameter
439439
p[0] = [ID('', value='', args=None, lineno=p.lineno(1),
440-
fname=CURRENT_FILE[-1])]
440+
fname=output.CURRENT_FILE[-1])]
441441

442442

443443
def p_define_params_paramlist(p):
@@ -464,14 +464,14 @@ def p_paramlist_single(p):
464464
""" paramlist : ID
465465
"""
466466
p[0] = [ID(p[1], value='', args=None, lineno=p.lineno(1),
467-
fname=CURRENT_FILE[-1])]
467+
fname=output.CURRENT_FILE[-1])]
468468

469469

470470
def p_paramlist_paramlist(p):
471471
""" paramlist : paramlist COMMA ID
472472
"""
473473
p[0] = p[1] + [ID(p[3], value='', args=None, lineno=p.lineno(1),
474-
fname=CURRENT_FILE[-1])]
474+
fname=output.CURRENT_FILE[-1])]
475475

476476

477477
def p_pragma_id(p):
@@ -505,7 +505,7 @@ def p_ifdef(p):
505505
else:
506506
p[0] = []
507507

508-
p[0] += ['#line %i "%s"' % (p.lineno(4) + 1, CURRENT_FILE[-1])]
508+
p[0] += ['#line %i "%s"' % (p.lineno(4) + 1, output.CURRENT_FILE[-1])]
509509
ENABLED = IFDEFS.pop().enabled
510510

511511

@@ -520,7 +520,7 @@ def p_ifdef_else(p):
520520
else:
521521
p[0] = []
522522

523-
p[0] += ['#line %i "%s"' % (p.lineno(3) + 1, CURRENT_FILE[-1])]
523+
p[0] += ['#line %i "%s"' % (p.lineno(3) + 1, output.CURRENT_FILE[-1])]
524524

525525

526526
def p_ifdef_else_a(p):
@@ -541,7 +541,7 @@ def p_ifdef_else_b(p):
541541
global ENABLED
542542

543543
if ENABLED:
544-
p[0] = ['#line %i "%s"%s' % (p.lineno(1) + 1, CURRENT_FILE[-1], p[2])]
544+
p[0] = ['#line %i "%s"%s' % (p.lineno(1) + 1, output.CURRENT_FILE[-1], p[2])]
545545
p[0] += p[3]
546546
else:
547547
p[0] = []
@@ -757,12 +757,12 @@ def filter_(input_, filename='<internal>', state='INITIAL'):
757757
global CURRENT_DIR
758758

759759
prev_dir = CURRENT_DIR
760-
CURRENT_FILE.append(filename)
761-
CURRENT_DIR = os.path.dirname(CURRENT_FILE[-1])
760+
output.CURRENT_FILE.append(filename)
761+
CURRENT_DIR = os.path.dirname(output.CURRENT_FILE[-1])
762762
LEXER.input(input_, filename)
763763
LEXER.lex.begin(state)
764764
parser.parse(lexer=LEXER, debug=OPTIONS.debug_zxbpp)
765-
CURRENT_FILE.pop()
765+
output.CURRENT_FILE.pop()
766766
CURRENT_DIR = prev_dir
767767

768768

@@ -774,10 +774,10 @@ def main(argv):
774774
set_include_path()
775775

776776
if argv:
777-
CURRENT_FILE.append(argv[0])
777+
output.CURRENT_FILE.append(argv[0])
778778
else:
779-
CURRENT_FILE.append(global_.FILENAME)
780-
CURRENT_DIR = os.path.dirname(CURRENT_FILE[-1])
779+
output.CURRENT_FILE.append(global_.FILENAME)
780+
CURRENT_DIR = os.path.dirname(output.CURRENT_FILE[-1])
781781

782782
if OPTIONS.Sinclair:
783783
included_file = search_filename('sinclair.bas', 0, local_first=False)
@@ -789,17 +789,17 @@ def main(argv):
789789
OUTPUT += '\n'
790790

791791
parser.parse(lexer=LEXER, debug=OPTIONS.debug_zxbpp)
792-
CURRENT_FILE.pop()
793-
CURRENT_DIR = os.path.dirname(CURRENT_FILE[-1])
792+
output.CURRENT_FILE.pop()
793+
CURRENT_DIR = os.path.dirname(output.CURRENT_FILE[-1])
794794

795795
prev_file = global_.FILENAME
796-
global_.FILENAME = CURRENT_FILE[-1]
797-
OUTPUT += LEXER.include(CURRENT_FILE[-1])
796+
global_.FILENAME = output.CURRENT_FILE[-1]
797+
OUTPUT += LEXER.include(output.CURRENT_FILE[-1])
798798
if len(OUTPUT) and OUTPUT[-1] != '\n':
799799
OUTPUT += '\n'
800800

801801
parser.parse(lexer=LEXER, debug=OPTIONS.debug_zxbpp)
802-
CURRENT_FILE.pop()
802+
output.CURRENT_FILE.pop()
803803
global_.FILENAME = prev_file
804804
return global_.has_errors
805805

libzxbpp/zxbpplex.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
# ----------------------------------------------------------------------
1212

1313
import sys
14-
from ply import lex
14+
from src.ply import lex
1515
from libzxbpp.prepro.output import warning, error
1616
import src.api.utils
1717

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ packages = [
3636
{ include = "arch/**/*"},
3737
{ include = "ast_" },
3838
{ include = "outfmt" },
39-
{ include = "ply" },
4039
{ include = "libzxbasm" },
4140
{ include = "libzxbpp" },
4241
]

setup.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@
1313
'libzxbasm',
1414
'libzxbpp',
1515
'libzxbpp.prepro',
16-
'outfmt',
17-
'ply'
16+
'outfmt'
1817
]
1918

2019
# The directory containing this file

src/libzxbc/zxblex.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
# ----------------------------------------------------------------------
1111

1212
import sys
13-
from ply import lex
13+
from src.ply import lex
1414
from .keywords import KEYWORDS as reserved
1515
from src import api
1616
from src.api.errmsg import error

src/libzxbc/zxbparser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
from src.api import global_ as gl
5656

5757
# Lexers and parsers, etc
58-
import ply.yacc as yacc
58+
import src.ply.yacc as yacc
5959
from src.libzxbc import zxblex
6060
from src.libzxbc.zxblex import tokens # noqa
6161
from libzxbpp import zxbpp

src/parsetab/tabs.dbm.bak

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

0 commit comments

Comments
 (0)