> compile NEMU

221220000 张三
Linux zzy 5.15.146.1-microsoft-standard-WSL2 #1 SMP Thu Jan 11 04:09:03 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux
 13:37:55 up 3 days,  5:15,  1 user,  load average: 0.78, 0.35, 0.20
This commit is contained in:
tracer-ics2023
2024-08-26 13:37:56 +08:00
committed by zzy
parent 78a4b2e8ea
commit deb89071dd

View File

@ -166,7 +166,7 @@ word_t eval(const Token* arr, size_t p, size_t q, bool* success) {
int parten = check_parentheses(arr, p, q);
if (parten == -1 || p > q) {
*success = false;
*success &= false;
return 0;
}
else if (parten == 0) {
@ -183,15 +183,18 @@ word_t eval(const Token* arr, size_t p, size_t q, bool* success) {
* Return the value of the number.
*/
if (arr[q].type != TK_DEC) {
*success = false;
*success &= false;
return 0;
}
if (p != q && arr[p].type != '-') {
*success = false;
return 0;
if (p == q) {
return atoi(arr[q].str);
}
return atoi(arr[q].str);
if (arr[p].type == '-') {
return - atoi(arr[q].str);
}
*success &= false;
return 0;
}
else {
/* We should do more things here. */
@ -213,11 +216,12 @@ word_t eval(const Token* arr, size_t p, size_t q, bool* success) {
if (arr[i].type == '+' || arr[i].type == '-') {
op = i;
} else if (arr[i].type == '*' || arr[i].type == '/') {
if (arr[i].type == '+' || arr[i].type == '-') {
continue;
}
op = i;
}
if (i + 1 <= q && arr[i + 1].type == '-') {
i++;
}
}
word_t val1 = eval(arr, p, op - 1, success);
word_t val2 = eval(arr, op + 1, q, success);