Got the compiler partially working

This commit is contained in:
2022-08-05 16:29:12 +01:00
parent 1ff32fe101
commit cd05d5d84a
17 changed files with 601 additions and 26 deletions

View File

@@ -6,7 +6,7 @@
void freeNode(Node* node) {
switch(node->type) {
case NODE_ATOMIC:
case NODE_LITERAL:
freeLiteral(node->atomic.literal);
break;
@@ -23,18 +23,27 @@ void freeNode(Node* node) {
FREE(Node, node);
}
void emitAtomicLiteral(Node** nodeHandle, Literal literal) {
void emitNodeLiteral(Node** nodeHandle, Literal literal) {
//allocate a new node
*nodeHandle = ALLOCATE(Node, 1);
(*nodeHandle)->type = NODE_ATOMIC;
(*nodeHandle)->type = NODE_LITERAL;
(*nodeHandle)->atomic.literal = literal;
}
void emitNodeUnary(Node** nodeHandle, Opcode opcode) {
//allocate a new node
*nodeHandle = ALLOCATE(Node, 1);
(*nodeHandle)->type = NODE_UNARY;
(*nodeHandle)->unary.opcode = opcode;
(*nodeHandle)->unary.child = NULL;
}
void printNode(Node* node) {
switch(node->type) {
case NODE_ATOMIC:
printf("atomic:");
case NODE_LITERAL:
printf("literal:");
printLiteral(node->atomic.literal);
break;