Added subscript parsing
This commit is contained in:
@@ -166,11 +166,14 @@ def prepare(root: lbn.Root, *, ban_macro_name = None) -> list:
|
||||
if (n.input.name in bound_variables):
|
||||
raise lbn.ReductionError(f"Bound variable name conflict: \"{n.input.name}\"")
|
||||
else:
|
||||
bound_variables[n.input.name] = lbn.Bound(n.input.name)
|
||||
bound_variables[n.input.name] = lbn.Bound(
|
||||
lamb.utils.remove_sub(n.input.name),
|
||||
macro_name = n.input.name
|
||||
)
|
||||
n.input = bound_variables[n.input.name]
|
||||
|
||||
elif s == lbn.Direction.LEFT:
|
||||
del bound_variables[n.input.name]
|
||||
del bound_variables[n.input.macro_name] # type: ignore
|
||||
|
||||
return warnings
|
||||
|
||||
|
||||
@@ -333,11 +333,16 @@ class History(ExpandableEndNode):
|
||||
|
||||
bound_counter = 0
|
||||
class Bound(EndNode):
|
||||
def __init__(self, name: str, *, forced_id = None, runner = None):
|
||||
def __init__(self, name: str, *, forced_id = None, runner = None, macro_name = None):
|
||||
self.name = name
|
||||
global bound_counter
|
||||
self.runner = runner # type: ignore
|
||||
|
||||
# The name of the macro this bound came from.
|
||||
# Always equal to self.name, unless the macro
|
||||
# this came from had a subscript.
|
||||
self.macro_name: str | None = macro_name
|
||||
|
||||
if forced_id is None:
|
||||
self.identifier = bound_counter
|
||||
bound_counter += 1
|
||||
|
||||
Reference in New Issue
Block a user