4 ms·
Excellent use of Ragel to generate fast state machines. Everyone should check it out: https://www.colm.net/open-source/ragel/ https://www.colm.net/open-source/r
by quotemstr 2mo ago
Excellent use of Ragel to generate fast state machines. Everyone should check it out: https://www.colm.net/open-source/ragel/ https://www.colm.net/open-source/ragel/
The author of shitty encoded the whole terminal state machine in Ragel: https://github.com/pg83/shitty/blob/master/parser.rl https://github.com/pg83/shitty/blob/master/parser.rl
The thing generates one of big DFA with actions for everything that can ever happen in the terminal. Precisely correct way to do it. Plus, Ragel is a joy to program once you get the hang of it. You can compose edge-triggered, level-triggered, and recursive operators in surprisingly elegant ways.
- pg83 2mo agoI'm glad someone noticed this, but ragel is a very niche tool; few people have heard of it! I believe my parser is the first complete description of a terminal output parser in FSM form, and that alone is quite valuable.
- ku1ik 2mo agoNo it’s not. https://www.vt100.net/emu/dec_ansi_parser https://www.vt100.net/emu/dec_ansi_parser Paul Williams made this years (if not decades) ago, and it has been widely used by terminal emulator implementers.
- quotemstr 2mo agoTo be fair, this description omits a huge part of the modern terminal interface surface.