diff options
| author | mryouse | 2022-05-10 04:27:12 +0000 |
|---|---|---|
| committer | mryouse | 2022-05-10 04:27:12 +0000 |
| commit | 12a2caa02af85f91f862d87ab0b518020751197c (patch) | |
| tree | 954257414d225ba729f727cc8e472c6441ff99e0 /tokens.py | |
| parent | db5564306399f0a3af97eb13808140542aa5b42c (diff) | |
make the literals print nicely
Diffstat (limited to 'tokens.py')
| -rw-r--r-- | tokens.py | 11 |
1 files changed, 11 insertions, 0 deletions
@@ -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 |
