Very Fast: Directly Coded Lexical Analyzer

Andi Kleen andi@firstfloor.org
Thu May 31 15:08:00 GMT 2007


"Frank Schaefer" <frank_r_schaefer@gmx.net> writes:
> 
> Is there any interest in using such an engine in the GCC toolset? 

Right now gcc doesn't use flex so it would be probably non trivial
to implement support. You would need to rewrite c-lex.c

> It would be an honor for me to provide any adaptions you require. 
> Anyway, quex's syntax is mostly conform to flex/lex, so there is 
> not much 'getting used to' with this generator. I am also positive, 
> that it is very hard to program a hand-written analyzer that is faster,
> since the engine does not do any house-keeping and profits from Hopcroft-
> Optimization and Binary-Search for code generation. These things are
> hard to to by hand.

Normally switch() uses reasonable algorithms which gcc's c-lex.c uses. 
I suspect for common symbols using a pure table lookup vs calling special 
code would be faster on many CPUs though (computed jumps are often slow
because they tend to cause branch mispredicts) 

-Andi



More information about the Gcc mailing list