Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.6节关于指针解引用段落修改的建议 #31

Open
Lumin-exdo opened this issue Jul 13, 2024 · 2 comments
Open

1.6节关于指针解引用段落修改的建议 #31

Lumin-exdo opened this issue Jul 13, 2024 · 2 comments

Comments

@Lumin-exdo
Copy link

“还需要注意的是指针解引用(dereference)的识别, ”这一段下方的代码:

if (!make_token(e)) {
  *success = false;
  return 0;
}

/* TODO: Implement code to evaluate the expression. */

for (i = 0; i < nr_token; i ++) {
  if (tokens[i].type == '*' && (i == 0 || tokens[i - 1].type == certain type) ) {
    tokens[i].type = DEREF;
  }
}

return eval(?, ?);

我认为这个for循环不应该放到这里,而应该放到make_token函数体内处理,更有逻辑。

@Lumin-exdo
Copy link
Author

原网页要求把它放在word_t expr(char *e, bool *success) 也就是expr.c结尾的这个函数体内,我认为不太合理。

@sashimi-yzh
Copy link
Contributor

make_token()做的事是词法分析,这个for循环做的是语义分析,是两回事,所以它不应该放在make_token()里面. 网页原来的说法是没问题的.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants