diff --git a/src/python/flowmetal/parser.py b/src/python/flowmetal/parser.py index 1032b2d..0492676 100644 --- a/src/python/flowmetal/parser.py +++ b/src/python/flowmetal/parser.py @@ -41,13 +41,11 @@ class TokenBase(object): """The raw token as scanned.""" -class ConstTokenBase(TokenBase): +class ConstTokenBase(TokenBase, NamedTuple): """The shared interface for constant tokens""" - - @property - @abstractmethod - def data(self) -> Any: - """The value of the token.""" + data: Any + raw: str + pos: Position # Hash according to data def __hash__(self): @@ -64,53 +62,32 @@ class ConstTokenBase(TokenBase): return self.data > other -class BooleanToken(ConstTokenBase, Enum): +class BooleanToken(ConstTokenBase): """A read boolean.""" - data: bool - raw: str - pos: Position -class IntegerToken(ConstTokenBase, NamedTuple): +class IntegerToken(ConstTokenBase): """A read integer, including position.""" - data: int - raw: str - pos: Position -class FractionToken(ConstTokenBase, NamedTuple): +class FractionToken(ConstTokenBase): """A read fraction, including position.""" - data: Fraction - raw: str - pos: Position -class FloatToken(ConstTokenBase, NamedTuple): +class FloatToken(ConstTokenBase): """A read floating point number, including position.""" - data: float - raw: str - pos: Position -class SymbolToken(ConstTokenBase, NamedTuple): +class SymbolToken(ConstTokenBase): """A read symbol, including position.""" - data: str - raw: str - pos: Position -class KeywordToken(ConstTokenBase, NamedTuple): +class KeywordToken(ConstTokenBase): """A read keyword.""" - data: str - raw: str - pos: Position -class StringToken(ConstTokenBase, NamedTuple): +class StringToken(ConstTokenBase): """A read string, including position.""" - data: str - raw: str - pos: Position class ListType(Enum):