3 ms·
Lexing and parsing are the simplest, by far, parts of a compiler. (That's why it is possible for Flex & Bison to exist.) 99% of the time spent writing a compil
by WalterBright 9y ago
Lexing and parsing are the simplest, by far, parts of a compiler. (That's why it is possible for Flex & Bison to exist.)
99% of the time spent writing a compiler will be elsewhere.
If you want a correct to the last drop C preprocessor, prepare to spend 6 months on that, minimum. Or just use Warp:
https://github.com/facebookarchive/warp https://github.com/facebookarchive/warp
and then you can have fun just working on the compiler bit.
- delhanty 9y agoThank you - that's informative. >99% of the time spent writing a compiler will be elsewhere. Out of interest, has the distribution of labor in that remaining 99% changed at all since you first started out? For example, do things like LLVM change anything?
- WalterBright 9y agoI re-used the Digital Mars C++ optimizer and back end for the dmd D compiler, so that would be like using LLVM for an optimizer and back end. I still wind up spending nearly all my time on the D front end, and not the lexer/parser. The time spent on the lexer/parser is a rounding error. Besides, build the lexer/parser by hand. The mystery of how to do them will evaporate, and you'll find you can apply that knowledge to all sorts of other tasks.