declaration-seq:
declaration
declaration-seq declaration
not this way:
declaration-seq:
declaration
declaration declaration-seq
Are the two definitions interchangeable? What is the difference between them?
This is a vestige of C++'s C heritage. The C grammar is (almost) LALR(1), and therefore uses left recursion as much as possible. The C++ grammar is not even vaguely LALR anymore, but many of the rules are still written in the form an LALR parser would prefer, because there's no reason to change them—any parser algorithm powerful enough to handle C++ doesn't care which type of syntactic recursion is used.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With