Skip to content

Commit

Permalink
handle unrecognized command on line start
Browse files Browse the repository at this point in the history
  • Loading branch information
BLooperZ committed Nov 20, 2023
1 parent 39b0a31 commit cb7bb71
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/magos/gamepc_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -663,6 +663,8 @@ def tokenize_cmds(
params.append(key)
params.append(token)
key = None
if command is None:
raise UnrecognizedCommandError(token)
if command is not None:
yield (keywords[command], command, params)

Expand Down Expand Up @@ -715,6 +717,11 @@ def show(self, scr_file: str) -> None:
sys.exit(1)


class UnrecognizedCommandError(ParseError):
def __init__(self, command: str) -> None:
super().__init__(f'unrecognized command name {command}', command, [])


class OpcodeCommandMismatchError(ParseError):
def __init__(self, key: str, expected: int, command: str) -> None:
super().__init__(
Expand Down

0 comments on commit cb7bb71

Please sign in to comment.