This commit is contained in:
itamar 2026-04-10 16:39:57 +02:00
commit 1ac693fdc2
Signed by: itamar
SSH key fingerprint: SHA256:Dv6UzB9hN8q8FUgMR/7X3DTFpE/vSB2m05+KNnxM4B0
9 changed files with 670 additions and 0 deletions

26
tokens.py Normal file
View file

@ -0,0 +1,26 @@
from enum import Enum
from dataclasses import dataclass
class TokenType(Enum):
NUMBER = 0
PLUS = 1
MINUS = 2
NEGATE = 3
MULTIPLY = 4
DIVIDE = 5
POWER = 6
MODULE = 7
FACTORIAL = 8
AVERAGE = 9
MAXIMUM = 10
MINIMUM = 11
LBRACKET = 12
RBRACKET = 13
@dataclass
class Token:
type: TokenType
value: any = None
def __repr__(self):
return self.type.name + (f"{self.value}" if self.value != None else "")