aboutsummaryrefslogtreecommitdiffstats
path: root/atk16_ast_walking_compiler/sample_py/atk16.py
diff options
context:
space:
mode:
authorJan Tuomi <jan@jantuomi.fi>2024-04-26 15:40:14 +0300
committerJan Tuomi <jan@jantuomi.fi>2024-04-26 15:40:14 +0300
commit7ca56c1a730fcecd0fe3af5e6b652fa09514a18b (patch)
treee2ef6a4d28fa26adf11e00d138ef21b8316497f6 /atk16_ast_walking_compiler/sample_py/atk16.py
parent2b18b320e97260f1d27143a37fe14953cf62e56d (diff)
Refactor project structure, add README and LICENSE
Diffstat (limited to 'atk16_ast_walking_compiler/sample_py/atk16.py')
-rw-r--r--atk16_ast_walking_compiler/sample_py/atk16.py39
1 files changed, 39 insertions, 0 deletions
diff --git a/atk16_ast_walking_compiler/sample_py/atk16.py b/atk16_ast_walking_compiler/sample_py/atk16.py
new file mode 100644
index 0000000..9aa3c55
--- /dev/null
+++ b/atk16_ast_walking_compiler/sample_py/atk16.py
@@ -0,0 +1,39 @@
+from typing import Literal, Any, TypeVar, NewType, Never, Callable, Generic, overload, cast
+Char = Literal['\x00', '\x01', '\x02', '\x03', '\x04', '\x05', '\x06', '\x07', '\x08', '\t', '\n', '\x0b', '\x0c', '\r', '\x0e', '\x0f', '\x10', '\x11', '\x12', '\x13', '\x14', '\x15', '\x16', '\x17', '\x18', '\x19', '\x1a', '\x1b', '\x1c', '\x1d', '\x1e', '\x1f', ' ', '!', '"', '#', '$', '%', '&', "'", '(', ')', '*', '+', ',', '-', '.', '/', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', '<', '=', '>', '?', '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '[', '\\', ']', '^', '_', '`', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '{', '|', '}', '~', '\x7f', '\x80', '\x81', '\x82', '\x83', '\x84', '\x85', '\x86', '\x87', '\x88', '\x89', '\x8a', '\x8b', '\x8c', '\x8d', '\x8e', '\x8f', '\x90', '\x91', '\x92', '\x93', '\x94', '\x95', '\x96', '\x97', '\x98', '\x99', '\x9a', '\x9b', '\x9c', '\x9d', '\x9e', '\x9f', '\xa0', '¡', '¢', '£', '¤', '¥', '¦', '§', '¨', '©', 'ª', '«', '¬', '\xad', '®', '¯', '°', '±', '²', '³', '´', 'µ', '¶', '·', '¸', '¹', 'º', '»', '¼', '½', '¾', '¿', 'À', 'Á', 'Â', 'Ã', 'Ä', 'Å', 'Æ', 'Ç', 'È', 'É', 'Ê', 'Ë', 'Ì', 'Í', 'Î', 'Ï', 'Ð', 'Ñ', 'Ò', 'Ó', 'Ô', 'Õ', 'Ö', '×', 'Ø', 'Ù', 'Ú', 'Û', 'Ü', 'Ý', 'Þ', 'ß', 'à', 'á', 'â', 'ã', 'ä', 'å', 'æ', 'ç', 'è', 'é', 'ê', 'ë', 'ì', 'í', 'î', 'ï', 'ð', 'ñ', 'ò', 'ó', 'ô', 'õ', 'ö', '÷', 'ø', 'ù', 'ú', 'û', 'ü', 'ý', 'þ', 'ÿ']
+Void = Literal[0]
+Word16 = int
+ConstWord16 = int
+
+def store(p: Word16, value: Word16 | Char) -> Void:
+ raise NotImplementedError
+
+@overload
+def store_const_vec(p: Word16, value: list[Word16]) -> Void: ...
+@overload
+def store_const_vec(p: Word16, value: list[Char]) -> Void: ...
+@overload
+def store_const_vec(p: Word16, value: str) -> Void: ...
+
+def store_const_vec(p, value) -> Void:
+ raise NotImplementedError
+
+def load(p: Word16) -> Word16:
+ raise NotImplementedError
+
+T = TypeVar("T")
+def call_inline(expr: T) -> T:
+ """Inline the function call `expr` at the callsite.
+ This can lead to a larger output size but avoids having to do a subroutine call."""
+ raise NotImplementedError
+
+def asm(asm: str):
+ """Inject ATK16 assembly `asm` into the compiled output."""
+ raise NotImplementedError
+
+def ord(char: Char) -> int:
+ """Convert char to int"""
+ raise NotImplementedError
+
+def const(word: Word16) -> ConstWord16:
+ """When used in an assignment such as `A = const(0xFF)`, stores the value as a globally accessible constant."""
+ raise NotImplementedError \ No newline at end of file