diff --git a/source/compiler.c b/source/compiler.c index 3b26106..ffbee55 100644 --- a/source/compiler.c +++ b/source/compiler.c @@ -79,6 +79,8 @@ void writeCompiler(Compiler* compiler, Node* node) { writeCompiler(compiler, node->grouping.child); compiler->bytecode[compiler->count++] = (unsigned char)OP_GROUPING_END; //1 byte break; + + //TODO: conditional } } diff --git a/source/node.c b/source/node.c index 044bf38..260ac9d 100644 --- a/source/node.c +++ b/source/node.c @@ -74,6 +74,10 @@ void emitNodeGrouping(Node** nodeHandle) { } void printNode(Node* node) { + if (node == NULL) { + return; + } + switch(node->type) { case NODE_ERROR: printf("error"); @@ -92,7 +96,7 @@ void printNode(Node* node) { case NODE_BINARY: printf("binary-left:"); printNode(node->binary.left); - printf("binary-right:"); + printf(";binary-right:"); printNode(node->binary.right); printf(";"); break; diff --git a/source/node.h b/source/node.h index 11a1812..9d24f48 100644 --- a/source/node.h +++ b/source/node.h @@ -12,6 +12,7 @@ typedef enum NodeType { NODE_UNARY, //one child NODE_BINARY, //two children, left and right NODE_GROUPING, //one child + // NODE_CONDITIONAL, //three children: conditional, then path, else path } NodeType; typedef struct NodeLiteral { diff --git a/source/parser.c b/source/parser.c index 2ff9d68..f518f62 100644 --- a/source/parser.c +++ b/source/parser.c @@ -62,7 +62,7 @@ static void synchronize(Parser* parser) { //these tokens can start a line case TOKEN_ASSERT: case TOKEN_BREAK: - case TOKEN_CONST: + case TOKEN_CLASS: case TOKEN_CONTINUE: case TOKEN_DO: case TOKEN_EXPORT: @@ -72,6 +72,7 @@ static void synchronize(Parser* parser) { case TOKEN_IMPORT: case TOKEN_PRINT: case TOKEN_RETURN: + case TOKEN_TYPE: case TOKEN_VAR: case TOKEN_WHILE: parser->panic = false;