Skip to content

Commit

Permalink
Merge pull request #863 from boriel-basic/fix/do_not_allow_data_withi…
Browse files Browse the repository at this point in the history
…n_functions

fix: prevent DATA to be declared within SUBs
  • Loading branch information
boriel authored Nov 13, 2024
2 parents e2c1c12 + 92c01b1 commit 8bf2536
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 50 deletions.
11 changes: 8 additions & 3 deletions src/zxbc/zxbparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,17 +221,17 @@ def make_unary(lineno, operator, operand, func=None, type_=None):
return sym.UNARY.make_node(lineno, operator, operand, func, type_)


def make_builtin(lineno, fname, operands, func=None, type_=None):
def make_builtin(lineno: int, fname: str, operands: Symbol | tuple | list | None, func=None, type_=None):
"""Wrapper: returns a Builtin function node.
Can be a Symbol, tuple or list of Symbols
If operand is an iterable, they will be expanded.
"""
if operands is None:
operands = []
assert isinstance(operands, Symbol) or isinstance(operands, tuple) or isinstance(operands, list)
assert isinstance(operands, Symbol | tuple | list)
# TODO: In the future, builtin functions will be implemented in an external stdlib, like POINT or ATTR
__DEBUG__(f'Creating BUILTIN "{fname}"', 1)
if not isinstance(operands, (list, tuple, set)):
if not isinstance(operands, (list, tuple)):
operands = [operands]

return sym.BUILTIN.make_node(lineno, fname, func, type_, *operands)
Expand Down Expand Up @@ -1739,6 +1739,11 @@ def p_data(p):
p[0] = None
return

if gl.FUNCTION_LEVEL:
errmsg.error(p.lineno(1), "DATA not allowed within Functions nor Subs")
p[0] = None
return

for d in p[2].children:
value = d.value
if is_static(value):
Expand Down
47 changes: 0 additions & 47 deletions tests/functional/arch/zx48k/sub_data.asm

This file was deleted.

0 comments on commit 8bf2536

Please sign in to comment.