I am implementing terminal emulator similar to default terminal emulator for OSX: Terminal.app.
I open terminal connection with openpty
and then use Flex to parse incoming input: normal text and control sequences and Bison which calls callbacks based on tokens produced by Flex (insert string, cursor forward sequence etc).
- Along with normal text tokens I have implemented around 30 escape sequences without any outstanding problems.
- I made Flex/Bison re-entrant because I needed multiple terminal windows to work simultaneously
- I did some workarounds to make Flex/Bison to read continuous output based on my another question: How to detect partial unfinished token and join its pieces that are obtained from two consequent portions of input?.
So far it looks like Flex/Bison do their job, however I suspect that sooner or later I will encounter something that reveals the fact that Flex/Bison should not be used as a tool to parse terminal input.
The question is: what are the problems that Flex/Bison can cause if they are used instead of hand-written parser for terminal input? Can performance be a concern?