diff options
author | Frederick Yin <fkfd@fkfd.me> | 2022-08-22 17:04:19 +0800 |
---|---|---|
committer | Frederick Yin <fkfd@fkfd.me> | 2022-08-22 17:04:19 +0800 |
commit | 10c9f64f592198d78aad11ebc676629d92ca6576 (patch) | |
tree | 1b4f8a21c72dae1700d92892a619ad9ddaf25cbf /projects/hack-vm/utils.py | |
parent | 900bd8fe1934f83ea35ab8673dda5239ae2dfca8 (diff) |
Project 07: VM translator part 1
Diffstat (limited to 'projects/hack-vm/utils.py')
-rw-r--r-- | projects/hack-vm/utils.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/projects/hack-vm/utils.py b/projects/hack-vm/utils.py new file mode 100644 index 0000000..99c029a --- /dev/null +++ b/projects/hack-vm/utils.py @@ -0,0 +1,12 @@ +from sys import stderr + +EXIT_CODE_FILE_ERROR = 1 +EXIT_CODE_ILLEGAL_CHAR = 2 +EXIT_CODE_SIZE_EXCEEDED = 3 +EXIT_CODE_SYNTAX_ERROR = 4 +EXIT_CODE_ADDR_ERROR = 5 +EXIT_CODE_SYMBOL_ERROR = 6 + +def exit_on_error(msg, code): + print(msg, file=stderr) + exit(code) |