Version 1.0
Copyright © 2022 Lowell D. Thomas
Python APG
 … an ABNF Parser Generator
scanner_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 = 10
7 # udts = 0
8 # opcodes = 31
9 # --- ABNF original opcodes
10 # ALT = 5
11 # CAT = 2
12 # REP = 4
13 # RNM = 11
14 # TLS = 0
15 # TBS = 4
16 # TRG = 5
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 = [0 - 9223372036854775807]
27 #
28 
29 # RULES
30 rules = ({'name': 'file',
31  'lower': 'file',
32  'index': 0,
33  'line': 0,
34  'is_bkru': False,
35  'is_bkrr': False,
36  'has_bkrr': False,
37  'opcodes': ({'type': 2, 'children': (1, 3)},
38  {'type': 3, 'min': 0, 'max': 9223372036854775807},
39  {'type': 4, 'index': 1},
40  {'type': 3, 'min': 0, 'max': 1},
41  {'type': 4, 'index': 3})},
42  {'name': 'line',
43  'lower': 'line',
44  'index': 1,
45  'line': 1,
46  'is_bkru': False,
47  'is_bkrr': False,
48  'has_bkrr': False,
49  'opcodes': ({'type': 2, 'children': (1, 2)},
50  {'type': 4, 'index': 2},
51  {'type': 4, 'index': 6})},
52  {'name': 'line-text',
53  'lower': 'line-text',
54  'index': 2,
55  'line': 2,
56  'is_bkru': False,
57  'is_bkrr': False,
58  'has_bkrr': False,
59  'opcodes': ({'type': 3, 'min': 0, 'max': 9223372036854775807},
60  {'type': 1, 'children': (2, 3)},
61  {'type': 4, 'index': 4},
62  {'type': 4, 'index': 5})},
63  {'name': 'last-line',
64  'lower': 'last-line',
65  'index': 3,
66  'line': 3,
67  'is_bkru': False,
68  'is_bkrr': False,
69  'has_bkrr': False,
70  'opcodes': ({'type': 3, 'min': 1, 'max': 9223372036854775807},
71  {'type': 1, 'children': (2, 3)},
72  {'type': 4, 'index': 4},
73  {'type': 4, 'index': 5})},
74  {'name': 'valid',
75  'lower': 'valid',
76  'index': 4,
77  'line': 4,
78  'is_bkru': False,
79  'is_bkrr': False,
80  'has_bkrr': False,
81  'opcodes': ({'type': 1, 'children': (1, 2)},
82  {'type': 5, 'min': 32, 'max': 126},
83  {'type': 6, 'string': (9,)})},
84  {'name': 'invalid',
85  'lower': 'invalid',
86  'index': 5,
87  'line': 5,
88  'is_bkru': False,
89  'is_bkrr': False,
90  'has_bkrr': False,
91  'opcodes': ({'type': 1, 'children': (1, 2, 3, 4)},
92  {'type': 5, 'min': 0, 'max': 8},
93  {'type': 5, 'min': 11, 'max': 12},
94  {'type': 5, 'min': 14, 'max': 31},
95  {'type': 5, 'min': 127, 'max': 9223372036854775807})},
96  {'name': 'end',
97  'lower': 'end',
98  'index': 6,
99  'line': 6,
100  'is_bkru': False,
101  'is_bkrr': False,
102  'has_bkrr': False,
103  'opcodes': ({'type': 1, 'children': (1, 2, 3)},
104  {'type': 4, 'index': 7},
105  {'type': 4, 'index': 8},
106  {'type': 4, 'index': 9})},
107  {'name': 'CRLF',
108  'lower': 'crlf',
109  'index': 7,
110  'line': 7,
111  'is_bkru': False,
112  'is_bkrr': False,
113  'has_bkrr': False,
114  'opcodes': ({'type': 6, 'string': (13, 10)},)},
115  {'name': 'LF',
116  'lower': 'lf',
117  'index': 8,
118  'line': 8,
119  'is_bkru': False,
120  'is_bkrr': False,
121  'has_bkrr': False,
122  'opcodes': ({'type': 6, 'string': (10,)},)},
123  {'name': 'CR',
124  'lower': 'cr',
125  'index': 9,
126  'line': 9,
127  'is_bkru': False,
128  'is_bkrr': False,
129  'has_bkrr': False,
130  'opcodes': ({'type': 6, 'string': (13,)},)})
131 
132 # UDTS
133 udts = ()
134 
135 has_bkru = False
136 has_bkrr = False
137 
138 
139 def to_string():
140  '''Displays the original SABNF syntax.'''
141  sabnf = ""
142  sabnf += "file = *line [last-line]\n"
143  sabnf += "line = line-text end\n"
144  sabnf += "line-text = *(valid/invalid)\n"
145  sabnf += "last-line = 1*(valid/invalid)\n"
146  sabnf += "valid = %d32-126 / %d9\n"
147  sabnf += "invalid = %d0-8 / %d11-12 /%d14-31 / %x7f-7FFFFFFFFFFFFFFF\n"
148  sabnf += "end = CRLF / LF / CR\n"
149  sabnf += "CRLF = %d13.10\n"
150  sabnf += "LF = %d10\n"
151  sabnf += "CR = %d13\n"
152  return sabnf
153 
def to_string()
Displays the original SABNF syntax.
Python APG, Version 1.0, is licensed under the 2-Clause BSD License,
an Open Source Initiative Approved License.