Skip to content

Commit fab69c7

Browse files
authored
Merge pull request #3 from boriel/feature/standardize-grammar
Feature/standardize grammar
2 parents 7c23ece + cedc3cb commit fab69c7

100 files changed

Lines changed: 151 additions & 163 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

arch/zx48k/optimizer/asm.py

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

33
from .patterns import RE_OUTC, RE_INDIR16
44
from .helpers import single_registers
5-
from libzxbasm import z80
5+
from src.libzxbasm import z80
66

77
# Dict of patterns to normalized instructions. I.e. 'ld a, 5' -> 'LD A,N'
88
Z80_PATTERN = {}

arch/zx48k/optimizer/memcell.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from .. import backend
77
from .asm import Asm
88
from src.api.utils import flatten_list
9-
from libzxbasm import asmlex
9+
from src.libzxbasm import asmlex
1010

1111

1212
class MemCell(object):

arch/zx48k/translator.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@
2121
from src.api.errors import InvalidOperatorError
2222
from src.api.errors import InvalidBuiltinFunctionError
2323
from src.api.errors import InternalError
24-
from libzxbpp import zxbpp
24+
from src.libzxbpp import zxbpp
2525

2626
from . import backend
2727
from .backend.__float import _float
2828

29-
import symbols
30-
from symbols.type_ import Type
29+
from src import symbols
30+
from src.symbols.type_ import Type
3131
from .translatorvisitor import TranslatorVisitor
3232

3333
import arch.zx48k # TODO: put this in global

arch/zx48k/translatorinstvisitor.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# -*- coding: utf-8 -*-
22

33
from src.api.constants import TYPE
4-
import symbols
4+
from src import symbols
55

6-
from ast_ import NodeVisitor
6+
from src.ast import NodeVisitor
77
from .backend import Quad, MEMORY
88
from src.api.debug import __DEBUG__
99

arch/zx48k/translatorvisitor.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@
1111
from src.api.constants import SCOPE
1212
import src.api.global_ as gl
1313

14-
from symbols.symbol_ import Symbol
15-
from symbols.type_ import Type
14+
from src.symbols.symbol_ import Symbol
15+
from src.symbols.type_ import Type
1616

1717
from . import backend
18-
import symbols
18+
from src import symbols
1919

2020
from src.api.errors import InvalidOperatorError
2121

pyproject.toml

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,19 +34,14 @@ keywords = ['compiler', 'zxspectrum', 'BASIC', 'z80'] # arbitrary keywords
3434
packages = [
3535
{ include = "src/**/*" },
3636
{ include = "arch/**/*"},
37-
{ include = "ast_" },
38-
{ include = "outfmt" },
39-
{ include = "ply" },
40-
{ include = "symbols" },
41-
{ include = "libzxbasm" },
42-
{ include = "libzxbpp" },
37+
{ include = "outfmt" }
4338
]
4439

4540
[tool.poetry.scripts]
4641
zxb = 'src.libzxbc.zxb:main'
4742
zxbc = 'src.libzxbc.zxb:main'
48-
zxbasm = 'libzxbasm.zxbasm:main'
49-
zxbpp = 'libzxbpp.zxbpp:entry_point'
43+
zxbasm = 'src.libzxbasm.zxbasm:main'
44+
zxbpp = 'src.libzxbpp.zxbpp:entry_point'
5045

5146
[tool.poetry.dependencies]
5247
python = "^3.6"

setup.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,7 @@
99
'arch.zx48k.backend',
1010
'arch.zx48k.optimizer',
1111
'arch.zx48k.peephole',
12-
'ast_',
13-
'libzxbasm',
14-
'libzxbpp',
15-
'libzxbpp.prepro',
16-
'outfmt',
17-
'ply',
18-
'symbols'
12+
'outfmt'
1913
]
2014

2115
# The directory containing this file
@@ -28,9 +22,9 @@
2822

2923
entry_points = {
3024
'console_scripts': ['zxb = src.libzxbc.zxb:main',
31-
'zxbasm = libzxbasm.zxbasm:main',
25+
'zxbasm = src.libzxbasm.zxbasm:main',
3226
'zxbc = src.libzxbc.zxb:main',
33-
'zxbpp = libzxbpp.zxbpp:entry_point']
27+
'zxbpp = src.libzxbpp.zxbpp:entry_point']
3428
}
3529

3630
setup_kwargs = {

src/api/check.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def check_is_declared_explicit(lineno, id_, classname='variable'):
7878

7979

8080
def check_type_is_explicit(lineno: int, id_: str, type_):
81-
from symbols.type_ import SymbolTYPE
81+
from src.symbols.type_ import SymbolTYPE
8282
assert isinstance(type_, SymbolTYPE)
8383
if type_.implicit:
8484
if config.OPTIONS.strict:
@@ -114,7 +114,7 @@ def check_call_arguments(lineno, id_, args):
114114
return False
115115

116116
if param.byref:
117-
from symbols.var import SymbolVAR
117+
from src.symbols.var import SymbolVAR
118118
if not isinstance(arg.value, SymbolVAR):
119119
error(lineno, "Expected a variable name, not an expression (parameter By Reference)")
120120
return False
@@ -210,7 +210,7 @@ def is_null(*symbols):
210210
""" True if no nodes or all the given nodes are either
211211
None, NOP or empty blocks. For blocks this applies recursively
212212
"""
213-
from symbols.symbol_ import Symbol
213+
from src.symbols.symbol_ import Symbol
214214

215215
for sym in symbols:
216216
if sym is None:
@@ -231,7 +231,7 @@ def is_SYMBOL(token, *symbols):
231231
""" Returns True if ALL of the given argument are AST nodes
232232
of the given token (e.g. 'BINARY')
233233
"""
234-
from symbols.symbol_ import Symbol
234+
from src.symbols.symbol_ import Symbol
235235
assert all(isinstance(x, Symbol) for x in symbols)
236236
for sym in symbols:
237237
if sym.token != token:
@@ -295,7 +295,7 @@ def is_var(*p):
295295

296296

297297
def is_integer(*p):
298-
from symbols.type_ import Type
298+
from src.symbols.type_ import Type
299299

300300
try:
301301
for i in p:
@@ -312,7 +312,7 @@ def is_integer(*p):
312312
def is_unsigned(*p):
313313
""" Returns false unless all types in p are unsigned
314314
"""
315-
from symbols.type_ import Type
315+
from src.symbols.type_ import Type
316316

317317
try:
318318
for i in p:
@@ -329,7 +329,7 @@ def is_unsigned(*p):
329329
def is_signed(*p):
330330
""" Returns false unless all types in p are signed
331331
"""
332-
from symbols.type_ import Type
332+
from src.symbols.type_ import Type
333333

334334
try:
335335
for i in p:
@@ -346,7 +346,7 @@ def is_signed(*p):
346346
def is_numeric(*p):
347347
""" Returns false unless all elements in p are of numerical type
348348
"""
349-
from symbols.type_ import Type
349+
from src.symbols.type_ import Type
350350

351351
try:
352352
for i in p:
@@ -379,7 +379,7 @@ def is_dynamic(*p): # TODO: Explain this better
379379
""" True if all args are dynamic (e.g. Strings, dynamic arrays, etc)
380380
The use a ptr (ref) and it might change during runtime.
381381
"""
382-
from symbols.type_ import Type
382+
from src.symbols.type_ import Type
383383

384384
try:
385385
for i in p:
@@ -397,7 +397,7 @@ def is_dynamic(*p): # TODO: Explain this better
397397
def is_callable(*p):
398398
""" True if all the args are functions and / or subroutines
399399
"""
400-
import symbols
400+
from .. import symbols
401401
return all(isinstance(x, symbols.FUNCTION) for x in p)
402402

403403

@@ -427,9 +427,9 @@ def common_type(a, b):
427427
""" Returns a type which is common for both a and b types.
428428
Returns None if no common types allowed.
429429
"""
430-
from symbols.type_ import SymbolBASICTYPE as BASICTYPE
431-
from symbols.type_ import Type as TYPE
432-
from symbols.type_ import SymbolTYPE
430+
from src.symbols.type_ import SymbolBASICTYPE as BASICTYPE
431+
from src.symbols.type_ import Type as TYPE
432+
from src.symbols.type_ import SymbolTYPE
433433

434434
if a is None or b is None:
435435
return None

src/api/optimize.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
# -*- coding: utf-8 -*-
33

44
from typing import NamedTuple
5-
from ast_ import NodeVisitor
5+
from src.ast import NodeVisitor
66
from .config import OPTIONS
77
from src.api.errmsg import warning
88
import src.api.check as chk
99
from src.api.constants import TYPE, SCOPE, CLASS
1010
import src.api.global_ as gl
11-
import symbols
11+
from .. import symbols
1212
import types
1313
from src.api.debug import __DEBUG__
1414
from src.api.errmsg import warning_not_used

src/api/symboltable.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313

1414
from .debug import __DEBUG__
1515

16-
import symbols
17-
from symbols.symbol_ import Symbol
16+
from .. import symbols
17+
from src.symbols.symbol_ import Symbol
1818

1919
from . import global_
2020
from .config import OPTIONS

0 commit comments

Comments
 (0)