Initial import.
[vtparse.git] / README
blob9b241138732ed8abb77b7766571748910024a5ec
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.
9 BUILDING
10 ========
12 Ruby is required at build time to generate the tables in C.  To build the library
13 and test program, just type make:
15 $ make
16 ruby vtparse_gen_c_tables.rb
17 Wrote vtparse_table.h
18 Wrote vtparse_table.c
19 gcc -o test vtparse_test.c vtparse.c vtparse_table.c
21 TEST PROGRAM
22 ============
24 The test program shows how to use vtparse.  To see what kind of data is returned
25 by the library, try:
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: ''
34 0 Parameters:
36 Received action CSI_DISPATCH, char=0x68
37 Intermediate chars: '???'
38 1 Parameters:
39         47
41 Received action CSI_DISPATCH, char=0x68
42 Intermediate chars: '???'
43 1 Parameters:
44         1
46 ---------------------------------
48 VERIFYING
49 =========
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
57 characters 0-0xA0.
60 TODO
61 ====
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.