mirror of
https://github.com/sigmasternchen/macrofuck
synced 2025-03-15 07:08:56 +00:00
feat: Add logic conjunction and disjunction to grammar and ast
This commit is contained in:
parent
f7f5238e51
commit
db26cc5182
3 changed files with 14 additions and 0 deletions
|
@ -58,6 +58,8 @@ enum calc_operator {
|
|||
MODULO,
|
||||
EQUALS,
|
||||
NOT_EQUALS,
|
||||
CONJUNCTION,
|
||||
DISJUNCTION,
|
||||
};
|
||||
|
||||
struct calc_expression {
|
||||
|
|
|
@ -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; }
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue