aboutsummaryrefslogtreecommitdiff
path: root/lllars/llltranspiler/src/main/kotlin/me/any/Ast.kt
diff options
context:
space:
mode:
authoranyunderstanding2024-12-29 21:13:59 +0100
committeranyunderstanding2024-12-29 21:13:59 +0100
commitdf1b046bd6bc1afd17aeeae0ee3a0dd75f1480f9 (patch)
tree9eba207c2fa40708ca0903970843c55acb7037ab /lllars/llltranspiler/src/main/kotlin/me/any/Ast.kt
parent3da2f9e537dbb379a4fa40c1b47ae56fd479b2e7 (diff)
im in love with lll
Diffstat (limited to 'lllars/llltranspiler/src/main/kotlin/me/any/Ast.kt')
-rw-r--r--lllars/llltranspiler/src/main/kotlin/me/any/Ast.kt62
1 files changed, 62 insertions, 0 deletions
diff --git a/lllars/llltranspiler/src/main/kotlin/me/any/Ast.kt b/lllars/llltranspiler/src/main/kotlin/me/any/Ast.kt
new file mode 100644
index 0000000..47bca22
--- /dev/null
+++ b/lllars/llltranspiler/src/main/kotlin/me/any/Ast.kt
@@ -0,0 +1,62 @@
+package me.any
+
+import kotlinx.serialization.Serializable
+
+@Serializable(with = AccessSerializer::class)
+interface Access
+
+@Serializable
+data class SAccess(val sAddress: Access) : Access
+
+@Serializable
+data class Address(val address: Int) : Access
+
+
+enum class Operation {
+ ADD, SUB, MUL, DIV, AND, OR, XOR
+}
+
+@Serializable(with = AddresationSerializer::class)
+interface Addresation
+
+data class AddressAddresation(val address: Access) : Addresation
+
+
+data class BinaryOperation(
+ val op: Operation,
+ val left: Access,
+ val right: Access
+) : Addresation
+
+interface SysCall : Instruction
+
+class WriteSysCall : SysCall
+class ReadSysCall : SysCall
+
+enum class BranchPolarity {
+ IfTrue, IfFalse
+}
+
+@Serializable(with = InstructionSerializer::class)
+interface Instruction
+
+@Serializable
+data class Comment(val comment: String = "") : Instruction
+
+@Serializable
+data class Write(val target: Int, val source: Addresation) : Instruction
+
+@Serializable
+data class LarsCode(val call: SysCall) : Instruction
+
+@Serializable
+data class Label(val label: String) : Instruction
+
+@Serializable
+data class GoTo(val label: String) : Instruction
+
+@Serializable
+data class Branch(val polarity: BranchPolarity, val address: Access, val label: String) : Instruction
+
+@Serializable
+data class Program(val instructions: List<Instruction>) \ No newline at end of file