mirror of
https://github.com/krgamestudios/Toy.git
synced 2026-04-15 23:04:08 +10:00
Implemented logical && and ||
This commit is contained in:
@@ -96,7 +96,6 @@ typedef enum {
|
||||
PREC_TERNARY,
|
||||
PREC_OR,
|
||||
PREC_AND,
|
||||
// PREC_EQUALITY,
|
||||
PREC_COMPARISON,
|
||||
PREC_TERM,
|
||||
PREC_FACTOR,
|
||||
@@ -382,6 +381,16 @@ static Opcode binary(Parser* parser, Node** nodeHandle) {
|
||||
return OP_COMPARE_GREATER_EQUAL;
|
||||
}
|
||||
|
||||
case TOKEN_AND: {
|
||||
parsePrecedence(parser, nodeHandle, PREC_COMPARISON);
|
||||
return OP_AND;
|
||||
}
|
||||
|
||||
case TOKEN_OR: {
|
||||
parsePrecedence(parser, nodeHandle, PREC_COMPARISON);
|
||||
return OP_OR;
|
||||
}
|
||||
|
||||
default:
|
||||
error(parser, parser->previous, "Unexpected token passed to binary precedence rule");
|
||||
return OP_EOF;
|
||||
@@ -689,8 +698,8 @@ ParseRule parseRules[] = { //must match the token types
|
||||
{NULL, binary, PREC_COMPARISON},// TOKEN_GREATER,
|
||||
{NULL, binary, PREC_COMPARISON},// TOKEN_LESS_EQUAL,
|
||||
{NULL, binary, PREC_COMPARISON},// TOKEN_GREATER_EQUAL,
|
||||
{NULL, NULL, PREC_NONE},// TOKEN_AND,
|
||||
{NULL, NULL, PREC_NONE},// TOKEN_OR,
|
||||
{NULL, binary, PREC_AND},// TOKEN_AND,
|
||||
{NULL, binary, PREC_OR},// TOKEN_OR,
|
||||
|
||||
//other operators
|
||||
{NULL, NULL, PREC_NONE},// TOKEN_COLON,
|
||||
|
||||
Reference in New Issue
Block a user