简体   繁体   中英

C grammar for ANTLR v4

I was wondering if anyone had a working C grammar for ANTLRv4 besides the one on Github?

I can't get the existing one to work at all, it won't even parse the sample files. It may be i'm missing something but I haven't had a problem with any of the other grammars.

I was thinking about modifying the existing one/writing my own, but I don't really have the time - I have limited time to work on this project.

Any help much appreciated.

thanks,

Katy

So you cannot create a working C grammar in less than a few months and it is more complex than it seems like. My opinion is that parsing all C (without preprocessor) takes 6 months to do it well.

For example, the first impression is that C grammar is context-free, but in reality it is context-sensitive.

Take the official grammar from Appendix A of the ISO Standard and start implementing sublanguages from it, inserting nonterminals one by one.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM