semantic+main: add the BuiltinContext and use it as semantic root
This commit is contained in:
parent
159ee81375
commit
45ce13ae99
2 changed files with 10 additions and 1 deletions
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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")
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue