I think Bison and Yacc are very often used for parsing grammars of programming languages. (and lex/flex for tokenizing...)
My Question is: Are all compilers made with this tools or are there people who write their parsers from scratch? (I do it mostly without "compiler compilers", but I know them)
Is it "luctrative" to build parsers without these tools?
Are there alternatives for yacc/bison and lex/flex that are more "open" and not so strict. Are libraries for C existing to do that for me (the parsing)? Is there another option to build parsers without yacc but also not to write it from scratch?
Best regards Lukas
Many high performance parsers for big ticket products, like C++ compilers are handwritten, or at least pre generated by a tool. and then modified by hand.
Unfortunately, this significantly increases maintenance effort and introduces a much larger possibility for bugs.
A well written grammar and a well chosen parser generator tool can yield performance almost as good, or in many cases, as good as a handwritten parser.
For this reason, a parser generator is preferable if you don't have the development and testing resources that a larger organization might.
There are many parsing and lexing tools available, both general and specialized depending on platform, parser type (LLk, LALR(1), etc), and output language.
There are also general parsing engines like Programmar that take an input grammar and interpret it at runtime in order to allow an app to analyze inputs that conform to that grammar.
Gold Parser is a free and easy to use LALR(1) parser generator that runs on Windows operating systems.
The Spirit Framework ships with the C++ Boost library and uses a combination of preprocessing macros and clever generics to allow the developer to produce a grammar in a C++ file that is compiled by the C++ compiler itself despite looking quite a bit like a standard EBNF grammar file. Naturally, its output targets C++
Elk is a toolkit for creating C++ based GLR parsers. GLR is a particularly efficient and flexible type of parser often used for complex grammars, like C++ itself.
There are many other tools out there, including ANTLR and ACCENT, each of which have their own strengths and weaknesses.
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