grammars-v4 icon indicating copy to clipboard operation
grammars-v4 copied to clipboard

[Question] Why are include statements ignored in the cpp grammar?

Open pasto9 opened this issue 2 years ago • 3 comments

While working with the cpp grammar I noticed that the include statements in the examples are ignored by the parser.

I tried to educate myself with the C++ standard appendix on grammar and noticed that include statements are also not mentioned. Or did I miss it?

What is the reason for that?

pasto9 avatar Jul 24 '23 08:07 pasto9

Okay I found them mentioned in an older standard. Why are there no preprocessing directives in the cpp grammar at all?

pasto9 avatar Jul 24 '23 09:07 pasto9

The Spec divides the C++ grammar into two phases, with the grammar shared between both. But, the driver here is not set up for two parsers, where the output is fed to another. I have another grammar with base clases to do this, but it is different than the one here, and much closer to the Spec. I haven't investigated how the grammar in this repo differs from the Spec and why yet. People have made a lot of changes with zero documentation (all changes should have an Issue credited to accompany the PR). I also do not like how this grammar is not labeled after the version of the Spec.

My plan is to redo this grammar.

kaby76 avatar Jul 24 '23 14:07 kaby76

Thank you for your answer. I would offer my help but I'm not sure how much I can with my limited antlr knowledge at the moment.

pasto9 avatar Jul 25 '23 06:07 pasto9