Skip to content

Commit

Permalink
let Ast behave like a tuple of (node, *children)
Browse files Browse the repository at this point in the history
  • Loading branch information
hoosierEE committed May 14, 2024
1 parent 042cf94 commit 61d5dc8
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion prototype/Ast.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
class Ast:#(node children*)
def __init__(s,n,*c): s.node,s.children = n,c
def __init__(s,n,*c): s.node,s.children = s.t = n,c
def __getitem__(s,i): return s.t[i]
def __repr__(s):
n = dict(zip("{[(;/\\'",'lam prg lst seq fld scn ech'.split())).get(s.node,s.node)
return f'({n} {" ".join(map(repr,s.children))})' if s.children else str(n)

0 comments on commit 61d5dc8

Please sign in to comment.