Use strings in IR rather than lexemes
This commit is contained in:
parent
ad012184c5
commit
0fef3804a4
|
@ -135,10 +135,10 @@ class ASTProp:
|
||||||
return Err(CallingNonFunc(self.ident, bound_type))
|
return Err(CallingNonFunc(self.ident, bound_type))
|
||||||
|
|
||||||
if bound_type == IdentKind.Variable:
|
if bound_type == IdentKind.Variable:
|
||||||
return Ok(IRVar(self.ident))
|
return Ok(IRVar(self.ident.matched_string))
|
||||||
else:
|
else:
|
||||||
arg_ir = sequence([t.make_ir(idents, False) for t in self.arguments])
|
arg_ir = sequence([t.make_ir(idents, False) for t in self.arguments])
|
||||||
return map_res(p(IRProp, self.ident), arg_ir)
|
return map_res(p(IRProp, self.ident.matched_string), arg_ir)
|
||||||
|
|
||||||
@cur2
|
@cur2
|
||||||
def make_ir(
|
def make_ir(
|
||||||
|
|
11
ir.py
11
ir.py
|
@ -1,9 +1,6 @@
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from typing import Sequence, TypeAlias
|
from typing import Sequence, TypeAlias
|
||||||
|
|
||||||
from lex import Lexeme
|
|
||||||
from tokens import Tok
|
|
||||||
|
|
||||||
@dataclass(frozen=True)
|
@dataclass(frozen=True)
|
||||||
class IRProp:
|
class IRProp:
|
||||||
"""
|
"""
|
||||||
|
@ -13,22 +10,22 @@ class IRProp:
|
||||||
distinction is made between predicates (n-arity, logical statements), functions
|
distinction is made between predicates (n-arity, logical statements), functions
|
||||||
(positive-arity functions over objects), and constants (stand-ins for objects)
|
(positive-arity functions over objects), and constants (stand-ins for objects)
|
||||||
"""
|
"""
|
||||||
lexeme: Lexeme[Tok]
|
name: str
|
||||||
"""
|
"""
|
||||||
The identifier of this thing, including its location in the source
|
The identifier of this thing, including its location in the source
|
||||||
"""
|
"""
|
||||||
arguments: 'Sequence[IRTerm]'
|
arguments: 'Sequence[IRTerm]'
|
||||||
def __str__(self) -> str:
|
def __str__(self) -> str:
|
||||||
return f'{self.lexeme.matched_string}({",".join(str(arg) for arg in self.arguments)})'
|
return f'{self.name}({",".join(str(arg) for arg in self.arguments)})'
|
||||||
|
|
||||||
@dataclass(frozen=True)
|
@dataclass(frozen=True)
|
||||||
class IRVar:
|
class IRVar:
|
||||||
"""
|
"""
|
||||||
A variable which may be substituted for any other term
|
A variable which may be substituted for any other term
|
||||||
"""
|
"""
|
||||||
lexeme: Lexeme[Tok]
|
name: str
|
||||||
def __str__(self) -> str:
|
def __str__(self) -> str:
|
||||||
return f'*{self.lexeme.matched_string}'
|
return f'*{self.name}'
|
||||||
|
|
||||||
@dataclass(frozen=True)
|
@dataclass(frozen=True)
|
||||||
class IRNeg:
|
class IRNeg:
|
||||||
|
|
Loading…
Reference in a new issue