2021-06-09 06:33:53 +00:00
|
|
|
from typing import *
|
|
|
|
from agast import *
|
|
|
|
|
2021-06-09 06:48:34 +00:00
|
|
|
class TypecheckResult:
|
|
|
|
def __init__(self, pd: str):
|
|
|
|
self.parser_data = pd
|
|
|
|
|
|
|
|
|
|
|
|
def typecheck(program: List[Decl]) -> TypecheckResult:
|
2021-06-09 06:33:53 +00:00
|
|
|
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)
|
|
|
|
|
2021-06-09 06:48:34 +00:00
|
|
|
# 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()
|
|
|
|
|
2021-06-09 06:33:53 +00:00
|
|
|
for node in filter(lambda c: isinstance(c, Node), program):
|
|
|
|
print(node)
|
2021-06-09 06:48:34 +00:00
|
|
|
|
|
|
|
return TypecheckResult("")
|