feat: Add logic conjunction and disjunction to grammar and ast

This commit is contained in:
overflowerror 2024-02-28 21:54:37 +01:00
parent f7f5238e51
commit db26cc5182
3 changed files with 14 additions and 0 deletions

View file

@ -58,6 +58,8 @@ enum calc_operator {
MODULO,
EQUALS,
NOT_EQUALS,
CONJUNCTION,
DISJUNCTION,
};
struct calc_expression {

View file

@ -81,6 +81,8 @@ strbuf_t strbuf = NULL;
<INITIAL>"==" { return EQUAL; }
<INITIAL>"!=" { return NOT_EQUAL; }
<INITIAL>"&&" { return AND; }
<INITIAL>"||" { return OR; }
<INITIAL>"(" { return OPENING_BRACKETS; }
<INITIAL>")" { return CLOSING_BRACKETS; }

View file

@ -52,6 +52,8 @@ extern struct block* program;
%token MOD
%token EQUAL
%token NOT_EQUAL
%token AND
%token OR
%token OPENING_BRACKETS
%token CLOSING_BRACKETS
@ -190,6 +192,14 @@ op: PLUS
{
$$ = NOT_EQUALS;
}
| AND
{
$$ = CONJUNCTION;
}
| OR
{
$$ = DISJUNCTION;
}
;
literal: NUM