Compare commits
2 commits
efb1452750
...
94e3b1d239
| Author | SHA1 | Date | |
|---|---|---|---|
| 94e3b1d239 | |||
| 6de059d854 |
2 changed files with 112 additions and 58 deletions
57
main.c
57
main.c
|
|
@ -2131,63 +2131,6 @@ struct expression* parse(const char* text)
|
||||||
return root;
|
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 value* evaluate(
|
||||||
struct expression* expression,
|
struct expression* expression,
|
||||||
struct scope* scope)
|
struct scope* scope)
|
||||||
|
|
|
||||||
113
tests.json
113
tests.json
|
|
@ -49,6 +49,11 @@
|
||||||
"ftime": 1755473136.3299906,
|
"ftime": 1755473136.3299906,
|
||||||
"output": "???"
|
"output": "???"
|
||||||
},
|
},
|
||||||
|
"!~1": {
|
||||||
|
"exit": 0,
|
||||||
|
"ftime": 1755488048.898679,
|
||||||
|
"output": "???"
|
||||||
|
},
|
||||||
"%": {
|
"%": {
|
||||||
"exit": 1,
|
"exit": 1,
|
||||||
"ftime": 1755472489.1916378,
|
"ftime": 1755472489.1916378,
|
||||||
|
|
@ -754,6 +759,14 @@
|
||||||
"ftime": 1755477196.619504,
|
"ftime": 1755477196.619504,
|
||||||
"output": "syntax error!\n1 @ 1 = 1\n \u2191\n \u2514 unexpected unknown token '@'\n"
|
"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": {
|
"1 | 2": {
|
||||||
"exit": 0,
|
"exit": 0,
|
||||||
"ftime": 1755477480.7324803,
|
"ftime": 1755477480.7324803,
|
||||||
|
|
@ -1204,6 +1217,18 @@
|
||||||
"ftime": 1755476394.9838262,
|
"ftime": 1755476394.9838262,
|
||||||
"output": "syntax error!\n7 % @\n \u2191\n \u2514 unknown token '@'\n"
|
"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,
|
"exit": 0,
|
||||||
"ftime": 1755473136.3300014,
|
"ftime": 1755473136.3300014,
|
||||||
|
|
@ -1359,6 +1384,10 @@
|
||||||
"ftime": 1755473136.3300033,
|
"ftime": 1755473136.3300033,
|
||||||
"output": "???"
|
"output": "???"
|
||||||
},
|
},
|
||||||
|
"x &= 3": {
|
||||||
|
"exit": 0,
|
||||||
|
"output": "???"
|
||||||
|
},
|
||||||
"x * 1": {
|
"x * 1": {
|
||||||
"exit": 0,
|
"exit": 0,
|
||||||
"ftime": 1755477704.4151225,
|
"ftime": 1755477704.4151225,
|
||||||
|
|
@ -1474,6 +1503,22 @@
|
||||||
"ftime": 1755473136.3300042,
|
"ftime": 1755473136.3300042,
|
||||||
"output": "???"
|
"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": {
|
"x = 3": {
|
||||||
"exit": 0,
|
"exit": 0,
|
||||||
"ftime": 1755477108.2987745,
|
"ftime": 1755477108.2987745,
|
||||||
|
|
@ -1484,6 +1529,42 @@
|
||||||
"ftime": 1755473136.3300042,
|
"ftime": 1755473136.3300042,
|
||||||
"output": "???"
|
"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": {
|
"x == 2": {
|
||||||
"exit": 0,
|
"exit": 0,
|
||||||
"ftime": 1755473136.3300045,
|
"ftime": 1755473136.3300045,
|
||||||
|
|
@ -1564,6 +1645,18 @@
|
||||||
"ftime": 1755474539.2456896,
|
"ftime": 1755474539.2456896,
|
||||||
"output": "syntax error!\nx @ y\n \u2191\n \u2514 unexpected unknown token '@'\n"
|
"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": {
|
"x | 2": {
|
||||||
"exit": 0,
|
"exit": 0,
|
||||||
"ftime": 1755477480.7324834,
|
"ftime": 1755477480.7324834,
|
||||||
|
|
@ -1574,6 +1667,10 @@
|
||||||
"ftime": 1755477480.7324834,
|
"ftime": 1755477480.7324834,
|
||||||
"output": "???"
|
"output": "???"
|
||||||
},
|
},
|
||||||
|
"x |= 3": {
|
||||||
|
"exit": 0,
|
||||||
|
"output": "???"
|
||||||
|
},
|
||||||
"x || 0": {
|
"x || 0": {
|
||||||
"exit": 0,
|
"exit": 0,
|
||||||
"ftime": 1755475034.2312126,
|
"ftime": 1755475034.2312126,
|
||||||
|
|
@ -1609,19 +1706,33 @@
|
||||||
"ftime": 1755474227.929854,
|
"ftime": 1755474227.929854,
|
||||||
"output": "syntax error!\n||\n\u2191\n\u2514 unexpected logical-or token\n"
|
"output": "syntax error!\n||\n\u2191\n\u2514 unexpected logical-or token\n"
|
||||||
},
|
},
|
||||||
|
"~!1": {
|
||||||
|
"exit": 0,
|
||||||
|
"ftime": 1755488048.8986857,
|
||||||
|
"output": "???"
|
||||||
|
},
|
||||||
"~0": {
|
"~0": {
|
||||||
"exit": 0,
|
"exit": 0,
|
||||||
"ftime": 1755477480.7324836,
|
"ftime": 1755477480.7324836,
|
||||||
"output": "???"
|
"output": "???"
|
||||||
},
|
},
|
||||||
|
"~0b1010": {
|
||||||
|
"exit": 0,
|
||||||
|
"output": "???"
|
||||||
|
},
|
||||||
"~1": {
|
"~1": {
|
||||||
"exit": 0,
|
"exit": 0,
|
||||||
"ftime": 1755487439.1243694,
|
"ftime": 1755488031.3807857,
|
||||||
"output": "???"
|
"output": "???"
|
||||||
},
|
},
|
||||||
"~x": {
|
"~x": {
|
||||||
"exit": 0,
|
"exit": 0,
|
||||||
"ftime": 1755477480.7324839,
|
"ftime": 1755477480.7324839,
|
||||||
"output": "???"
|
"output": "???"
|
||||||
|
},
|
||||||
|
"~~1": {
|
||||||
|
"exit": 0,
|
||||||
|
"ftime": 1755488048.9001203,
|
||||||
|
"output": "???"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in a new issue