2
votes

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

1
You should describe the problem you have with the sample files. Maybe the problem is not in the grammar but in the sample files or in the way you generate the parser? - quepas
You don't want to write your own or debug somebody else's C parser. C is hard language to parse in practice. See stackoverflow.com/a/24777596/120163 - Ira Baxter

1 Answers

3
votes

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.