Skip to content

Commit

Permalink
Parsing of standard tokens which are also functions with integer-only…
Browse files Browse the repository at this point in the history
… forms
  • Loading branch information
kounch committed Apr 18, 2020
1 parent bd0094a commit bca998c
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions txt2nextbasic.py
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,11 @@ def process_params(str_statement):
def process_numbers(str_statement):
"""Parses statement and expands numbers to 5-byte format"""

# Standard tokens which are also functions with integer-only forms
# (as stated in page 76 of ZX Spectrum Next manual)
# RND, PEEK, IN, USR, BIN
arr_intfunc = '\xa5\xbe\xbf\xc0\xc4'

is_number = False
is_intexpr = False # Integer in int expression (NextBASIC)
arr_numbers = [] # Number as string, position, previous char and previous
Expand All @@ -472,8 +477,9 @@ def process_numbers(str_statement):

if str_char in '%\x8b': # Int expression or MOD
is_intexpr = True
elif str_char in ',=' or ord(str_char) > 164:
is_intexpr = False
elif str_char in ',=' or ord(str_char) > 164: # Standard token
if str_char not in arr_intfunc: # Not an integer-only function
is_intexpr = False

if not is_intexpr:
if not is_number:
Expand Down

1 comment on commit bca998c

@kounch
Copy link
Owner Author

@kounch kounch commented on bca998c Apr 18, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixes #2 (integer expression parsing bug)

Please sign in to comment.