Lexer partially working

This commit is contained in:
2022-08-03 14:06:54 +01:00
parent 3cad70dddd
commit 1ff32fe101
17 changed files with 687 additions and 34 deletions

43
source/node.h Normal file
View File

@@ -0,0 +1,43 @@
#pragma once
#include "opcodes.h"
#include "literal.h"
//nodes are the intermediaries between parsers and compilers
typedef union _node Node;
typedef enum NodeType {
NODE_ATOMIC, //a simple value
NODE_UNARY, //one child
NODE_BINARY, //two children, left and right
// NODE_GROUPING,
} NodeType;
typedef struct NodeAtomic {
NodeType type;
Literal literal;
} NodeAtomic;
typedef struct NodeUnary {
NodeType type;
Node* child;
} NodeUnary;
typedef struct NodeBinary {
NodeType type;
Node* left;
Node* right;
} NodeBinary;
union _node {
NodeType type;
NodeAtomic atomic;
NodeUnary unary;
NodeBinary binary;
};
void freeNode(Node* node);
void emitAtomicLiteral(Node** nodeHandle, Literal literal);
void printNode(Node* node);