DEV Community

Ez Pz Developement
Ez Pz Developement

Posted on

Compilers, Hand coded scanners

After discussing the basics of table and hand coded scanners, it is the time to write a post about the hand coded one, the two previous scanners are auto generated and use the DFA as the backbone for all the operations, but the hand coded scanners is totally different with a goal of reducing the cost of simulating the DFA, in order to achieve this a careful implementation is needed.

The author of Engineering a compiler mentioned that they did an official survey, the results was that this hand coded scanners was used in the most of opensource and commercial compilers.

This last mentioned scanner has some disadvantages, for example doing an i/o to read a character has significant impact in the performance, if we compare it to the DFA.

To solve this issue the compiler writers use a buffered i/o, where each read operation return a longer character, we keep track of the current position by using a pointer.

Top comments (0)