Source for parsing C grammar using JavaCC

大憨熊 提交于 2019-12-25 10:01:05

问题



As an project assignment, I need to parse a plain-C grammar from Java to generate AST output. As a startup, I am using the file c.jj that I have found among grammar files at

http://java.net/projects/javacc/sources/svn/

but I found that it only has syntactic and lexical actions and no real semantics for parsing C source. Is there some other source that incorporate typedef, variables, construct functions, include files?


回答1:


You could go looking for a complete grammar. Will you learn much this way?

You could ask your lecturer which would impress them more: implementing some small subset of C grammar by writing your own rules, or by searching google for alternative complete rules?

I trust writing your own rules - and even your own hand-crafted parser - will be more a more useful exercise. Even if its only parsing expressions.



来源:https://stackoverflow.com/questions/5296029/source-for-parsing-c-grammar-using-javacc

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!