From 153ab54be61aff64d57799d1037c4b91deb836c5 Mon Sep 17 00:00:00 2001 From: Kayne Ruse Date: Thu, 26 Dec 2024 14:46:12 +1100 Subject: [PATCH] Fixed some incorrect precedence rules --- source/toy_parser.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/source/toy_parser.c b/source/toy_parser.c index 77b10c8..07c1abc 100644 --- a/source/toy_parser.c +++ b/source/toy_parser.c @@ -91,6 +91,7 @@ typedef enum ParsingPrecedence { PREC_ASSIGNMENT, PREC_GROUP, PREC_TERNARY, + PREC_NEGATE, PREC_OR, PREC_AND, PREC_COMPARISON, @@ -124,7 +125,7 @@ static ParsingTuple parsingRulesetTable[] = { {PREC_PRIMARY,literal,NULL},// TOY_TOKEN_NULL, //variable names (initially handled as a string) - {PREC_NONE,nameString,NULL},// TOY_TOKEN_NAME, + {PREC_PRIMARY,nameString,NULL},// TOY_TOKEN_NAME, //types {PREC_NONE,NULL,NULL},// TOY_TOKEN_TYPE_BOOLEAN, @@ -194,7 +195,7 @@ static ParsingTuple parsingRulesetTable[] = { {PREC_COMPARISON,NULL,binary},// TOY_TOKEN_OPERATOR_COMPARE_GREATER_EQUAL, //structural operators - {PREC_NONE,group,NULL},// TOY_TOKEN_OPERATOR_PAREN_LEFT, + {PREC_GROUP,group,NULL},// TOY_TOKEN_OPERATOR_PAREN_LEFT, {PREC_NONE,NULL,NULL},// TOY_TOKEN_OPERATOR_PAREN_RIGHT, {PREC_GROUP,compound,aggregate},// TOY_TOKEN_OPERATOR_BRACKET_LEFT, {PREC_NONE,compound,aggregate},// TOY_TOKEN_OPERATOR_BRACKET_RIGHT, @@ -204,7 +205,7 @@ static ParsingTuple parsingRulesetTable[] = { //other operators {PREC_AND,NULL,binary},// TOY_TOKEN_OPERATOR_AND, {PREC_OR,NULL,binary},// TOY_TOKEN_OPERATOR_OR, - {PREC_NONE,unary,NULL},// TOY_TOKEN_OPERATOR_NEGATE, + {PREC_NEGATE,unary,NULL},// TOY_TOKEN_OPERATOR_NEGATE, {PREC_NONE,NULL,NULL},// TOY_TOKEN_OPERATOR_QUESTION, {PREC_GROUP,compound,aggregate},// TOY_TOKEN_OPERATOR_COLON,