logoalt Hacker News

quotemstrtoday at 1:20 AM1 replyview on HN

Excellent use of Ragel to generate fast state machines. Everyone should check it out: 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

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.


Replies

pg83today at 2:25 AM

I'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.