Skip to content
This repository has been archived by the owner on May 21, 2024. It is now read-only.

Commit

Permalink
Merged in bugfix/parser_crash (pull request boriel-basic#217)
Browse files Browse the repository at this point in the history
Bugfix/parser crash

Approved-by: Jose Rodriguez <boriel@gmail.com>
  • Loading branch information
boriel committed Sep 28, 2019
2 parents 90aa502 + 404483c commit 158002c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
3 changes: 3 additions & 0 deletions tests/functional/callable_err.bas
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
IF m$(s(1)-vm,s(2)-hm)="\c" THEN REM


2 changes: 2 additions & 0 deletions tests/functional/substr_err.bas
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
IF k$<>s$ THEN REM
IF m$(s(1),s(2))="\b" THEN LET m$(s(1),s(2))="\c"
13 changes: 12 additions & 1 deletion zxbparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -1166,10 +1166,17 @@ def p_substr_assignment(p):
if entry.class_ == CLASS.unknown:
entry.class_ = CLASS.var

assert entry.class_ == CLASS.var and entry.type_ == TYPE.string
if entry.class_ != CLASS.var:
api.errmsg.syntax_error_cannot_assign_not_a_var(p.lineno(2), p[2])
return

if entry.type_ != TYPE.string:
api.errmsg.syntax_error_expected_string(p.lineno(2), entry.type_)
return

if p[5].type_ != TYPE.string:
api.errmsg.syntax_error_expected_string(p.lineno(4), p[5].type_)
return

if len(p[3]) > 1:
syntax_error(p.lineno(2), "Accessing string with too many indexes. Expected only one.")
Expand Down Expand Up @@ -2583,6 +2590,10 @@ def p_expr_funccall(p):
def p_idcall_expr(p):
""" func_call : ID arg_list %prec UMINUS
""" # This can be a function call or a string index
if p[2] is None:
p[0] = None
return

p[0] = make_call(p[1], p.lineno(1), p[2])
if p[0] is None:
return
Expand Down

0 comments on commit 158002c

Please sign in to comment.