From 1430aefdf3207f34294401bf9323ce143796d3c4 Mon Sep 17 00:00:00 2001 From: Kayne Ruse Date: Thu, 11 Aug 2022 14:01:33 +0100 Subject: [PATCH] Bugfix when strings are unterminated --- source/parser.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/source/parser.c b/source/parser.c index 86860e1..be22284 100644 --- a/source/parser.c +++ b/source/parser.c @@ -36,7 +36,6 @@ static void advance(Parser* parser) { if (parser->current.type == TOKEN_ERROR) { error(parser, parser->current, "Lexer error"); - printf(parser->lexer->source); } } @@ -146,10 +145,19 @@ static Opcode compound(Parser* parser, Node** nodeHandle, bool canBeAssigned) { //store the left parsePrecedence(parser, &left, PREC_PRIMARY); + if (!left) { //error + return OP_EOF; + } + //detect a dictionary if (match(parser, TOKEN_COLON)) { parsePrecedence(parser, &right, PREC_PRIMARY); + if (!right) { //error + freeNode(left); + return OP_EOF; + } + //check we ARE defining a dictionary if (array) { error(parser, parser->previous, "Incorrect detection between array and dictionary");