aboutsummaryrefslogtreecommitdiff
path: root/structs.py
diff options
context:
space:
mode:
Diffstat (limited to 'structs.py')
-rw-r--r--structs.py19
1 files changed, 18 insertions, 1 deletions
diff --git a/structs.py b/structs.py
index 1e01949..bab9c13 100644
--- a/structs.py
+++ b/structs.py
@@ -67,12 +67,29 @@ class Token:
def __str__(self):
return f"{self.type_.name} {self.text} {self.line}"
+# Literals
class Literal:
def __init__(self, value):
self.value = value
def __str__(self):
+ return f"{self.value}:literal"
+
+class Int(Literal):
+ def __str__(self):
+ return f"{self.value}"
+
+class Float(Literal):
+ def __str__(self):
return f"{self.value}"
+class Bool(Literal):
+ def __str__(self):
+ return f"#{str(self.value).lower()}"
+
+class String(Literal):
+ def __str__(self):
+ return f'"{self.value}"'
+
class Type:
def __init__(self, name):
self.name = name
@@ -90,4 +107,4 @@ class List:
self.args = args
self.data = data
def __str__(self):
- return "(" + " ".join(f"{arg}" for arg in self.args) + ")"
+ return "(" + ",".join(f"{arg}" for arg in self.args) + ")"