Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ if(NOT PROJECTM_EVAL_FLOAT_SIZE EQUAL 8 AND NOT PROJECTM_EVAL_FLOAT_SIZE EQUAL 4
endif()

project(projectm-eval
VERSION 1.0.1
VERSION 1.0.2
LANGUAGES ${LANGUAGES} # Using "enable_language(CXX)" in the test dir will NOT work properly!
)

Expand Down
8 changes: 4 additions & 4 deletions projectm-eval/Compiler.c
Original file line number Diff line number Diff line change
Expand Up @@ -2008,11 +2008,11 @@ YYLTYPE yylloc = yyloc_default;
break;

case 33: /* expression: expression BOOLOR expression */
{ PRJM_EVAL_FUNC2((yyval.expression), "bor", (yyvsp[-2].expression), (yyvsp[0].expression)) }
{ PRJM_EVAL_FUNC2((yyval.expression), "_or", (yyvsp[-2].expression), (yyvsp[0].expression)) }
break;

case 34: /* expression: expression BOOLAND expression */
{ PRJM_EVAL_FUNC2((yyval.expression), "band", (yyvsp[-2].expression), (yyvsp[0].expression)) }
{ PRJM_EVAL_FUNC2((yyval.expression), "_and", (yyvsp[-2].expression), (yyvsp[0].expression)) }
break;

case 35: /* expression: expression '=' expression */
Expand Down Expand Up @@ -2052,11 +2052,11 @@ YYLTYPE yylloc = yyloc_default;
break;

case 44: /* expression: expression '|' expression */
{ PRJM_EVAL_FUNC2((yyval.expression), "bor", (yyvsp[-2].expression), (yyvsp[0].expression)) }
{ PRJM_EVAL_FUNC2((yyval.expression), "/*or*/", (yyvsp[-2].expression), (yyvsp[0].expression)) }
break;

case 45: /* expression: expression '&' expression */
{ PRJM_EVAL_FUNC2((yyval.expression), "band", (yyvsp[-2].expression), (yyvsp[0].expression)) }
{ PRJM_EVAL_FUNC2((yyval.expression), "/*and*/", (yyvsp[-2].expression), (yyvsp[0].expression)) }
break;

case 46: /* expression: '-' expression */
Expand Down
8 changes: 4 additions & 4 deletions projectm-eval/Compiler.y
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,8 @@ expression:
| expression[left] '>' expression[right] { PRJM_EVAL_FUNC2($$, "_above", $left, $right) }

/* Boolean operators */
| expression[left] BOOLOR expression[right] { PRJM_EVAL_FUNC2($$, "bor", $left, $right) }
| expression[left] BOOLAND expression[right] { PRJM_EVAL_FUNC2($$, "band", $left, $right) }
| expression[left] BOOLOR expression[right] { PRJM_EVAL_FUNC2($$, "_or", $left, $right) }
| expression[left] BOOLAND expression[right] { PRJM_EVAL_FUNC2($$, "_and", $left, $right) }

/* Assignment operator */
| expression[left] '=' expression[right] { PRJM_EVAL_FUNC2($$, "_set", $left, $right) }
Expand All @@ -164,8 +164,8 @@ expression:
| expression[left] '/' expression[right] { PRJM_EVAL_FUNC2($$, "_div", $left, $right) }
| expression[left] '%' expression[right] { PRJM_EVAL_FUNC2($$, "_mod", $left, $right) }
| expression[left] '^' expression[right] { PRJM_EVAL_FUNC2($$, "pow", $left, $right) }
| expression[left] '|' expression[right] { PRJM_EVAL_FUNC2($$, "bor", $left, $right) }
| expression[left] '&' expression[right] { PRJM_EVAL_FUNC2($$, "band", $left, $right) }
| expression[left] '|' expression[right] { PRJM_EVAL_FUNC2($$, "/*or*/", $left, $right) }
| expression[left] '&' expression[right] { PRJM_EVAL_FUNC2($$, "/*and*/", $left, $right) }

/* Unary operators */
| '-' expression[value] %prec NEG { PRJM_EVAL_FUNC1($$, "_neg", $value) }
Expand Down
4 changes: 2 additions & 2 deletions projectm-eval/Scanner.c
Original file line number Diff line number Diff line change
Expand Up @@ -1546,11 +1546,11 @@ YY_RULE_SETUP
YY_BREAK
case 37:
YY_RULE_SETUP
{ return '%'; }
{ return '&'; }
YY_BREAK
case 38:
YY_RULE_SETUP
{ return '^'; }
{ return '|'; }
YY_BREAK
case 39:
YY_RULE_SETUP
Expand Down
4 changes: 2 additions & 2 deletions projectm-eval/Scanner.l
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ NAME [_a-zA-Z][_a-zA-Z0-9]*
"/" { return '/'; }
"%" { return '%'; }
"^" { return '^'; }
"&" { return '%'; }
"|" { return '^'; }
"&" { return '&'; }
"|" { return '|'; }
"!" { return '!'; }
"=" { return '='; }

Expand Down
32 changes: 32 additions & 0 deletions projectm-eval/TreeFunctions.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ static prjm_eval_function_def_t intrinsic_function_table[] = {
{ "/*const*/", prjm_eval_func_const, 0, true, false },
{ "/*var*/", prjm_eval_func_var, 0, false, false },
{ "/*list*/", prjm_eval_func_execute_list, 1, true, false },
{ "/*or*/", prjm_eval_func_or, 2, true, false },
{ "/*and*/", prjm_eval_func_and, 2, true, false },
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using the special "comment" syntax here as ns-eel2 doesn't have any internal name for these two operator implementations. Since the scanner will skip over comments, this text can never occur as a function token in the parser and thus doesn't influence the syntax in any way.


{ "if", prjm_eval_func_if, 3, true, false },
{ "_if", prjm_eval_func_if, 3, true, false },
Expand Down Expand Up @@ -777,6 +779,21 @@ prjm_eval_function_decl(orop)
assign_ret_val((PRJM_EVAL_F) ((int)(**ret_val) | (int)(*val2_ptr)));
}

prjm_eval_function_decl(or)
{
assert_valid_ctx();

PRJM_EVAL_F val1 = .0;
PRJM_EVAL_F* val1_ptr = &val1;
PRJM_EVAL_F val2 = .0;
PRJM_EVAL_F* val2_ptr = &val2;

invoke_arg(0, &val1_ptr);
invoke_arg(1, &val2_ptr);

assign_ret_val((PRJM_EVAL_F) ((int)(*val1_ptr) | (int)(*val2_ptr)));
}

prjm_eval_function_decl(andop)
{
assert_valid_ctx();
Expand All @@ -790,6 +807,21 @@ prjm_eval_function_decl(andop)
assign_ret_val((PRJM_EVAL_F) ((int)(**ret_val) & (int)(*val2_ptr)));
}

prjm_eval_function_decl(and)
{
assert_valid_ctx();

PRJM_EVAL_F val1 = .0;
PRJM_EVAL_F* val1_ptr = &val1;
PRJM_EVAL_F val2 = .0;
PRJM_EVAL_F* val2_ptr = &val2;

invoke_arg(0, &val1_ptr);
invoke_arg(1, &val2_ptr);

assign_ret_val((PRJM_EVAL_F) ((int)(*val1_ptr) & (int)(*val2_ptr)));
}

prjm_eval_function_decl(modop)
{
assert_valid_ctx();
Expand Down
2 changes: 2 additions & 0 deletions projectm-eval/TreeFunctions.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ prjm_eval_function_decl(sub);
prjm_eval_function_decl(mul);
prjm_eval_function_decl(div);
prjm_eval_function_decl(mod);
prjm_eval_function_decl(or);
prjm_eval_function_decl(and);
prjm_eval_function_decl(band_op);
prjm_eval_function_decl(bor_op);
prjm_eval_function_decl(band_func);
Expand Down
Loading