diff options
| author | Mustafa Quraish <[email protected]> | 2022-02-05 22:34:44 -0500 |
|---|---|---|
| committer | Mustafa Quraish <[email protected]> | 2022-02-05 22:34:44 -0500 |
| commit | 7b0bfa91b400e89f32f19ef2987200562bbe3f8f (patch) | |
| tree | d44f6cb1525ebbe6cc0c958191dd4ab1d76eb4f6 /compiler/ast.cup | |
| parent | [cup] Fix error in codegen for `if` (diff) | |
| download | cup-7b0bfa91b400e89f32f19ef2987200562bbe3f8f.tar.xz cup-7b0bfa91b400e89f32f19ef2987200562bbe3f8f.zip | |
[cup] Add support for builtin functions, add `print()`
Diffstat (limited to 'compiler/ast.cup')
| -rw-r--r-- | compiler/ast.cup | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/compiler/ast.cup b/compiler/ast.cup index 82e8477..2ba677b 100644 --- a/compiler/ast.cup +++ b/compiler/ast.cup @@ -1,5 +1,6 @@ -import "std/vector.cup" +import "compiler/tokens.cup" import "compiler/types.cup" +import "std/vector.cup" enum NodeType { // Unary @@ -149,6 +150,14 @@ fn node_from_int_literal(val: int): Node* { return node; } +fn variable_new(name: char*, typ: Type*, offset: int): Variable* { + let v: Variable* = malloc(sizeof(Variable)); + v.name = name; + v.typ = typ; + v.offset = offset; + return v; +} + fn block_add_child(block: Node*, child: Node*) { if (block.d.block.children == null) block.d.block.children = vector_new(); |