omextra 0.0.0.dev496__py3-none-any.whl → 0.0.0.dev498__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- omextra/text/abnf/__init__.py +51 -18
- omextra/text/abnf/_dataclasses.py +246 -0
- omextra/text/abnf/base.py +21 -257
- omextra/text/abnf/core.py +22 -10
- omextra/text/abnf/grammars.py +235 -0
- omextra/text/abnf/internal.py +1 -1
- omextra/text/abnf/matches.py +145 -0
- omextra/text/abnf/meta.py +45 -12
- omextra/text/abnf/ops.py +76 -9
- omextra/text/abnf/opto.py +257 -0
- omextra/text/abnf/parsing.py +134 -20
- omextra/text/abnf/utils.py +38 -41
- omextra/text/abnf/visitors.py +1 -1
- {omextra-0.0.0.dev496.dist-info → omextra-0.0.0.dev498.dist-info}/METADATA +2 -2
- {omextra-0.0.0.dev496.dist-info → omextra-0.0.0.dev498.dist-info}/RECORD +19 -16
- {omextra-0.0.0.dev496.dist-info → omextra-0.0.0.dev498.dist-info}/WHEEL +0 -0
- {omextra-0.0.0.dev496.dist-info → omextra-0.0.0.dev498.dist-info}/entry_points.txt +0 -0
- {omextra-0.0.0.dev496.dist-info → omextra-0.0.0.dev498.dist-info}/licenses/LICENSE +0 -0
- {omextra-0.0.0.dev496.dist-info → omextra-0.0.0.dev498.dist-info}/top_level.txt +0 -0
omextra/text/abnf/utils.py
CHANGED
|
@@ -1,62 +1,59 @@
|
|
|
1
|
-
import itertools
|
|
2
1
|
import textwrap
|
|
3
2
|
import typing as ta
|
|
4
3
|
|
|
5
4
|
from omlish import check
|
|
6
5
|
|
|
7
|
-
from .
|
|
8
|
-
from .
|
|
6
|
+
from .grammars import Channel
|
|
7
|
+
from .grammars import Grammar
|
|
8
|
+
from .matches import Match
|
|
9
|
+
from .matches import filter_matches
|
|
9
10
|
from .ops import RuleRef
|
|
10
11
|
|
|
11
12
|
|
|
12
13
|
##
|
|
13
14
|
|
|
14
15
|
|
|
15
|
-
def
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
return rec(m)
|
|
16
|
+
def filter_match_channels(
|
|
17
|
+
m: Match,
|
|
18
|
+
g: Grammar,
|
|
19
|
+
*,
|
|
20
|
+
keep: ta.Container[Channel] | None = None,
|
|
21
|
+
remove: ta.Container[Channel] | None = None,
|
|
22
|
+
keep_children: bool = False,
|
|
23
|
+
) -> Match:
|
|
24
|
+
if keep is None and remove is None:
|
|
25
|
+
return m
|
|
26
26
|
|
|
27
|
+
def fn(x: Match) -> bool:
|
|
28
|
+
if not isinstance((rr := x.op), RuleRef):
|
|
29
|
+
return False
|
|
27
30
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
if
|
|
31
|
-
return
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
31
|
+
r = check.not_none(g.rule(rr.name))
|
|
32
|
+
|
|
33
|
+
if keep is not None and r.channel not in keep:
|
|
34
|
+
return False
|
|
35
|
+
|
|
36
|
+
if remove is not None and r.channel in remove:
|
|
37
|
+
return False
|
|
38
|
+
|
|
39
|
+
return True
|
|
40
|
+
|
|
41
|
+
return filter_matches(
|
|
42
|
+
fn,
|
|
43
|
+
m,
|
|
44
|
+
keep_children=keep_children,
|
|
45
|
+
)
|
|
35
46
|
|
|
36
47
|
|
|
37
48
|
#
|
|
38
49
|
|
|
39
50
|
|
|
40
|
-
def
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
**kwargs: ta.Any,
|
|
47
|
-
) -> Match | None:
|
|
48
|
-
if (match := grammar.parse(
|
|
49
|
-
source,
|
|
50
|
-
root,
|
|
51
|
-
start=start,
|
|
52
|
-
**kwargs,
|
|
53
|
-
)) is None:
|
|
54
|
-
return None
|
|
55
|
-
|
|
56
|
-
match = only_match_rules(match)
|
|
57
|
-
match = strip_insignificant_match_rules(match, grammar)
|
|
58
|
-
|
|
59
|
-
return match
|
|
51
|
+
def only_match_rules(m: Match) -> Match:
|
|
52
|
+
return filter_matches(
|
|
53
|
+
lambda x: isinstance(x.op, RuleRef),
|
|
54
|
+
m,
|
|
55
|
+
keep_children=True,
|
|
56
|
+
)
|
|
60
57
|
|
|
61
58
|
|
|
62
59
|
##
|
omextra/text/abnf/visitors.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: omextra
|
|
3
|
-
Version: 0.0.0.
|
|
3
|
+
Version: 0.0.0.dev498
|
|
4
4
|
Summary: omextra
|
|
5
5
|
Author: wrmsr
|
|
6
6
|
License-Expression: BSD-3-Clause
|
|
@@ -14,7 +14,7 @@ Classifier: Programming Language :: Python :: 3.13
|
|
|
14
14
|
Requires-Python: >=3.13
|
|
15
15
|
Description-Content-Type: text/markdown
|
|
16
16
|
License-File: LICENSE
|
|
17
|
-
Requires-Dist: omlish==0.0.0.
|
|
17
|
+
Requires-Dist: omlish==0.0.0.dev498
|
|
18
18
|
Dynamic: license-file
|
|
19
19
|
|
|
20
20
|
# Overview
|
|
@@ -65,17 +65,20 @@ omextra/sql/parsing/_antlr/MinisqlVisitor.py,sha256=UPs2qA2VlNRP_LMwF0DpMxMir9tI
|
|
|
65
65
|
omextra/sql/parsing/_antlr/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
66
66
|
omextra/text/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
67
67
|
omextra/text/abnf/LICENSE,sha256=UJzrhSePw9TVm0VfkVmx9NRHkPS1n6jx2UgajTb14ts,1054
|
|
68
|
-
omextra/text/abnf/__init__.py,sha256=
|
|
69
|
-
omextra/text/abnf/_dataclasses.py,sha256=
|
|
70
|
-
omextra/text/abnf/base.py,sha256=
|
|
71
|
-
omextra/text/abnf/core.py,sha256=
|
|
68
|
+
omextra/text/abnf/__init__.py,sha256=qCV4I7sMWw2k3B4LnHrURwic2m1ewYdaOteu2n2lx0E,2662
|
|
69
|
+
omextra/text/abnf/_dataclasses.py,sha256=G7fqKpNvWZ-HtdlkwQ_O3IE-eD7-i0Fdq470l2ujM38,29545
|
|
70
|
+
omextra/text/abnf/base.py,sha256=GaNDZxC7rFkbQDTLVFwprtbk_288p7F40zgGkeLiwzY,969
|
|
71
|
+
omextra/text/abnf/core.py,sha256=CO62fK2Ez7XqVkESp_yNfX4iDY8tgph5b9fgmCMam0I,2728
|
|
72
72
|
omextra/text/abnf/errors.py,sha256=uj1oQvRVRlWkMG8mpmcRUg25kICeIJx5EWAVij3pmXc,142
|
|
73
|
-
omextra/text/abnf/
|
|
74
|
-
omextra/text/abnf/
|
|
75
|
-
omextra/text/abnf/
|
|
76
|
-
omextra/text/abnf/
|
|
77
|
-
omextra/text/abnf/
|
|
78
|
-
omextra/text/abnf/
|
|
73
|
+
omextra/text/abnf/grammars.py,sha256=PZn7jjzz6p2FGNSjO4OAqmyrAEc8_im17mtsoq3QMa8,5814
|
|
74
|
+
omextra/text/abnf/internal.py,sha256=BltBOKj1uXDxtPgpajt_a6va3Nj7x2SEFRSvevjkIzY,501
|
|
75
|
+
omextra/text/abnf/matches.py,sha256=YsGooPUnrxQsfBgvJoZPkPXKgHNq_HpVsxfzjG6wu-Y,3546
|
|
76
|
+
omextra/text/abnf/meta.py,sha256=7O0WgPKUk6dqQHVGKpVdCX6EAbphj7Gv7GAtkFKcoAY,15151
|
|
77
|
+
omextra/text/abnf/ops.py,sha256=gwN9kxsFmXh3CPN8bTXzDVP775d8hnYFiay4mRijfxc,8068
|
|
78
|
+
omextra/text/abnf/opto.py,sha256=4S97lkk_n4DWjvHqFvapKyMqWbI1voBS4Fhm7bdn3ks,6743
|
|
79
|
+
omextra/text/abnf/parsing.py,sha256=6WGn21gzFJlmVwOzJDD30YkpwXSVuLZlJNk7sGbZOik,9760
|
|
80
|
+
omextra/text/abnf/utils.py,sha256=EXyG5lZ561keeH5XFEePaH4UGa2wW-Aw2t9lE6aCJCc,1261
|
|
81
|
+
omextra/text/abnf/visitors.py,sha256=5Or7Tht5JqNAfoICLmeAXJEZV-nWyMIybvvYcSpNHEc,1269
|
|
79
82
|
omextra/text/abnf/docs/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
80
83
|
omextra/text/abnf/docs/rfc5234.txt,sha256=I478qv82TBjP29ZpQT-D6_pb3rHOU6wiwN2ZMGiXLLU,26352
|
|
81
84
|
omextra/text/abnf/docs/rfc7405.txt,sha256=Bwt1VISu7eBvlPox9a0iuVD_uCF39teXrEMUQAuuvqU,6661
|
|
@@ -152,9 +155,9 @@ omextra/text/antlr/cli/__main__.py,sha256=ckYkj0drxabBVwWYewH2SS36TTeAxllZtS4xEl
|
|
|
152
155
|
omextra/text/antlr/cli/cli.py,sha256=LW8pJNmySBOV3g8QxquPjUgxFv7YblzEyi555hHH3_M,1234
|
|
153
156
|
omextra/text/antlr/cli/consts.py,sha256=HUYJP9j4RfeuuQv6HFd2oFMS0piWJ9Sq1tbeAs4OlBc,290
|
|
154
157
|
omextra/text/antlr/cli/gen.py,sha256=HYleVptrpynwcl6GspX6O9_oMRSxwdYAQGuUFfDYse8,5236
|
|
155
|
-
omextra-0.0.0.
|
|
156
|
-
omextra-0.0.0.
|
|
157
|
-
omextra-0.0.0.
|
|
158
|
-
omextra-0.0.0.
|
|
159
|
-
omextra-0.0.0.
|
|
160
|
-
omextra-0.0.0.
|
|
158
|
+
omextra-0.0.0.dev498.dist-info/licenses/LICENSE,sha256=B_hVtavaA8zCYDW99DYdcpDLKz1n3BBRjZrcbv8uG8c,1451
|
|
159
|
+
omextra-0.0.0.dev498.dist-info/METADATA,sha256=7xPp8WGYYfw-EBkMVoR8c3-1VlMOkQKAOZK3ZJtGgJ0,1409
|
|
160
|
+
omextra-0.0.0.dev498.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
161
|
+
omextra-0.0.0.dev498.dist-info/entry_points.txt,sha256=-MFAMks5HgZ60Ore0Wl5lKVKk8z4kf1Ls3WY9E_OlCU,37
|
|
162
|
+
omextra-0.0.0.dev498.dist-info/top_level.txt,sha256=o1nCNRejLMcayDngLuWMWwaeOucz33BXbpuoVvvzjPc,8
|
|
163
|
+
omextra-0.0.0.dev498.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|