05ba2a2d9055aa99f764edc10f6d2154cdc1bf2f
[pspp] / src / output / spv / light-binary.grammar
1 # PSPP - a program for statistical analysis.
2 # Copyright (C) 2017, 2018, 2019 Free Software Foundation, Inc.
3 #
4 # This program is free software: you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation, either version 3 of the License, or
7 # (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
17 Table =>
18    Header Titles Footnotes
19    Areas Borders PrintSettings[ps] TableSettings[ts] Formats
20    Dimensions Axes Cells
21    01?
22
23 Header =>
24    01 00
25    int32[version]
26    bool[x0]
27    bool[x1]
28    bool[rotate-inner-column-labels]
29    bool[rotate-outer-row-labels]
30    bool[x2]
31    int32[x3]
32    int32[min-col-width] int32[max-col-width]
33    int32[min-row-height] int32[max-row-height]
34    int64[table-id]
35
36 Titles =>
37    Value[title] 01?
38    Value[subtype] 01? 31
39    Value[user-title] 01?
40    (31 Value[corner-text] | 58)
41    (31 Value[caption] | 58)
42
43 Footnotes => int32[n-footnotes] Footnote*[n-footnotes]
44 Footnote => Value[text] (58 | 31 Value[marker]) int32[show]
45
46 Areas => 00? Area*8[areas]
47 Area =>
48    byte[index] 31
49    string[typeface] float[size] int32[style] bool[underline]
50    int32[halign] int32[valign]
51    string[fg-color] string[bg-color]
52    bool[alternate] string[alt-fg-color] string[alt-bg-color]
53    v3(int32[left-margin] int32[right-margin] int32[top-margin] int32[bottom-margin])
54
55 Borders =>
56    count(
57        ib1
58        be32[n-borders] Border*[n-borders]
59        bool[show-grid-lines]
60        00 00 00)
61
62 Border =>
63    be32[border-type]
64    be32[stroke-type]
65    be32[color]
66
67 PrintSettings =>
68    count(
69        ib1
70        bool[all-layers]
71        bool[paginate-layers]
72        bool[fit-width]
73        bool[fit-length]
74        bool[top-continuation]
75        bool[bottom-continuation]
76        be32[n-orphan-lines]
77        bestring[continuation-string])
78
79 TableSettings =>
80    count(
81      v3(
82        ib1
83        be32[x5]
84        be32[current-layer]
85        bool[omit-empty]
86        bool[show-row-labels-in-corner]
87        bool[show-alphabetic-markers]
88        bool[footnote-marker-superscripts]
89        byte[x6]
90        becount(
91          Breakpoints[row-breaks] Breakpoints[col-breaks]
92          Keeps[row-keeps] Keeps[col-keeps]
93          PointKeeps[row-point-keeps] PointKeeps[col-point-keeps]
94        )
95        bestring[notes]
96        bestring[table-look]
97        )...)
98
99 Breakpoints => be32[n-breaks] be32*[n-breaks]
100
101 Keeps => be32[n-keeps] Keep*[n-keeps]
102 Keep => be32[offset] be32[n]
103
104 PointKeeps => be32[n-point-keeps] PointKeep*[n-point-keeps]
105 PointKeep => be32[offset] be32 be32
106
107 Formats =>
108    int32[n-widths] int32*[n-widths]
109    string[locale]
110    int32[current-layer]
111    bool[x7] bool[x8] bool[x9]
112    Y0
113    CustomCurrency
114    count(
115      v1(X0?)
116      v3(count(X1 count(X2)) count(X3)))
117 Y0 => int32[epoch] byte[decimal] byte[grouping]
118 CustomCurrency => int32[n-ccs] string*[n-ccs]
119
120 X0 => byte*14 Y1 Y2
121 Y1 =>
122    string[command] string[command-local]
123    string[language] string[charset] string[locale]
124    bool[x10] bool[x11] bool[x12] bool[x13]
125    Y0
126 Y2 => CustomCurrency byte[missing] bool[x17]
127
128 X1 =>
129    bool[x14]
130    byte[show-title]
131    bool[x16]
132    byte[lang]
133    byte[show-variables]
134    byte[show-values]
135    int32[x18] int32[x19]
136    00*17
137    bool[x20]
138    bool[show-caption]
139
140 X2 =>
141    int32[n-row-heights] int32*[n-row-heights]
142    int32[n-style-map] StyleMap*[n-style-map]
143    int32[n-styles] StylePair*[n-styles]
144    count((i0 i0)?)
145 StyleMap => int64[cell-index] int16[style-index]
146
147 X3 =>
148    01 00 byte[x21] 00 00 00
149    Y1
150    double[small] 01
151    (string[dataset] string[datafile] i0 int32[date] i0)?
152    Y2
153    (int32[x22] i0)?
154
155 Dimensions => int32[n-dims] Dimension*[n-dims]
156 Dimension =>
157     Value[name] DimProperties[props]
158     int32[n-categories] Category*[n-categories]
159 DimProperties =>
160    byte[x1]
161    byte[x2]
162    int32[x3]
163    bool[hide-dim-label]
164    bool[hide-all-labels]
165    01 int32[dim-index]
166
167 Category => Value[name] (Leaf | Group)
168 Leaf => 00 00 00 i2 int32[leaf-index] i0
169 Group =>
170    bool[merge] 00 01 int32[x23]
171    i-1 int32[n-subcategories] Category*[n-subcategories]
172
173 Axes =>
174    int32[n-layers] int32[n-rows] int32[n-columns]
175    int32*[n-layers] int32*[n-rows] int32*[n-columns]
176
177 Cells => int32[n-cells] Cell*[n-cells]
178 Cell => int64[index] v1(00?) Value
179
180 Value =>
181   00? 00? 00? 00?
182   case(
183       01 ValueMod int32[format] double[x]
184     | 02 ValueMod int32[format] double[x]
185       string[var-name] string[value-label] byte[show]
186     | 03 string[local] ValueMod string[id] string[c] bool[fixed]
187     | 04 ValueMod int32[format] string[value-label] string[var-name]
188       byte[show] string[s]
189     | 05 ValueMod string[var-name] string[var-label] byte[show]
190     | 06 string[local] ValueMod string[id] string[c]
191     | else ValueMod string[template] int32[n-args] Argument*[n-args]
192   )[type]
193 Argument =>
194     i0 Value[value]
195   | int32[n-values] i0 Value*[n-values]
196
197 ValueMod =>
198     58
199   | 31
200     int32[n-refs] int16*[n-refs]
201     int32[n-subscripts] string*[n-subscripts]
202     v1(00 (i1 | i2) 00? 00? int32 00? 00?)
203     v3(count(TemplateString StylePair))
204
205 TemplateString => count((count((i0 (58 | 31 55))?) (58 | 31 string[id]))?)
206
207 StylePair =>
208     (31 FontStyle | 58)
209     (31 CellStyle | 58)
210
211 FontStyle =>
212     bool[bold] bool[italic] bool[underline] bool[show]
213     string[fg-color] string[bg-color]
214     string[typeface] byte[size]
215
216 CellStyle =>
217     int32[halign] int32[valign] double[decimal-offset]
218     int16[left-margin] int16[right-margin]
219     int16[top-margin] int16[bottom-margin]