semantic+main: add the BuiltinContext and use it as semantic root

This commit is contained in:
Antoine Viallon 2023-05-23 00:48:52 +02:00
parent 159ee81375
commit 45ce13ae99
Signed by: aviallon
GPG key ID: D126B13AB555E16F
2 changed files with 10 additions and 1 deletions

View file

@ -43,7 +43,7 @@ def main():
ast = parser.parse()
ast.pprint(depth=10)
context = semantic.Context("root")
context = semantic.BuiltinContext()
ast.semantic_analysis(context)
intermediate_representation = ast.intermediate_representation()

View file

@ -131,3 +131,12 @@ class Context:
def __repr__(self) -> str:
return self._pprint()
class BuiltinContext(Context):
def __init__(self):
super().__init__(name="builtins", parent=None)
self.types = {
"__unknown": Type(self, "__unknown", "builtin"),
"uint32": Type(self, "uint32", "builtin")
}