Add more flexibility in how whitespace is specified.
[gazelle.git] / docs / FILEFORMAT
blob70ed5abaa31e023631da40e16a44b9f99c5018ff
2 This is a description of Gazelle's bytecode file format.
4 The file format itself is "Bitcode," a generic bytecode format
5 developed as part of the LLVM project.  It is documented here:
6   http://llvm.cs.uiuc.edu/docs/BitCodeFormat.html
8 This file describes the meaning of the information that Gazelle
9 puts into the bytecode.
11 Bitcode file, application magic number = "GH"
12 All offsets are 0-based unless otherwise specified.
14 STRINGS -- all strings are put into the STRINGS block, and referenced
15            by offset in other parts of the file
16   [STRING, <ascii array of chars>]
17   [STRING, <ascii array of chars>]
18   ...
20 INTFAS -- the list of all IntFAs (lexing DFAs)
21   INTFA -- a single DFA
22     [INTFA_STATE, # of transitions]  <-- first state is assumed to be start state
23     [INTFA_STATE, # of transitions]
24     [INTFA_FINAL_STATE, # of transitions, terminal_name_int]
25     ...
26     (states are identified by their offset in this list)
28     [INTFA_TRANSITION, edge val, dest state offset]
29     [INTFA_TRANSITION_RANGE, edge val low, edge val high, dest state offset]
30     ...
31     (transitions are identified by their offset in this list)
33 GLAS
34   GLA
35     [GLA_STATE, intfa #, # of transitions]
36     [GLA_FINAL_STATE, 1-based rtn alt offset (0 is return from final)]
37     ...
39     [GLA_TRANSITION, 1-based terminal_name_int (0 is EOF), dest GLA state offset]
40     ...
42 RTNS -- a list of all the RTNs
43   RTN - a single RTN
44     [RTN_INFO, nonterm_name_int, # of slots]
46     [RTN_STATE_WITH_INTFA, # of transitions, is final, intfa#]
47     [RTN_STATE_WITH_GLA, # of transitions, is final, gla#]
48     [RTN_TRIVIAL_STATE, # of transitions, is final]
49     ...
51     -- slotnums are 0-based in the runtime, but 1-based in the bytecode and in the
52     -- compiler.  We use 0 in the bytecode to represent "no slotnum" (-1 elsewhere),
53     -- as used by subparsers.
54     [RTN_TRANSITION_TERMINAL, terminal_name_int, dest RTN state offset, slotname_int, slotnum+1]
55     [RTN_TRANSITION_NONTERM, rtn_offset, dest RTN state offset, slotname_int, slotnum+1]
56     ...