开发者

Source for parsing C grammar using JavaCC

开发者 https://www.devze.com 2023-02-16 20:17 出处:网络
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

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 semant开发者_C百科ics for parsing C source. Is there some other source that incorporate typedef, variables, construct functions, include files?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消