Add support for reading and writing SPV files.
[pspp] / src / output / spv / light-binary.grammar
1 Table =>
2    Header Titles Footnotes
3    Areas Borders PrintSettings[ps] TableSettings[ts] Formats
4    Dimensions Axes Cells
5    01?
6
7 Header =>
8    01 00
9    int32[version]
10    bool[x0]
11    bool[x1]
12    bool[rotate-inner-column-labels]
13    bool[rotate-outer-row-labels]
14    bool[x2]
15    int32[x3]
16    int32[min-col-width] int32[max-col-width]
17    int32[min-row-height] int32[max-row-height]
18    int64[table-id]
19
20 Titles =>
21    Value[title] 01?
22    Value[subtype] 01? 31
23    Value[user-title] 01?
24    (31 Value[corner-text] | 58)
25    (31 Value[caption] | 58)
26
27 Footnotes => int32[n-footnotes] Footnote*[n-footnotes]
28 Footnote => Value[text] (58 | 31 Value[marker]) int32[x4]
29
30 Areas => 00? Area*8[areas]
31 Area =>
32    byte[index] 31
33    string[typeface] float[size] int32[style] bool[underline]
34    int32[halign] int32[valign]
35    string[fg-color] string[bg-color]
36    bool[alternate] string[alt-fg-color] string[alt-bg-color]
37    v3(int32[left-margin] int32[right-margin] int32[top-margin] int32[bottom-margin])
38
39 Borders =>
40    count(
41        ib1
42        be32[n-borders] Border*[n-borders]
43        bool[show-grid-lines]
44        00 00 00)
45
46 Border =>
47    be32[border-type]
48    be32[stroke-type]
49    be32[color]
50
51 PrintSettings =>
52    count(
53        ib1
54        bool[all-layers]
55        bool[paginate-layers]
56        bool[fit-width]
57        bool[fit-length]
58        bool[top-continuation]
59        bool[bottom-continuation]
60        be32[n-orphan-lines]
61        bestring[continuation-string])
62
63 TableSettings =>
64    count(
65      v3(
66        ib1
67        be32[x5]
68        be32[current-layer]
69        bool[omit-empty]
70        bool[show-row-labels-in-corner]
71        bool[show-alphabetic-markers]
72        bool[footnote-marker-superscripts]
73        byte[x6]
74        becount(
75          Breakpoints[row-breaks] Breakpoints[col-breaks]
76          Keeps[row-keeps] Keeps[col-keeps]
77          PointKeeps[row-point-keeps] PointKeeps[col-point-keeps]
78        )
79        bestring[notes]
80        bestring[table-look]
81        )...)
82
83 Breakpoints => be32[n-breaks] be32*[n-breaks]
84
85 Keeps => be32[n-keeps] Keep*[n-keeps]
86 Keep => be32[offset] be32[n]
87
88 PointKeeps => be32[n-point-keeps] PointKeep*[n-point-keeps]
89 PointKeep => be32[offset] be32 be32
90
91 Formats =>
92    int32[n-widths] int32*[n-widths]
93    string[locale]
94    int32[current-layer]
95    bool[x7] bool[x8] bool[x9]
96    Y0
97    CustomCurrency
98    count(
99      v1(X0?)
100      v3(count(X1 count(X2)) count(X3)))
101 Y0 => int32[epoch] byte[decimal] byte[grouping]
102 CustomCurrency => int32[n-ccs] string*[n-ccs]
103
104 X0 => byte*14 Y1 Y2
105 Y1 =>
106    string[command] string[command-local]
107    string[language] string[charset] string[locale]
108    bool[x10] bool[x11] bool[x12] bool[x13]
109    Y0
110 Y2 => CustomCurrency byte[missing] bool[x16]
111
112 X1 =>
113    00 byte[x14] bool[x15]
114    byte[lang]
115    byte[show-variables]
116    byte[show-values]
117    int32[x17] int32[x18]
118    00*17
119    bool[x19]
120    01
121
122 X2 =>
123    int32[n-row-heights] int32*[n-row-heights]
124    int32[n-style-map] StyleMap*[n-style-map]
125    int32[n-styles] StylePair*[n-styles]
126    count((i0 i0)?)
127 StyleMap => int64[cell-index] int16[style-index]
128
129 X3 =>
130    01 00 byte[x20] 00 00 00
131    Y1
132    double[small] 01
133    (string[dataset] string[datafile] i0 int32[date] i0)?
134    Y2
135    (int32[x21] i0)?
136
137 Dimensions => int32[n-dims] Dimension*[n-dims]
138 Dimension =>
139     Value[name] DimProperties[props]
140     int32[n-categories] Category*[n-categories]
141 DimProperties =>
142    byte[x1]
143    byte[x2]
144    int32[x3]
145    bool[hide-dim-label]
146    bool[hide-all-labels]
147    01 int32[dim-index]
148
149 Category => Value[name] (Leaf | Group)
150 Leaf => 00 00 00 i2 int32[leaf-index] i0
151 Group =>
152    bool[merge] 00 01 int32[x22]
153    i-1 int32[n-subcategories] Category*[n-subcategories]
154
155 Axes =>
156    int32[n-layers] int32[n-rows] int32[n-columns]
157    int32*[n-layers] int32*[n-rows] int32*[n-columns]
158
159 Cells => int32[n-cells] Cell*[n-cells]
160 Cell => int64[index] v1(00?) Value
161
162 Value =>
163   00? 00? 00? 00?
164   case(
165       01 ValueMod int32[format] double[x]
166     | 02 ValueMod int32[format] double[x]
167       string[var-name] string[value-label] byte[show]
168     | 03 string[local] ValueMod string[id] string[c] bool[fixed]
169     | 04 ValueMod int32[format] string[value-label] string[var-name]
170       byte[show] string[s]
171     | 05 ValueMod string[var-name] string[var-label] byte[show]
172     | 06 string[local] ValueMod string[id] string[c]
173     | else ValueMod string[template] int32[n-args] Argument*[n-args]
174   )[type]
175 Argument =>
176     i0 Value[value]
177   | int32[n-values] i0 Value*[n-values]
178
179 ValueMod =>
180     58
181   | 31
182     int32[n-refs] int16*[n-refs]
183     (i0 | i1 string[subscript])
184     v1(00 (i1 | i2) 00? 00? int32 00? 00?)
185     v3(count(TemplateString StylePair))
186
187 TemplateString => count((count((i0 58)?) (58 | 31 string[id]))?)
188
189 StylePair =>
190     (31 FontStyle | 58)
191     (31 CellStyle | 58)
192
193 FontStyle =>
194     bool[bold] bool[italic] bool[underline] bool[show]
195     string[fg-color] string[bg-color]
196     string[typeface] byte[size]
197
198 CellStyle =>
199     int32[halign] int32[valign] double[decimal-offset]
200     int16[left-margin] int16[right-margin]
201     int16[top-margin] int16[bottom-margin]