From ad012184c57d5890cb5ce8c21eba05b800b0e713 Mon Sep 17 00:00:00 2001 From: Emi Simpson Date: Sun, 5 Mar 2023 16:51:19 -0500 Subject: [PATCH] Add docs --- ir.py | 36 ++++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/ir.py b/ir.py index ebb239e..e7b0c3e 100644 --- a/ir.py +++ b/ir.py @@ -6,21 +6,37 @@ 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)})' + """ + Represents a proposition or object for resolution + + Can have any number of arguments, each of which should be a `IRTerm`. Note that no + distinction is made between predicates (n-arity, logical statements), functions + (positive-arity functions over objects), and constants (stand-ins for objects) + """ + lexeme: Lexeme[Tok] + """ + The identifier of this thing, including its location in the source + """ + 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}' + """ + A variable which may be substituted for any other term + """ + 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}' + """ + A negated proposition + """ + inner: 'IRTerm' + def __str__(self) -> str: + return f'¬{self.inner}' IRTerm: TypeAlias = IRVar | IRProp | IRNeg \ No newline at end of file