From 7b0bfa91b400e89f32f19ef2987200562bbe3f8f Mon Sep 17 00:00:00 2001 From: Mustafa Quraish Date: Sat, 5 Feb 2022 22:34:44 -0500 Subject: [cup] Add support for builtin functions, add `print()` --- compiler/ast.cup | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'compiler/ast.cup') 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(); -- cgit v1.2.3