added type checking

This commit is contained in:
Andrew Segavac
2021-05-12 06:40:11 -06:00
parent 9d9d42ebd5
commit cb30ad7040
5 changed files with 355 additions and 163 deletions

View File

@@ -1,24 +1,29 @@
import sys
from typing import List
from boring.parse import boring_parser, TreeToBoring, pretty_print
from boring.type_checker import TypeCheckTableBuilder, TypeComparison, check_types
from boring.type_checking import TypeChecker
if __name__ == "__main__":
with open(sys.argv[1]) as f:
tree = boring_parser.parse(f.read())
# print(tree)
result = TreeToBoring().transform(tree)
# pretty_print(result)
type_checker = TypeChecker()
while type_checker.with_module({}, result):
print('loop')
# type_checker.with_module({}, result)
pretty_print(result)
tctb = TypeCheckTableBuilder()
table: List[TypeComparison] = []
tctb.with_module({}, table, result)
for e in table:
print(e)
print('^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^')
check_types(table)
print('vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv')
for e in table:
print(e)
# tctb = TypeCheckTableBuilder()
# table: List[TypeComparison] = []
# tctb.with_module({}, table, result)
# for e in table:
# print(e)
# print("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^")
# check_types(table)
# print("vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv")
# for e in table:
# print(e)
# None, Some
# None skip, set