解析函数和包含文件 [英] Parse functions and include files

查看:80
本文介绍了解析函数和包含文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究野牛(yacc),但我有一个疑问,我如何在源代码中包含处理文件(#include)以及如何创建函数并分析和yacc生成这些函数的代码?



我做了一个简单的测试代码:https://github.com/bencz/YaccStudy



但是,没有功能系统和#include系统...我只是试图制作,但做错了,它在编译时给出了错误,并在编译时,它没有工作...然后删除了源有这些变化,并且做了一个新的...

解决方案

我用了很长时间以来一直使用过YACC而且我从未使用过野牛。 />
也许这会有所帮助...



 inc_def:INC {printf(  #include<%s> \ n,yytext);} 
;


I am studying the bison ( yacc ), but I have a doubt, how can I make processing files included in the source (# include) and how can I create functions and to analyze and yacc generate the code for these functions ?

I made a simple test code: https://github.com/bencz/YaccStudy

but, don't have the function system and #include system... I just tried to make, but did it wrong, it gave error at compile time, and when compiled, it did not work ... then deleted the sources that had these changes, and made ​​a new...

解决方案

It has been a long time since I have used YACC and I have never used bison.
Maybe this will help...

inc_def   : INC        {printf("#include <%s>\n",yytext);}
          ;


这篇关于解析函数和包含文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆