Version 1.0
Copyright © 2022 Lowell D. Thomas
Python APG
 … an ABNF Parser Generator
grammar.py
Go to the documentation of this file.
1 # Copyright (c) 2022 Lowell D. Thomas, all rights reserved
2 # BSD-2-Clause (https://opensource.org/licenses/BSD-2-Clause)
3 #
4 
5 # SUMMARY
6 # rules = 48
7 # udts = 0
8 # opcodes = 204
9 # --- ABNF original opcodes
10 # ALT = 25
11 # CAT = 18
12 # REP = 19
13 # RNM = 76
14 # TLS = 11
15 # TBS = 31
16 # TRG = 24
17 # --- SABNF super set opcodes
18 # UDT = 0
19 # AND = 0
20 # NOT = 0
21 # BKA = 0
22 # BKN = 0
23 # BKR = 0
24 # ABG = 0
25 # AEN = 0
26 # characters = [9 - 126]
27 #
28 
29 # RULES
30 rules = ({'name': 'ini-file',
31  'lower': 'ini-file',
32  'index': 0,
33  'line': 31,
34  'is_bkru': False,
35  'is_bkrr': False,
36  'has_bkrr': False,
37  'opcodes': ({'type': 2, 'children': (1, 5)},
38  {'type': 3, 'min': 0, 'max': 9223372036854775807},
39  {'type': 1, 'children': (3, 4)},
40  {'type': 4, 'index': 38},
41  {'type': 4, 'index': 5},
42  {'type': 3, 'min': 0, 'max': 9223372036854775807},
43  {'type': 4, 'index': 1})},
44  {'name': 'section',
45  'lower': 'section',
46  'index': 1,
47  'line': 32,
48  'is_bkru': False,
49  'is_bkrr': False,
50  'has_bkrr': False,
51  'opcodes': ({'type': 2, 'children': (1, 2)},
52  {'type': 4, 'index': 2},
53  {'type': 3, 'min': 0, 'max': 9223372036854775807},
54  {'type': 1, 'children': (4, 5)},
55  {'type': 4, 'index': 38},
56  {'type': 4, 'index': 5})},
57  {'name': 'section-line',
58  'lower': 'section-line',
59  'index': 2,
60  'line': 33,
61  'is_bkru': False,
62  'is_bkrr': False,
63  'has_bkrr': False,
64  'opcodes': ({'type': 1, 'children': (1, 2)},
65  {'type': 4, 'index': 3},
66  {'type': 4, 'index': 4})},
67  {'name': 'good-section-line',
68  'lower': 'good-section-line',
69  'index': 3,
70  'line': 34,
71  'is_bkru': False,
72  'is_bkrr': False,
73  'has_bkrr': False,
74  'opcodes': ({'type': 2, 'children': (1, 2, 3, 4, 5, 6, 7, 9)},
75  {'type': 7, 'string': (91,)},
76  {'type': 4, 'index': 43},
77  {'type': 4, 'index': 9},
78  {'type': 4, 'index': 43},
79  {'type': 7, 'string': (93,)},
80  {'type': 4, 'index': 43},
81  {'type': 3, 'min': 0, 'max': 1},
82  {'type': 4, 'index': 42},
83  {'type': 4, 'index': 41})},
84  {'name': 'bad-section-line',
85  'lower': 'bad-section-line',
86  'index': 4,
87  'line': 35,
88  'is_bkru': False,
89  'is_bkrr': False,
90  'has_bkrr': False,
91  'opcodes': ({'type': 2, 'children': (1, 2, 4)},
92  {'type': 7, 'string': (91,)},
93  {'type': 3, 'min': 0, 'max': 9223372036854775807},
94  {'type': 4, 'index': 47},
95  {'type': 4, 'index': 41})},
96  {'name': 'value-line',
97  'lower': 'value-line',
98  'index': 5,
99  'line': 36,
100  'is_bkru': False,
101  'is_bkrr': False,
102  'has_bkrr': False,
103  'opcodes': ({'type': 1, 'children': (1, 2)},
104  {'type': 4, 'index': 6},
105  {'type': 4, 'index': 7})},
106  {'name': 'good-value',
107  'lower': 'good-value',
108  'index': 6,
109  'line': 37,
110  'is_bkru': False,
111  'is_bkrr': False,
112  'has_bkrr': False,
113  'opcodes': ({'type': 2, 'children': (1, 2, 3, 4, 5, 6, 7, 9)},
114  {'type': 4, 'index': 10},
115  {'type': 4, 'index': 43},
116  {'type': 7, 'string': (61,)},
117  {'type': 4, 'index': 43},
118  {'type': 4, 'index': 8},
119  {'type': 4, 'index': 43},
120  {'type': 3, 'min': 0, 'max': 1},
121  {'type': 4, 'index': 42},
122  {'type': 4, 'index': 41})},
123  {'name': 'bad-value-line',
124  'lower': 'bad-value-line',
125  'index': 7,
126  'line': 38,
127  'is_bkru': False,
128  'is_bkrr': False,
129  'has_bkrr': False,
130  'opcodes': ({'type': 2, 'children': (1, 4, 6)},
131  {'type': 1, 'children': (2, 3)},
132  {'type': 5, 'min': 33, 'max': 90},
133  {'type': 5, 'min': 92, 'max': 126},
134  {'type': 3, 'min': 0, 'max': 9223372036854775807},
135  {'type': 4, 'index': 47},
136  {'type': 4, 'index': 41})},
137  {'name': 'value-array',
138  'lower': 'value-array',
139  'index': 8,
140  'line': 39,
141  'is_bkru': False,
142  'is_bkrr': False,
143  'has_bkrr': False,
144  'opcodes': ({'type': 2, 'children': (1, 2)},
145  {'type': 4, 'index': 11},
146  {'type': 3, 'min': 0, 'max': 9223372036854775807},
147  {'type': 2, 'children': (4, 5, 6, 7)},
148  {'type': 4, 'index': 43},
149  {'type': 7, 'string': (44,)},
150  {'type': 4, 'index': 43},
151  {'type': 4, 'index': 11})},
152  {'name': 'section-name',
153  'lower': 'section-name',
154  'index': 9,
155  'line': 40,
156  'is_bkru': False,
157  'is_bkrr': False,
158  'has_bkrr': False,
159  'opcodes': ({'type': 4, 'index': 45},)},
160  {'name': 'key-name',
161  'lower': 'key-name',
162  'index': 10,
163  'line': 41,
164  'is_bkru': False,
165  'is_bkrr': False,
166  'has_bkrr': False,
167  'opcodes': ({'type': 4, 'index': 45},)},
168  {'name': 'value',
169  'lower': 'value',
170  'index': 11,
171  'line': 42,
172  'is_bkru': False,
173  'is_bkrr': False,
174  'has_bkrr': False,
175  'opcodes': ({'type': 1, 'children': (1, 2, 3, 4, 5)},
176  {'type': 4, 'index': 16},
177  {'type': 4, 'index': 12},
178  {'type': 4, 'index': 18},
179  {'type': 4, 'index': 20},
180  {'type': 4, 'index': 17})},
181  {'name': 'boolean',
182  'lower': 'boolean',
183  'index': 12,
184  'line': 43,
185  'is_bkru': False,
186  'is_bkrr': False,
187  'has_bkrr': False,
188  'opcodes': ({'type': 1, 'children': (1, 2, 3)},
189  {'type': 4, 'index': 13},
190  {'type': 4, 'index': 14},
191  {'type': 4, 'index': 15})},
192  {'name': 'true',
193  'lower': 'true',
194  'index': 13,
195  'line': 44,
196  'is_bkru': False,
197  'is_bkrr': False,
198  'has_bkrr': False,
199  'opcodes': ({'type': 1, 'children': (1, 2)},
200  {'type': 7, 'string': (116, 114, 117, 101)},
201  {'type': 7, 'string': (121, 101, 115)})},
202  {'name': 'false',
203  'lower': 'false',
204  'index': 14,
205  'line': 45,
206  'is_bkru': False,
207  'is_bkrr': False,
208  'has_bkrr': False,
209  'opcodes': ({'type': 1, 'children': (1, 2)},
210  {'type': 7, 'string': (102, 97, 108, 115, 101)},
211  {'type': 7, 'string': (110, 111)})},
212  {'name': 'null',
213  'lower': 'null',
214  'index': 15,
215  'line': 46,
216  'is_bkru': False,
217  'is_bkrr': False,
218  'has_bkrr': False,
219  'opcodes': ({'type': 1, 'children': (1, 2)},
220  {'type': 7, 'string': (110, 117, 108, 108)},
221  {'type': 7, 'string': (118, 111, 105, 100)})},
222  {'name': 'number',
223  'lower': 'number',
224  'index': 16,
225  'line': 47,
226  'is_bkru': False,
227  'is_bkrr': False,
228  'has_bkrr': False,
229  'opcodes': ({'type': 3, 'min': 1, 'max': 9223372036854775807},
230  {'type': 4, 'index': 46})},
231  {'name': 'string',
232  'lower': 'string',
233  'index': 17,
234  'line': 48,
235  'is_bkru': False,
236  'is_bkrr': False,
237  'has_bkrr': False,
238  'opcodes': ({'type': 2, 'children': (1, 8)},
239  {'type': 1, 'children': (2, 3, 4, 5, 6, 7)},
240  {'type': 6, 'string': (33,)},
241  {'type': 5, 'min': 35, 'max': 38},
242  {'type': 5, 'min': 40, 'max': 43},
243  {'type': 5, 'min': 45, 'max': 91},
244  {'type': 5, 'min': 93, 'max': 126},
245  {'type': 4, 'index': 22},
246  {'type': 3, 'min': 0, 'max': 9223372036854775807},
247  {'type': 1, 'children': (10, 11, 12, 13)},
248  {'type': 5, 'min': 32, 'max': 43},
249  {'type': 5, 'min': 45, 'max': 91},
250  {'type': 5, 'min': 93, 'max': 126},
251  {'type': 4, 'index': 22})},
252  {'name': 'd-quoted-string',
253  'lower': 'd-quoted-string',
254  'index': 18,
255  'line': 49,
256  'is_bkru': False,
257  'is_bkrr': False,
258  'has_bkrr': False,
259  'opcodes': ({'type': 2, 'children': (1, 2, 3)},
260  {'type': 6, 'string': (34,)},
261  {'type': 4, 'index': 19},
262  {'type': 6, 'string': (34,)})},
263  {'name': 'd-quoted-value',
264  'lower': 'd-quoted-value',
265  'index': 19,
266  'line': 50,
267  'is_bkru': False,
268  'is_bkrr': False,
269  'has_bkrr': False,
270  'opcodes': ({'type': 3, 'min': 1, 'max': 9223372036854775807},
271  {'type': 1, 'children': (2, 3, 4, 5)},
272  {'type': 5, 'min': 32, 'max': 33},
273  {'type': 5, 'min': 35, 'max': 91},
274  {'type': 5, 'min': 93, 'max': 126},
275  {'type': 4, 'index': 22})},
276  {'name': 's-quoted-string',
277  'lower': 's-quoted-string',
278  'index': 20,
279  'line': 51,
280  'is_bkru': False,
281  'is_bkrr': False,
282  'has_bkrr': False,
283  'opcodes': ({'type': 2, 'children': (1, 2, 3)},
284  {'type': 6, 'string': (39,)},
285  {'type': 4, 'index': 21},
286  {'type': 6, 'string': (39,)})},
287  {'name': 's-quoted-value',
288  'lower': 's-quoted-value',
289  'index': 21,
290  'line': 52,
291  'is_bkru': False,
292  'is_bkrr': False,
293  'has_bkrr': False,
294  'opcodes': ({'type': 3, 'min': 1, 'max': 9223372036854775807},
295  {'type': 1, 'children': (2, 3, 4, 5)},
296  {'type': 5, 'min': 32, 'max': 38},
297  {'type': 5, 'min': 40, 'max': 91},
298  {'type': 5, 'min': 93, 'max': 126},
299  {'type': 4, 'index': 22})},
300  {'name': 'escaped',
301  'lower': 'escaped',
302  'index': 22,
303  'line': 53,
304  'is_bkru': False,
305  'is_bkrr': False,
306  'has_bkrr': False,
307  'opcodes': ({'type': 2, 'children': (1, 2)},
308  {'type': 6, 'string': (92,)},
309  {'type': 1,
310  'children': (3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16)},
311  {'type': 4, 'index': 23},
312  {'type': 4, 'index': 24},
313  {'type': 4, 'index': 25},
314  {'type': 4, 'index': 26},
315  {'type': 4, 'index': 27},
316  {'type': 4, 'index': 28},
317  {'type': 4, 'index': 29},
318  {'type': 4, 'index': 30},
319  {'type': 4, 'index': 31},
320  {'type': 4, 'index': 32},
321  {'type': 4, 'index': 33},
322  {'type': 4, 'index': 34},
323  {'type': 4, 'index': 35},
324  {'type': 4, 'index': 36})},
325  {'name': 'back-slash',
326  'lower': 'back-slash',
327  'index': 23,
328  'line': 67,
329  'is_bkru': False,
330  'is_bkrr': False,
331  'has_bkrr': False,
332  'opcodes': ({'type': 6, 'string': (92,)},)},
333  {'name': 'double-quote',
334  'lower': 'double-quote',
335  'index': 24,
336  'line': 68,
337  'is_bkru': False,
338  'is_bkrr': False,
339  'has_bkrr': False,
340  'opcodes': ({'type': 6, 'string': (34,)},)},
341  {'name': 'hash',
342  'lower': 'hash',
343  'index': 25,
344  'line': 69,
345  'is_bkru': False,
346  'is_bkrr': False,
347  'has_bkrr': False,
348  'opcodes': ({'type': 6, 'string': (35,)},)},
349  {'name': 'single-quote',
350  'lower': 'single-quote',
351  'index': 26,
352  'line': 70,
353  'is_bkru': False,
354  'is_bkrr': False,
355  'has_bkrr': False,
356  'opcodes': ({'type': 6, 'string': (39,)},)},
357  {'name': 'comma',
358  'lower': 'comma',
359  'index': 27,
360  'line': 71,
361  'is_bkru': False,
362  'is_bkrr': False,
363  'has_bkrr': False,
364  'opcodes': ({'type': 6, 'string': (44,)},)},
365  {'name': 'colon',
366  'lower': 'colon',
367  'index': 28,
368  'line': 72,
369  'is_bkru': False,
370  'is_bkrr': False,
371  'has_bkrr': False,
372  'opcodes': ({'type': 6, 'string': (58,)},)},
373  {'name': 'semicolon',
374  'lower': 'semicolon',
375  'index': 29,
376  'line': 73,
377  'is_bkru': False,
378  'is_bkrr': False,
379  'has_bkrr': False,
380  'opcodes': ({'type': 6, 'string': (59,)},)},
381  {'name': 'equal-sign',
382  'lower': 'equal-sign',
383  'index': 30,
384  'line': 74,
385  'is_bkru': False,
386  'is_bkrr': False,
387  'has_bkrr': False,
388  'opcodes': ({'type': 6, 'string': (61,)},)},
389  {'name': 'blank',
390  'lower': 'blank',
391  'index': 31,
392  'line': 75,
393  'is_bkru': False,
394  'is_bkrr': False,
395  'has_bkrr': False,
396  'opcodes': ({'type': 6, 'string': (98,)},)},
397  {'name': 'tab',
398  'lower': 'tab',
399  'index': 32,
400  'line': 76,
401  'is_bkru': False,
402  'is_bkrr': False,
403  'has_bkrr': False,
404  'opcodes': ({'type': 6, 'string': (116,)},)},
405  {'name': 'line-feed',
406  'lower': 'line-feed',
407  'index': 33,
408  'line': 77,
409  'is_bkru': False,
410  'is_bkrr': False,
411  'has_bkrr': False,
412  'opcodes': ({'type': 6, 'string': (110,)},)},
413  {'name': 'carriage-return',
414  'lower': 'carriage-return',
415  'index': 34,
416  'line': 78,
417  'is_bkru': False,
418  'is_bkrr': False,
419  'has_bkrr': False,
420  'opcodes': ({'type': 6, 'string': (114,)},)},
421  {'name': 'unicode',
422  'lower': 'unicode',
423  'index': 35,
424  'line': 79,
425  'is_bkru': False,
426  'is_bkrr': False,
427  'has_bkrr': False,
428  'opcodes': ({'type': 2, 'children': (1, 2)},
429  {'type': 6, 'string': (117,)},
430  {'type': 3, 'min': 4, 'max': 4},
431  {'type': 4, 'index': 37})},
432  {'name': 'hexadecimal',
433  'lower': 'hexadecimal',
434  'index': 36,
435  'line': 80,
436  'is_bkru': False,
437  'is_bkrr': False,
438  'has_bkrr': False,
439  'opcodes': ({'type': 2, 'children': (1, 2)},
440  {'type': 6, 'string': (120,)},
441  {'type': 3, 'min': 2, 'max': 2},
442  {'type': 4, 'index': 37})},
443  {'name': 'hh',
444  'lower': 'hh',
445  'index': 37,
446  'line': 81,
447  'is_bkru': False,
448  'is_bkrr': False,
449  'has_bkrr': False,
450  'opcodes': ({'type': 1, 'children': (1, 2, 3)},
451  {'type': 5, 'min': 48, 'max': 57},
452  {'type': 5, 'min': 65, 'max': 72},
453  {'type': 5, 'min': 97, 'max': 104})},
454  {'name': 'blank-line',
455  'lower': 'blank-line',
456  'index': 38,
457  'line': 82,
458  'is_bkru': False,
459  'is_bkrr': False,
460  'has_bkrr': False,
461  'opcodes': ({'type': 1, 'children': (1, 2)},
462  {'type': 4, 'index': 39},
463  {'type': 4, 'index': 40})},
464  {'name': 'good-blank-line',
465  'lower': 'good-blank-line',
466  'index': 39,
467  'line': 83,
468  'is_bkru': False,
469  'is_bkrr': False,
470  'has_bkrr': False,
471  'opcodes': ({'type': 2, 'children': (1, 2, 4)},
472  {'type': 4, 'index': 43},
473  {'type': 3, 'min': 0, 'max': 1},
474  {'type': 4, 'index': 42},
475  {'type': 4, 'index': 41})},
476  {'name': 'bad-blank-line',
477  'lower': 'bad-blank-line',
478  'index': 40,
479  'line': 84,
480  'is_bkru': False,
481  'is_bkrr': False,
482  'has_bkrr': False,
483  'opcodes': ({'type': 2, 'children': (1, 4, 5, 8, 10)},
484  {'type': 1, 'children': (2, 3)},
485  {'type': 6, 'string': (32,)},
486  {'type': 6, 'string': (9,)},
487  {'type': 4, 'index': 43},
488  {'type': 1, 'children': (6, 7)},
489  {'type': 5, 'min': 33, 'max': 58},
490  {'type': 5, 'min': 60, 'max': 126},
491  {'type': 3, 'min': 0, 'max': 9223372036854775807},
492  {'type': 4, 'index': 47},
493  {'type': 4, 'index': 41})},
494  {'name': 'line-end',
495  'lower': 'line-end',
496  'index': 41,
497  'line': 85,
498  'is_bkru': False,
499  'is_bkrr': False,
500  'has_bkrr': False,
501  'opcodes': ({'type': 1, 'children': (1, 2, 3)},
502  {'type': 6, 'string': (13, 10)},
503  {'type': 6, 'string': (10,)},
504  {'type': 6, 'string': (13,)})},
505  {'name': 'comment',
506  'lower': 'comment',
507  'index': 42,
508  'line': 86,
509  'is_bkru': False,
510  'is_bkrr': False,
511  'has_bkrr': False,
512  'opcodes': ({'type': 2, 'children': (1, 2)},
513  {'type': 6, 'string': (59,)},
514  {'type': 3, 'min': 0, 'max': 9223372036854775807},
515  {'type': 4, 'index': 47})},
516  {'name': 'wsp',
517  'lower': 'wsp',
518  'index': 43,
519  'line': 87,
520  'is_bkru': False,
521  'is_bkrr': False,
522  'has_bkrr': False,
523  'opcodes': ({'type': 3, 'min': 0, 'max': 9223372036854775807},
524  {'type': 1, 'children': (2, 3)},
525  {'type': 6, 'string': (32,)},
526  {'type': 6, 'string': (9,)})},
527  {'name': 'alpha',
528  'lower': 'alpha',
529  'index': 44,
530  'line': 88,
531  'is_bkru': False,
532  'is_bkrr': False,
533  'has_bkrr': False,
534  'opcodes': ({'type': 1, 'children': (1, 2)},
535  {'type': 5, 'min': 65, 'max': 90},
536  {'type': 5, 'min': 97, 'max': 122})},
537  {'name': 'alphanum',
538  'lower': 'alphanum',
539  'index': 45,
540  'line': 89,
541  'is_bkru': False,
542  'is_bkrr': False,
543  'has_bkrr': False,
544  'opcodes': ({'type': 2, 'children': (1, 4)},
545  {'type': 1, 'children': (2, 3)},
546  {'type': 4, 'index': 44},
547  {'type': 6, 'string': (95,)},
548  {'type': 3, 'min': 0, 'max': 9223372036854775807},
549  {'type': 1, 'children': (6, 7, 8)},
550  {'type': 4, 'index': 44},
551  {'type': 4, 'index': 46},
552  {'type': 6, 'string': (95,)})},
553  {'name': 'digit',
554  'lower': 'digit',
555  'index': 46,
556  'line': 90,
557  'is_bkru': False,
558  'is_bkrr': False,
559  'has_bkrr': False,
560  'opcodes': ({'type': 5, 'min': 48, 'max': 57},)},
561  {'name': 'any',
562  'lower': 'any',
563  'index': 47,
564  'line': 91,
565  'is_bkru': False,
566  'is_bkrr': False,
567  'has_bkrr': False,
568  'opcodes': ({'type': 1, 'children': (1, 2)},
569  {'type': 5, 'min': 32, 'max': 126},
570  {'type': 6, 'string': (9,)})})
571 
572 # UDTS
573 udts = ()
574 
575 has_bkru = False
576 has_bkrr = False
577 
578 
579 def to_string():
580  '''Displays the original SABNF syntax.'''
581  sabnf = ""
582  sabnf += ";\n"
583  sabnf += "; Ref: https://en.wikipedia.org: INI File\n"
584  sabnf += ";\n"
585  sabnf += "; comments begin with the semicolon, \";\" and continue to the end of the line\n"
586  sabnf += "; comments may appear on valid section and value lines as well as blank lines\n"
587  sabnf += "; line ends may be CRLF, LF or CR\n"
588  sabnf += "; tabs, 0x09, may NOT occur in quoted strings\n"
589  sabnf += ";\n"
590  sabnf += "; keys may have multiple values\n"
591  sabnf += "; - multiple values may be given as a comma delimited list on a single line\n"
592  sabnf += "; - multiple values may be listed separately on separate lines with the same key name\n"
593  sabnf += ";\n"
594  sabnf += "; section names are optional\n"
595  sabnf += "; - keys need not appear in a named section\n"
596  sabnf += ";\n"
597  sabnf += "; sections are \"disjoint\",\n"
598  sabnf += "; - that is the keys in multiple occurrences of a section name are\n"
599  sabnf += "; - simply joined together as if they appeared contiguously in a single section\n"
600  sabnf += ";\n"
601  sabnf += "; sections end at the beginning of a new section or the end of file\n"
602  sabnf += ";\n"
603  sabnf += "; section and key names are alphanumeric + underscore (must begin with alpha or underscore)\n"
604  sabnf += "; values that are not alphanumeric must be single or double quoted\n"
605  sabnf += ";\n"
606  sabnf += "; The grammar is designed to accept any string of ASCII characters without failure.\n"
607  sabnf += "; The \"error productions\", bad-section-line, bad-value-line, bad-blank-line are meant to accept all lines\n"
608  sabnf += "; that are not otherwise correct blank, section or value lines. This is so that\n"
609  sabnf += "; parser callback functions can recognize input errors and report or react to them\n"
610  sabnf += "; in an application-dependent manner.\n"
611  sabnf += ";\n"
612  sabnf += ";\n"
613  sabnf += "ini-file = *(blank-line / value-line) *section\n"
614  sabnf += "section = section-line *(blank-line / value-line)\n"
615  sabnf += "section-line = good-section-line / bad-section-line\n"
616  sabnf += "good-section-line = \"[\" wsp section-name wsp \"]\" wsp [comment] line-end\n"
617  sabnf += "bad-section-line = \"[\" *any line-end;\n"
618  sabnf += "value-line = good-value / bad-value-line\n"
619  sabnf += "good-value = key-name wsp \"=\" wsp value-array wsp [comment] line-end\n"
620  sabnf += "bad-value-line = (%d33-90 / %d92-126) *any line-end\n"
621  sabnf += "value-array = value *(wsp \",\" wsp value)\n"
622  sabnf += "section-name = alphanum\n"
623  sabnf += "key-name = alphanum\n"
624  sabnf += "value = number / boolean / d-quoted-string / s-quoted-string / string\n"
625  sabnf += "boolean = true / false / null\n"
626  sabnf += "true = \"true\" / \"yes\"\n"
627  sabnf += "false = \"false\" / \"no\"\n"
628  sabnf += "null = \"null\" / \"void\"\n"
629  sabnf += "number = 1*digit\n"
630  sabnf += "string = (%d33 / %d35-38 / %d40-43 / %d45-91 / %d93-126 / escaped) *(%d32-43 / %d45-91 / %d93-126 / escaped)\n"
631  sabnf += "d-quoted-string = %d34 d-quoted-value %d34\n"
632  sabnf += "d-quoted-value = 1*(%d32-33 / %d35-91 / %d93-126 / escaped)\n"
633  sabnf += "s-quoted-string = %d39 s-quoted-value %d39\n"
634  sabnf += "s-quoted-value = 1*(%d32-38 / %d40-91 / %d93-126 / escaped)\n"
635  sabnf += "escaped = %x5c (back-slash\n"
636  sabnf += " / double-quote\n"
637  sabnf += " / hash\n"
638  sabnf += " / single-quote\n"
639  sabnf += " / comma\n"
640  sabnf += " / colon\n"
641  sabnf += " / semicolon\n"
642  sabnf += " / equal-sign\n"
643  sabnf += " / blank\n"
644  sabnf += " / tab\n"
645  sabnf += " / line-feed\n"
646  sabnf += " / carriage-return\n"
647  sabnf += " / unicode\n"
648  sabnf += " / hexadecimal)\n"
649  sabnf += "back-slash = %x5c\n"
650  sabnf += "double-quote = %x22\n"
651  sabnf += "hash = %x23\n"
652  sabnf += "single-quote = %x27\n"
653  sabnf += "comma = %x2c\n"
654  sabnf += "colon = %x3a\n"
655  sabnf += "semicolon = %x3b\n"
656  sabnf += "equal-sign = %x3d\n"
657  sabnf += "blank = %s\"b\"\n"
658  sabnf += "tab = %s\"t\"\n"
659  sabnf += "line-feed = %s\"n\"\n"
660  sabnf += "carriage-return = %s\"r\"\n"
661  sabnf += "unicode = %s\"u\" 4hh\n"
662  sabnf += "hexadecimal = %s\"x\" 2hh\n"
663  sabnf += "hh = %d48-57 / %d65-72 / %d97-104\n"
664  sabnf += "blank-line = good-blank-line / bad-blank-line\n"
665  sabnf += "good-blank-line = wsp [comment] line-end\n"
666  sabnf += "bad-blank-line = (%d32 / %d9) wsp (%d33-58 / %d60-126) *any line-end\n"
667  sabnf += "line-end = %d13.10 / %d10 / %d13\n"
668  sabnf += "comment = %d59 *any\n"
669  sabnf += "wsp = *(%d32 / %d9)\n"
670  sabnf += "alpha = %d65-90 / %d97-122\n"
671  sabnf += "alphanum = (alpha / %d95) *(alpha / digit / %d95)\n"
672  sabnf += "digit = %d48-57\n"
673  sabnf += "any = %d32-126 / %d9\n"
674  return sabnf
675 
def to_string()
Displays the original SABNF syntax.
Definition: grammar.py:579
Python APG, Version 1.0, is licensed under the 2-Clause BSD License,
an Open Source Initiative Approved License.