aboutsummaryrefslogtreecommitdiff
path: root/tokens.py
diff options
context:
space:
mode:
Diffstat (limited to 'tokens.py')
-rw-r--r--tokens.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/tokens.py b/tokens.py
index 688fb7f..2d4387e 100644
--- a/tokens.py
+++ b/tokens.py
@@ -11,6 +11,9 @@ class NebType(Enum):
STRING = auto()
BOOL = auto()
+ def __str__(self):
+ return ":" + self.name.lower()
+
@dataclass
class NebToken:
pass
@@ -20,6 +23,14 @@ class NebLiteral(NebToken):
type_: NebType
value: T
+ def __str__(self):
+ fixed = str(self.value)
+ if self.type_ == NebType.BOOL:
+ fixed = f"#{str(self.value).lower()}"
+ elif self.type_ == NebType.STRING:
+ fixed = f'"{self.value}"'
+ return f"{fixed} <{self.type_}>"
+
class NebSeparator(NebToken):
pass