diff options
author | Frederick Yin <fkfd@fkfd.me> | 2022-08-30 14:46:23 +0800 |
---|---|---|
committer | Frederick Yin <fkfd@fkfd.me> | 2022-08-30 14:46:23 +0800 |
commit | b439d663a3f3d4d275f07339c1c0e794808f67d9 (patch) | |
tree | 6ab4a6b152336271f4d38c961cee67922020192e /projects/hackc/utils.py | |
parent | d303447dc7a830489828be2e66ccf8c36af4aed6 (diff) |
hackc: parse variable declaration
Also add a handful of overloading operators to Token
Diffstat (limited to 'projects/hackc/utils.py')
-rw-r--r-- | projects/hackc/utils.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/projects/hackc/utils.py b/projects/hackc/utils.py index d1ea3ca..4861088 100644 --- a/projects/hackc/utils.py +++ b/projects/hackc/utils.py @@ -4,6 +4,16 @@ EXIT_CODE_FILE_ERROR = 1 EXIT_CODE_INVALID_TOKEN = 2 EXIT_CODE_SYNTAX_ERROR = 4 +# vim autoindent misbehaves if I type these verbatim in strings +LEFT_BRACE = "{" +RIGHT_BRACE = "}" + +class JackSyntaxError(Exception): + def __init__(self, msg, token): + self.message = msg + self.token = token + super().__init__(msg) + def print_err(msg): print(msg, file=stderr) |