tighten things up

This commit is contained in:
Reid 'arrdem' McKenzie 2020-07-18 18:01:18 -06:00
parent beea56fad5
commit 9f29067f6d

View file

@ -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):