Add docs
This commit is contained in:
parent
f84a340f0a
commit
ad012184c5
36
ir.py
36
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
|
Loading…
Reference in a new issue