Are GCC and Clang parsers really handwritten?

后端 未结 6 1503
独厮守ぢ
独厮守ぢ 2020-11-29 15:15

It seems that GCC and LLVM-Clang are using handwritten recursive descent parsers, and not machine generated, Bison-Flex based, bottom up pa

6条回答
  •  野性不改
    2020-11-29 16:01

    gcc's parser is handwritten.. I suspect the same for clang. This is probably for a few reasons:

    • Performance: something that you've hand-optimized for your particular task will almost always perform better than a general solution. Abstraction usually has a performance hit
    • Timing: at least in the case of GCC, GCC predates a lot of free developer tools (came out in 1987). There was no free version of yacc, etc. at the time, which I'd imagine would've been a priority to the people at the FSF.

    This is probably not a case of "not invented here" syndrome, but more along the lines of "there was nothing optimized specifically for what we needed, so we wrote our own".

提交回复
热议问题