摘要: 参考:http://www.ibm.com/developerworks/cn/linux/sdk/lex/#resources 阅读全文
posted @ 2012-09-29 21:34 helloweworld 阅读(789) 评论(0) 推荐(1) 编辑
摘要: 声明:原创作品,转载注明出处http://www.cnblogs.com/vestinfo/一、简介推荐书籍《flex&bison》.在UNIX下是flex和bison.网上介绍很多,大部分是写给懂的人看的,初学者一头雾水。这样来理解lex和yacc可能容易些:在linux下,有很多系统配置文件,一些linux下的软件也有配置文件,那么程序是如何读取配置文件中的信息的呢?首先用到lex词法分析器,读取配置文件中的关键词(后面说到的token标记其实可看做关键词)。然后把关键词递交给yacc,yacc对一些关键词进行匹配,看是否符合一定语法逻辑,如果符合就进行相应动作。上面举得例子是分析 阅读全文
posted @ 2012-09-29 21:29 helloweworld 阅读(3591) 评论(0) 推荐(3) 编辑
摘要: 声明:原创作品,转载注明出处:http://www.cnblogs.com/vestinfo/六、flex和bison相结合。test.l%{ #include "test.tab.h" #include <stdio.h> #include <stdlib.h> %} %% a {return A_STATE;} b {return B_STATE;} c {return C_STATE;} not {return NOT;} %%test.y%{ #include <stdio.h> #include <stdlib.h> 阅读全文
posted @ 2012-09-29 10:02 helloweworld 阅读(890) 评论(0) 推荐(1) 编辑