Kaydet (Commit) b1c15743 authored tarafından Batuhan Taşkaya's avatar Batuhan Taşkaya

Representations

üst 382d74ba
...@@ -17,19 +17,26 @@ class Node: ...@@ -17,19 +17,26 @@ class Node:
def add_child(self, child): def add_child(self, child):
self.children.append(child) self.children.append(child)
def __str__(self):
level = 0
for child in self.children:
print(child)
@dataclass @dataclass
class KVNode: class KVNode:
lhs: Any lhs: Any
rhs: Any rhs: Any
def __str__(self):
return f"\n{self.lhs} => {self.rhs} | "
@dataclass @dataclass
class LinkedNode: class LinkedNode:
prev: Optional[LinkedNode] prev: Optional[LinkedNode]
value: Any value: Any
def __str__(self): def __str__(self):
return f"{value} ->" return f"\n{self.value} ->"
class Viz: class Viz:
typeregs = {} typeregs = {}
...@@ -87,3 +94,4 @@ node = viz.visit({ ...@@ -87,3 +94,4 @@ node = viz.visit({
(1, 2): 'a' (1, 2): 'a'
}) })
print(node)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment