Minor tweaks

This commit is contained in:
2022-08-08 03:42:48 +01:00
parent ceeca9d40f
commit 3fb952e3c2
4 changed files with 10 additions and 2 deletions

View File

@@ -79,6 +79,8 @@ void writeCompiler(Compiler* compiler, Node* node) {
writeCompiler(compiler, node->grouping.child); writeCompiler(compiler, node->grouping.child);
compiler->bytecode[compiler->count++] = (unsigned char)OP_GROUPING_END; //1 byte compiler->bytecode[compiler->count++] = (unsigned char)OP_GROUPING_END; //1 byte
break; break;
//TODO: conditional
} }
} }

View File

@@ -74,6 +74,10 @@ void emitNodeGrouping(Node** nodeHandle) {
} }
void printNode(Node* node) { void printNode(Node* node) {
if (node == NULL) {
return;
}
switch(node->type) { switch(node->type) {
case NODE_ERROR: case NODE_ERROR:
printf("error"); printf("error");
@@ -92,7 +96,7 @@ void printNode(Node* node) {
case NODE_BINARY: case NODE_BINARY:
printf("binary-left:"); printf("binary-left:");
printNode(node->binary.left); printNode(node->binary.left);
printf("binary-right:"); printf(";binary-right:");
printNode(node->binary.right); printNode(node->binary.right);
printf(";"); printf(";");
break; break;

View File

@@ -12,6 +12,7 @@ typedef enum NodeType {
NODE_UNARY, //one child NODE_UNARY, //one child
NODE_BINARY, //two children, left and right NODE_BINARY, //two children, left and right
NODE_GROUPING, //one child NODE_GROUPING, //one child
// NODE_CONDITIONAL, //three children: conditional, then path, else path
} NodeType; } NodeType;
typedef struct NodeLiteral { typedef struct NodeLiteral {

View File

@@ -62,7 +62,7 @@ static void synchronize(Parser* parser) {
//these tokens can start a line //these tokens can start a line
case TOKEN_ASSERT: case TOKEN_ASSERT:
case TOKEN_BREAK: case TOKEN_BREAK:
case TOKEN_CONST: case TOKEN_CLASS:
case TOKEN_CONTINUE: case TOKEN_CONTINUE:
case TOKEN_DO: case TOKEN_DO:
case TOKEN_EXPORT: case TOKEN_EXPORT:
@@ -72,6 +72,7 @@ static void synchronize(Parser* parser) {
case TOKEN_IMPORT: case TOKEN_IMPORT:
case TOKEN_PRINT: case TOKEN_PRINT:
case TOKEN_RETURN: case TOKEN_RETURN:
case TOKEN_TYPE:
case TOKEN_VAR: case TOKEN_VAR:
case TOKEN_WHILE: case TOKEN_WHILE:
parser->panic = false; parser->panic = false;