Compare commits

...

2 commits

Author SHA1 Message Date
94e3b1d239 added more test cases for bitwise operations 2025-08-17 22:37:32 -05:00
6de059d854 . 2025-08-17 22:33:49 -05:00
2 changed files with 112 additions and 58 deletions

57
main.c
View file

@ -2131,63 +2131,6 @@ struct expression* parse(const char* text)
return root;
}
#if 0
struct value** evaluate_lvalue(
struct expression* expression,
struct scope* scope)
{
switch (expression->kind)
{
case ek_syntax_error: assert(0); break;
case ek_variable:
{
return scope_lookup(scope, expression->string);
}
case ek_literal: TODO; break;
case ek_add: TODO; break;
case ek_subtract: TODO; break;
case ek_multiply: TODO; break;
case ek_divide: TODO; break;
case ek_positive: TODO; break;
case ek_negative: TODO; break;
case ek_greater_than: TODO; break;
case ek_greater_than_equal_to: TODO; break;
case ek_less_than: TODO; break;
case ek_less_than_equal_to: TODO; break;
case ek_equal_to: TODO; break;
case ek_not_equal_to: TODO; break;
case ek_logical_not: TODO; break;
case ek_logical_and: TODO; break;
case ek_logical_or: TODO; break;
case ek_ternary: TODO; break;
case ek_remainder: TODO; break;
case ek_assign:
{
TODO;
break;
};
case ek_comma:
{
TODO;
break;
};
}
return NULL;
}
#endif
struct value* evaluate(
struct expression* expression,
struct scope* scope)

View file

@ -49,6 +49,11 @@
"ftime": 1755473136.3299906,
"output": "???"
},
"!~1": {
"exit": 0,
"ftime": 1755488048.898679,
"output": "???"
},
"%": {
"exit": 1,
"ftime": 1755472489.1916378,
@ -754,6 +759,14 @@
"ftime": 1755477196.619504,
"output": "syntax error!\n1 @ 1 = 1\n \u2191\n \u2514 unexpected unknown token '@'\n"
},
"1 ^ 2": {
"exit": 0,
"output": "???"
},
"1 ^ y": {
"exit": 0,
"output": "???"
},
"1 | 2": {
"exit": 0,
"ftime": 1755477480.7324803,
@ -1204,6 +1217,18 @@
"ftime": 1755476394.9838262,
"output": "syntax error!\n7 % @\n \u2191\n \u2514 unknown token '@'\n"
},
"8 & 12": {
"exit": 0,
"output": "???"
},
"8 ^ 12": {
"exit": 0,
"output": "???"
},
"8 | 12": {
"exit": 0,
"output": "???"
},
":": {
"exit": 0,
"ftime": 1755473136.3300014,
@ -1359,6 +1384,10 @@
"ftime": 1755473136.3300033,
"output": "???"
},
"x &= 3": {
"exit": 0,
"output": "???"
},
"x * 1": {
"exit": 0,
"ftime": 1755477704.4151225,
@ -1474,6 +1503,22 @@
"ftime": 1755473136.3300042,
"output": "???"
},
"x = 1, x += 1": {
"exit": 0,
"output": "???"
},
"x = 2, x *= 3": {
"exit": 0,
"output": "???"
},
"x = 2, x -= 1": {
"exit": 0,
"output": "???"
},
"x = 2, x /= 3": {
"exit": 0,
"output": "???"
},
"x = 3": {
"exit": 0,
"ftime": 1755477108.2987745,
@ -1484,6 +1529,42 @@
"ftime": 1755473136.3300042,
"output": "???"
},
"x = 5, x %= 3": {
"exit": 0,
"output": "???"
},
"x = 5, x &= 3": {
"exit": 0,
"output": "???"
},
"x = 5, x //= 3": {
"exit": 0,
"output": "???"
},
"x = 5, x <<= 3": {
"exit": 0,
"output": "???"
},
"x = 5, x >>= 3": {
"exit": 0,
"output": "???"
},
"x = 5, x ^= 3": {
"exit": 0,
"output": "???"
},
"x = 5, x |= 3": {
"exit": 0,
"output": "???"
},
"x = 8, x |= 3": {
"exit": 0,
"output": "???"
},
"x = y": {
"exit": 0,
"output": "???"
},
"x == 2": {
"exit": 0,
"ftime": 1755473136.3300045,
@ -1564,6 +1645,18 @@
"ftime": 1755474539.2456896,
"output": "syntax error!\nx @ y\n \u2191\n \u2514 unexpected unknown token '@'\n"
},
"x ^ 2": {
"exit": 0,
"output": "???"
},
"x ^ y": {
"exit": 0,
"output": "???"
},
"x ^= 3": {
"exit": 0,
"output": "???"
},
"x | 2": {
"exit": 0,
"ftime": 1755477480.7324834,
@ -1574,6 +1667,10 @@
"ftime": 1755477480.7324834,
"output": "???"
},
"x |= 3": {
"exit": 0,
"output": "???"
},
"x || 0": {
"exit": 0,
"ftime": 1755475034.2312126,
@ -1609,19 +1706,33 @@
"ftime": 1755474227.929854,
"output": "syntax error!\n||\n\u2191\n\u2514 unexpected logical-or token\n"
},
"~!1": {
"exit": 0,
"ftime": 1755488048.8986857,
"output": "???"
},
"~0": {
"exit": 0,
"ftime": 1755477480.7324836,
"output": "???"
},
"~0b1010": {
"exit": 0,
"output": "???"
},
"~1": {
"exit": 0,
"ftime": 1755487439.1243694,
"ftime": 1755488031.3807857,
"output": "???"
},
"~x": {
"exit": 0,
"ftime": 1755477480.7324839,
"output": "???"
},
"~~1": {
"exit": 0,
"ftime": 1755488048.9001203,
"output": "???"
}
}