agtest/agtypeck.py

29 lines
773 B
Python

from typing import *
from agast import *
class TypecheckResult:
def __init__(self, pd: str):
self.parser_data = pd
def typecheck(program: List[Decl]) -> TypecheckResult:
i = 0
def gen(name: str = "") -> str:
return f"__ag{i:03}{name}"
# collect a list of name -> iface declarations
ifaces: Dict[str, Decl] = dict(
map(lambda c: (c.name, c),
filter(lambda c: isinstance(c, Iface),
program)))
print(ifaces)
# a high-level dictionary of productions; this has sub-productions
# that should be further expanded at a later step before converting
# into lark code
productions_hi: Dict[str, Union[str, List[str]]] = dict()
for node in filter(lambda c: isinstance(c, Node), program):
print(node)
return TypecheckResult("")