mirror of
https://github.com/krgamestudios/Toy.git
synced 2026-04-15 14:54:07 +10:00
Minor tweaks
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user