Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/token.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,24 @@

@dataclass
class Token:
"""
Represents a lexical token with a type and value.

Attributes:
type_ (str): The type/category of the token (e.g., 'MEMBER', 'SCOPE').
value (str): The string value of the token.
"""
type_: str
value: str

def __eq__(self, other: object) -> bool:
"""
Compare this token to another for equality.

Args:
other (object): Another object to compare with.

Returns:
bool: True if `other` is a Token with the same type and value, False otherwise.
"""
return isinstance(other, Token) and self.type_ == other.type_ and self.value == other.value