From 0fef3804a45c7f7ed88a372bd4e55dc84345926c Mon Sep 17 00:00:00 2001 From: Emi Simpson Date: Sun, 5 Mar 2023 17:01:10 -0500 Subject: [PATCH] Use strings in IR rather than lexemes --- grammar.py | 4 ++-- ir.py | 11 ++++------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/grammar.py b/grammar.py index 9e4a13f..6da8e2b 100644 --- a/grammar.py +++ b/grammar.py @@ -135,10 +135,10 @@ class ASTProp: return Err(CallingNonFunc(self.ident, bound_type)) if bound_type == IdentKind.Variable: - return Ok(IRVar(self.ident)) + return Ok(IRVar(self.ident.matched_string)) else: 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 def make_ir( diff --git a/ir.py b/ir.py index e7b0c3e..e4f3bac 100644 --- a/ir.py +++ b/ir.py @@ -1,9 +1,6 @@ from dataclasses import dataclass from typing import Sequence, TypeAlias -from lex import Lexeme -from tokens import Tok - @dataclass(frozen=True) class IRProp: """ @@ -13,22 +10,22 @@ class IRProp: distinction is made between predicates (n-arity, logical statements), functions (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 """ arguments: 'Sequence[IRTerm]' 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) class IRVar: """ A variable which may be substituted for any other term """ - lexeme: Lexeme[Tok] + name: str def __str__(self) -> str: - return f'*{self.lexeme.matched_string}' + return f'*{self.name}' @dataclass(frozen=True) class IRNeg: