I have a huge project that is using YACC and I would need to fix a bug in it.
I might ask someone else who wrote that to fix it but I’m interested in how compilers work. Does it make sense to learn YACC nowadays? It was told me that it’s old and obsolete. I would love to understand how compilers/llvm and other stuff like those work… what about YACC?
8
YACC helps you with one step of the pipeline: creating a parser for a specific grammar. There are lots of other ways to do that step. There are a ton of parser generators available, or you can manually write your own parser. Depending on your requirements, there are many technical reasons to consider YACC to be obsolete, not the least of which is its limited choice of output languages.
However, it is nowhere near obsolete as a pedagogical tool. You’ll need to learn the fundamentals of parsers and grammars no matter what parser you use, and you can learn those just as easily using YACC as with anything else. The knowledge translates very easily. I learned YACC in school, but picked up ANTLR with very little effort.
Also consider that it’s very likely your bug isn’t even in the parser. Usually most parser bugs get ironed out very early in the project, because they have a tendency to produce spectacular failures. The more subtle errors tend to be in the layers downstream of the parser, which have nothing to do with YACC.
I don’t think YACC is obsolete. In a sense it is obsoleted by bison, the GNU implementation, but that is backward compatible with the original version.
The big compilers appear to have manually written parsers, I suppose mainly because they need better diagnostics in case of parse errors than what the generic parser generator provides. But many tools with smaller domain specific language use bison (llvm suite build-depends on bison, so it apparently has some, though clang has manually written parser), because it gets the job done quickly and in more maintainable way.