2 VTParse - an implementation of Paul Williams' DEC compatible state machine parser
3 <http://www.vt100.net/emu/dec_ansi_parser>
5 Author: Joshua Haberman <joshua@reverberate.org>
7 This code is in the public domain.
12 Ruby is required at build time to generate the tables in C. To build the library
13 and test program, just type make:
16 ruby vtparse_gen_c_tables.rb
19 gcc -o test vtparse_test.c vtparse.c vtparse_table.c
24 The test program shows how to use vtparse. To see what kind of data is returned
27 --------------------------------
29 $ vim > terminaloutput
30 <type ':q<ENTER>' to exit vim, even though you won't see it>
31 $ ./test < terminaloutput | head -14
32 Received action ESC_DISPATCH, char=0x37
33 Intermediate chars: ''
36 Received action CSI_DISPATCH, char=0x68
37 Intermediate chars: '???'
41 Received action CSI_DISPATCH, char=0x68
42 Intermediate chars: '???'
46 ---------------------------------
51 You can also verify the validity of the state tables by running:
53 $ ruby vtparse_check_tables.rb
54 Tables had all necessary transitions defined.
56 This checks to make sure that state transitions are defined for all states, for all
63 One possible enhancement is to allow the client to pass a return value from the
64 callback to say "stop parsing." The vtparse() function could return the number
65 of bytes consumed from the input buffer. This would be quite simple to do if
66 someone needed this functionality, but I don't, so I didn't bother.