Do lex and yacc provide optimized code?
The code you write has a significant impact on speed, especially on the lexer side. Some versions of Flex have half a dozen (or so) different word counts, most of which are written in Flex and a few are handwritten - the code gives a pretty good idea of โโhow to optimize scan speed (and a pretty reasonable comparison of what you can expect in handwritten or machine lexes).
On the parser side, you tend to be a little more limited - you can't make as many changes without affecting the semantics. Much depends on the parser generator you are using - for example, some algorithms for less constrained grammars consistently produce relatively slow parsers, while other algorithms only slow down for less strict constructs and work relatively quickly until the input uses more complex constructs.
a source to share