> 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
 08:46:58 up 12:56,  2 users,  load average: 0.20, 0.26, 0.21
This commit is contained in:
tracer-ics2023
2024-08-18 08:46:59 +08:00
committed by zzy
parent 27e7aadb96
commit b7401e137c

View File

@ -168,7 +168,7 @@ int check_parentheses(const Token* arr, size_t p, size_t q) {
word_t eval(const Token* arr, size_t p, size_t q) {
Assert (p >= 0 && p < q && q < nr_token, "invalid range on eval, "\
"p = %"PRIuMAX", q = %"PRIuMAX"\n", p, q);
if (p > q) {
if (p > q || p > nr_token || q > nr_token) {
/* Bad expression */
panic("bad expression");
}
@ -231,7 +231,5 @@ word_t expr(char *e, bool *success) {
/* TODO: Insert codes to evaluate the expression. */
// TODO();
*success = true;
size_t q = nr_token - 1;
printf("nr_token = %"PRIuMAX"\n", q);
return eval(tokens, 0, q);
return eval(tokens, 0, nr_token - 1);
}