11 2021 档案

摘要:1. 要编译的测试代码: int plus(int x, int y) { return x + y; } int main(void) { return plus(3, 4); } 2. main中return语句语法分析 if (equal(tok, "return")) { Node *nod 阅读全文
posted @ 2021-11-25 11:07 Just_4_fun 阅读(385) 评论(0) 推荐(0)
摘要:1. 要编译的测试代码: int main(void) { 2+3*4; } 2. 词法分析 词法分析将字符变成token,其中很重要的是token的类型,如字符2的token类型为TK_NUM,这在后面的语法分析阶段有用。 3. 语法分析 3.1 解析字符"2" if (tok->kind == 阅读全文
posted @ 2021-11-24 09:34 Just_4_fun 阅读(878) 评论(0) 推荐(0)
摘要:1. 要编译的测试代码: int a; int b = 3; int main(void) { if (3) a = 4; else b = 5; } 2. 词法分析 词法分析将c源代码解析成一个个的token。 关键的,将if两个字符解析成一个if token,后续语法分析的输入就从两个字符减少为 阅读全文
posted @ 2021-11-23 13:24 Just_4_fun 阅读(1045) 评论(0) 推荐(0)