Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ pyyaml_env_tag==0.1
regex==2024.11.6
requests==2.33.0
six==1.16.0
urllib3==2.6.3
urllib3==2.7.*
watchdog==6.0.0
mkdocs-material
624 changes: 336 additions & 288 deletions poetry.lock

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ disable_error_code = [
exclude = [
'src/ply/.*\.py$',
'scratch/*',
'.venv/*',
'venv/*',
]

[[tool.mypy.overrides]]
Expand All @@ -130,6 +132,8 @@ follow_imports = "skip"
line-length = 120
target-version = "py311"
exclude = [
".venv/",
"venv/",
"src/ply" # PLY, external 3rd party tool
]

Expand Down
6 changes: 3 additions & 3 deletions src/api/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ def to_type(typename: str) -> TYPE | None:


@enum.unique
class SCOPE(str, enum.Enum):
class SCOPE(StrEnum):
"""Enum scopes"""

global_ = "global"
Expand All @@ -193,7 +193,7 @@ def to_string(scope: SCOPE) -> str:


@enum.unique
class CONVENTION(str, enum.Enum):
class CONVENTION(StrEnum):
unknown = "unknown"
fastcall = "__fastcall__"
stdcall = "__stdcall__"
Expand All @@ -209,7 +209,7 @@ def to_string(convention: CONVENTION):


@enum.unique
class LoopType(str, enum.Enum):
class LoopType(StrEnum):
DO = "DO"
FOR = "FOR"
WHILE = "WHILE"
Expand Down
4 changes: 2 additions & 2 deletions src/api/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@


SHELVE_PATH = os.path.join(constants.ZXBASIC_ROOT, "parsetab", "tabs.dbm")
SHELVE = shelve.open(SHELVE_PATH)
SHELVE = shelve.open(SHELVE_PATH, protocol=5, flag="c")

T = TypeVar("T")

Expand Down Expand Up @@ -178,7 +178,7 @@ def eval_to_num(expr: str) -> int | float | None:
except (NameError, SyntaxError, ValueError):
return None

if isinstance(result, (int, float)):
if isinstance(result, int | float):
return result

return None
Expand Down
2 changes: 1 addition & 1 deletion src/arch/z80/optimizer/basicblock.py
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ def optimize(self, patterns_list):
old_unary = dict(evaluator.UNARY)

# monkey-patches some functions in this optimizer level (> 2)
evaluator.UNARY[FN.GVAL] = lambda x: self.cpu.get(x)
evaluator.UNARY[FN.GVAL] = self.cpu.get
evaluator.UNARY[FN.FLAGVAL] = lambda x: {
"c": str(self.cpu.C) if self.cpu.C is not None else new_tmp_val(),
"z": str(self.cpu.Z) if self.cpu.Z is not None else new_tmp_val(),
Expand Down
6 changes: 3 additions & 3 deletions src/parsetab/tabs.dbm.bak
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
'zxbpp', (0, 71563)
'asmparse', (71680, 233956)
'zxnext_asmparse', (305664, 259034)
'zxbparser', (564736, 641214)
'asmparse', (71680, 234798)
'zxnext_asmparse', (306688, 259879)
'zxbparser', (566784, 641214)
Binary file modified src/parsetab/tabs.dbm.dat
Binary file not shown.
6 changes: 3 additions & 3 deletions src/parsetab/tabs.dbm.dir
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
'zxbpp', (0, 71563)
'asmparse', (71680, 233956)
'zxnext_asmparse', (305664, 259034)
'zxbparser', (564736, 641214)
'asmparse', (71680, 234798)
'zxnext_asmparse', (306688, 259879)
'zxbparser', (566784, 641214)
4 changes: 3 additions & 1 deletion src/zxbasm/asmparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -925,7 +925,9 @@ def p_expr_div_expr(p):


def p_expr_lprp(p):
"""pexpr : LP expr RP"""
"""pexpr : LP expr RP
| LP pexpr RP
"""
p[0] = p[2]


Expand Down
6 changes: 3 additions & 3 deletions src/zxbc/zxbparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -3511,7 +3511,7 @@ def val(s):
errmsg.syntax_error_expected_string(p.lineno(1), Type.to_string(p[2].type_))
p[0] = None
else:
p[0] = make_builtin(p.lineno(1), "VAL", p[2], lambda x: val(x), type_=Type.float_)
p[0] = make_builtin(p.lineno(1), "VAL", p[2], val, type_=Type.float_)


def p_code(p):
Expand All @@ -3531,7 +3531,7 @@ def asc(x):
errmsg.syntax_error_expected_string(p.lineno(1), Type.to_string(p[2].type_))
p[0] = None
else:
p[0] = make_builtin(p.lineno(1), "CODE", p[2], lambda x: asc(x), type_=Type.ubyte)
p[0] = make_builtin(p.lineno(1), "CODE", p[2], asc, type_=Type.ubyte)


def p_sgn(p):
Expand All @@ -3545,7 +3545,7 @@ def p_sgn(p):
if is_unsigned(p[2]) and not is_number(p[2]):
warning(p.lineno(1), "Sign of unsigned value is always 0 or 1")

p[0] = make_builtin(p.lineno(1), "SGN", p[2], lambda x: sgn(x), type_=Type.byte_)
p[0] = make_builtin(p.lineno(1), "SGN", p[2], sgn, type_=Type.byte_)


# ----------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions src/zxbpp/base_pplex.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import sys
from collections.abc import Callable, Iterable
from dataclasses import dataclass
from enum import Enum, unique
from enum import StrEnum, unique

from src.api import utils
from src.ply import lex
Expand All @@ -26,7 +26,7 @@


@unique
class ReservedDirectives(str, Enum):
class ReservedDirectives(StrEnum):
INCLUDE = "INCLUDE"
ONCE = "ONCE"
DEFINE = "DEFINE"
Expand Down
4 changes: 2 additions & 2 deletions src/zxbpp/zxbpp.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import re
import sys
from dataclasses import dataclass
from enum import Enum, unique
from enum import StrEnum, unique
from typing import Any, Final, NamedTuple

from src.api import config, global_, utils
Expand All @@ -28,7 +28,7 @@


@unique
class PreprocMode(str, Enum):
class PreprocMode(StrEnum):
BASIC = "BASIC"
ASM = "ASM"

Expand Down
5 changes: 5 additions & 0 deletions tests/functional/asm/ld_hl_expr.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
ld hl, (_Fuente.__DATA__ + 0) - (256)
ld hl, ((_Fuente.__DATA__ + 0)) - (256)
ld hl, ((_Fuente.__DATA__ + 0) - (256))

_Fuente.__DATA__:
1 change: 1 addition & 0 deletions tests/functional/asm/ld_hl_expr.bin
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
! ÿ! ÿ* ÿ
Loading