C ++ BNF Grammar with Parsing / Matching Examples

I am developing a C ++ parser (for the IDE), so now I am trying to understand the C ++ grammar. While I found an excellent source of grammar at http://www.nongnu.org/hcb/ , I had trouble understanding some of its parts - and, especially, which "real" language constructs correspond to different settings.

So, I am looking for a C / C ++ BNF grammar guide with code examples that correspond to various regulations / rules. Whether there is a?

+7
source share
1 answer

A hyperlink (implied) grammar is not necessarily one on which you can easily build a parser. This is determined by the nature of your parser and the actual dialect of C and C ++ you care about (ANSI? GNU? C99? C ++ 11? MS?).

Building a working C ++ analyzer is very difficult. See My answer to Why C ++ cannot be parsed by the LR (1) parser? for some reasons. If you want a “good” parser, I suggest you use one of the existing ones. It might be worth taking a look at Elsa , as it is open source.

+7
source

All Articles