Context-free grammar for C

China☆狼群 提交于 2019-12-03 08:46:36

问题


I'm working on a parser for C. I'm trying to find a list of all of the context-free derivations for C. Ideally it would be in BNF or similar. I'm sure such a thing is out there, but googling around hasn't given me much.

Reading the source code for existing parsers/compilers has proven to be far more confusing than helpful, as most that I've found are much more ambitious and complicated than the one I'm building.


回答1:


You could always use Annex A of the C11 standard itself. The freely available draft standard will work for your purposes, at http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf .




回答2:


This is an ANSI-C grammar, updated to C11 standard. Should serve your purpose.

http://www.quut.com/c/ANSI-C-grammar-y.html



来源:https://stackoverflow.com/questions/15492481/context-free-grammar-for-c

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