from dataclasses import dataclass from typing import Sequence, TypeAlias from lex import Lexeme from tokens import Tok @dataclass(frozen=True) class IRProp: lexeme: Lexeme[Tok] arguments: 'Sequence[IRTerm]' def __str__(self) -> str: return f'{self.lexeme.matched_string}({",".join(str(arg) for arg in self.arguments)})' @dataclass(frozen=True) class IRVar: lexeme: Lexeme[Tok] def __str__(self) -> str: return f'*{self.lexeme.matched_string}' @dataclass(frozen=True) class IRNeg: inner: 'IRTerm' def __str__(self) -> str: return f'¬{self.inner}' IRTerm: TypeAlias = IRVar | IRProp | IRNeg