14

Was there a language change that required it or some practical reason why Bison was no longer appropriate or optimal?

I saw on wikipedia that they switched, referring to the GCC 3.4 and GCC 4.1 release notes.

These release notes state:

A hand-written recursive-descent C++ parser has replaced the YACC-derived C++ parser from previous GCC releases. The new parser contains much improved infrastructure needed for better parsing of C++ source codes, handling of extensions, and clean separation (where possible) between proper semantics analysis and parsing. The new parser fixes many bugs that were found in the old parser.

And:

The old Bison-based C and Objective-C parser has been replaced by a new, faster hand-written recursive-descent parser

What I would like to know is what actual problems were they having and why it was impossible / impractical to solve using Bison

4
  • 1
    eventually all parsers will become homebrewn after enough modifications when the parser generator can't handle the requirements Aug 28, 2014 at 14:42
  • 1
    Sharing your research helps everyone. Tell us what you've tried and why it didn’t meet your needs. This demonstrates that you’ve taken the time to try to help yourself, it saves us from reiterating obvious answers, and most of all it helps you get a more specific and relevant answer. Also see How to Ask
    – gnat
    Aug 28, 2014 at 14:46
  • 1
    @gnat I expanded my question
    – neelsg
    Aug 28, 2014 at 14:57
  • 2
    C++ is an extraordinarily complex language to parse compared to most other programming languages. My gut feeling is a general-purpose parser probably could not support certain optimizations that a home-brewed parser could use.
    – user22815
    Aug 28, 2014 at 15:02

1 Answer 1

19

GCC switched to hand-written parsing because error messages are more meaningful when using recursive descent techniques, as I explained here.

Also, C++ is becoming such a (syntactically) complex language to parse that using parser generators is not worthwhile for it.

At last, the bulk of the work of a real compiler is not parsing, it is optimizing. GCC middle end optimization passes are much more complex than its parsing.

(BTW you can customize GCC e.g. with plugins or using MELT, but you cannot really extend the syntax of the language it is accepting - except by adding attributes and pragmas).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.