syncraft 0.1.37__tar.gz → 0.3.1__tar.gz

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.
Files changed (122) hide show
  1. syncraft-0.3.1/PKG-INFO +60 -0
  2. syncraft-0.3.1/README.md +46 -0
  3. syncraft-0.3.1/pyproject.toml +44 -0
  4. syncraft-0.3.1/syncraft/__init__.py +100 -0
  5. syncraft-0.3.1/syncraft/algebra.py +558 -0
  6. syncraft-0.3.1/syncraft/analysis.py +5 -0
  7. syncraft-0.3.1/syncraft/ast.py +715 -0
  8. syncraft-0.3.1/syncraft/cache/0323a09e1e0c6b6e2e03927451b2c035d6eb181fa866a4b162101715ffcc9362.lex +0 -0
  9. syncraft-0.3.1/syncraft/cache/0ad89ff788cd0fc733b414415e4b1fd310460a9040541adc766062c7f861699e.lex +0 -0
  10. syncraft-0.3.1/syncraft/cache/0ca268f038e813af17052b8ab051ae43e4057353caa1dea58effce47d33566d7.lex +0 -0
  11. syncraft-0.3.1/syncraft/cache/0ca4b3915f90a20b730dfbbf73862b99c1b62849412412128b3ef604a71f937e.lex +0 -0
  12. syncraft-0.3.1/syncraft/cache/139d2e8ffdf6c96c8d5c3f9508e0d27899d06cd396add66d4909f18495e42a1d.lex +0 -0
  13. syncraft-0.3.1/syncraft/cache/25a112229cad318466527a053645784cfe36e9241eaeea856f4ce81adbfafc4c.lex +0 -0
  14. syncraft-0.3.1/syncraft/cache/2bb80cb55dbf5d9902d2d31dbaa8c71ba9490fb5a190ccfbb688683039083b49.lex +0 -0
  15. syncraft-0.3.1/syncraft/cache/2f47f5ba4a43cbc4db0afc870d719211a799f8fba03698984477484f7b6f965d.lex +0 -0
  16. syncraft-0.3.1/syncraft/cache/30677f1ce02f17dd4e0d97213897801b44a50ff658933fb9efbf52dbe6a2a11c.lex +0 -0
  17. syncraft-0.3.1/syncraft/cache/38266a113e15c92ecc48d4abf750a1a0b252070eb264ab71e1f19012d7528c7e.lex +0 -0
  18. syncraft-0.3.1/syncraft/cache/390d35713387fe8508cf75bf55faf1b687b2bbaca5b72f36889a6768d0987f32.lex +0 -0
  19. syncraft-0.3.1/syncraft/cache/3b1b656d9c899f56a20e81793d1d87ba38458257d08bb37a504d0c5f1987a24e.lex +0 -0
  20. syncraft-0.3.1/syncraft/cache/3c4016322323afa5cfdfc2479f51da05d03d024c76dfce12022da54cf2540f37.lex +0 -0
  21. syncraft-0.3.1/syncraft/cache/427810660487e85706307e9e5549fc85b4c23cda5a3406b6b0669ae54cbdae65.lex +0 -0
  22. syncraft-0.3.1/syncraft/cache/49b33ff6f555bd8e97483b6ff3266b07c525184fb8f69363aacf81cb56fbf74b.lex +0 -0
  23. syncraft-0.3.1/syncraft/cache/4e2c4a34b56daff8a0927135b5982478e357d507e0a332753da73693ac8799e5.lex +0 -0
  24. syncraft-0.3.1/syncraft/cache/50aa0399e3d1a158b4d80daef829d30e5272dc588bd0c32941390f06241240f4.lex +0 -0
  25. syncraft-0.3.1/syncraft/cache/5b8aff732507a9fb7a9dfc7a658b32fff905d523d2e1b6c575939f2c13184d02.lex +0 -0
  26. syncraft-0.3.1/syncraft/cache/5deb7c7d3a82a6a19f1491eb9f3eb66e5170fd55f1211efa9a6fc71b19e1e9e8.lex +0 -0
  27. syncraft-0.3.1/syncraft/cache/658a7759b09a31aa5cf9ea73b0b08fa93d9c63086aed241363fab1dcac431d6b.lex +0 -0
  28. syncraft-0.3.1/syncraft/cache/7dd0dc70ecac5c1e305d63ffb17963aef0dec25befe55c06c709b4c472d338b9.lex +0 -0
  29. syncraft-0.3.1/syncraft/cache/8200ce656582293a902e6c6522561b40254ef48dca9f6cff7625959967bf4dac.lex +0 -0
  30. syncraft-0.3.1/syncraft/cache/932c3fa1ccf18106e6e593066f193f0f55c11e8916d036b8b29082dab688525e.lex +0 -0
  31. syncraft-0.3.1/syncraft/cache/9412f55cc12c5adf290442e7252b21b219d5bb6ff644cac5e01605024bee05d9.lex +0 -0
  32. syncraft-0.3.1/syncraft/cache/96c113822d4de9a6fa1af13a071e8fbf6bde5410197d3f1972eccff80255e872.lex +0 -0
  33. syncraft-0.3.1/syncraft/cache/9aa52a5105add13fae8cef61cc1f32348a6966ce0303b695e9374ecb99f4d7a5.lex +0 -0
  34. syncraft-0.3.1/syncraft/cache/aa2d31d33d5449e55fd72e2e2b967a1f09e8a344dbbc5812d0bcca2885759671.lex +0 -0
  35. syncraft-0.3.1/syncraft/cache/add85e75b03bca439e73a57e260f03a7ec645ae079175935f6cbb9d3e0c4e5b2.lex +0 -0
  36. syncraft-0.3.1/syncraft/cache/afa3bcb917c588b6ac2bff31db152cfef2c002b666af43c0b4f3965cba15efbd.lex +0 -0
  37. syncraft-0.3.1/syncraft/cache/b337e4788fbb64e2528956c3fd5c13f007d0e03ba46ae30f8b67a892ec7355b2.lex +0 -0
  38. syncraft-0.3.1/syncraft/cache/c388cddeefd427af667f710fa41f1dc82c82cc33483f656f6014d0b8b17d45fc.lex +0 -0
  39. syncraft-0.3.1/syncraft/cache/c729bdd63c706a261c6409428cff67bf2bd8877c406b06f0e6c4db0affc04a82.lex +0 -0
  40. syncraft-0.3.1/syncraft/cache/ca2387078d1f30a773f30e0976ba6048e7c8cbc19d7587ac6c7b3963a0700336.lex +0 -0
  41. syncraft-0.3.1/syncraft/cache/d040ccc8a7547e7ae0761d19dd4bb47c9ca30ea749ef35c8806a1fdf2ff27dc8.lex +0 -0
  42. syncraft-0.3.1/syncraft/cache/dc25580cc40a059965b15cbcdfae30dfe32b4384e01c34271a37689c8e262432.lex +0 -0
  43. syncraft-0.3.1/syncraft/cache/dc5c91b4d0af5853a38985de81bab92342d902f545b0cd8322311f6acafcea32.lex +0 -0
  44. syncraft-0.3.1/syncraft/cache/e690d7175e1b1edc2969a0d93b0b39dc5d65223f2f549c3ee32d7456b6cee5dd.lex +0 -0
  45. syncraft-0.3.1/syncraft/cache/e91f0273605bf92d257f0cb14f9abc5bc21aa0b5de623a708c6a528601cd3522.lex +0 -0
  46. syncraft-0.3.1/syncraft/cache/ed412eadc92dcaa8579e1d205b80af2379b99c6ff94b621abfa97ed60b7ac196.lex +0 -0
  47. syncraft-0.3.1/syncraft/cache/ef2ca0cbca40bc2a4d138b3d2a35d66aa75a32b060a036a247b677da1c7922cc.lex +0 -0
  48. syncraft-0.3.1/syncraft/cache/f11a85a630fdf609a9f42cb639c05c84031db5df2c2f4289ff7fa39e9d647d0e.lex +0 -0
  49. syncraft-0.3.1/syncraft/cache/f19b6594061a559db2a96ac2aef7339cc7512cf5818e21c779d7899d7123e603.lex +0 -0
  50. syncraft-0.3.1/syncraft/cache/f421f43b060044eecb933e3b927fdd3401f7f349218a51a191afbba66a3192ca.lex +0 -0
  51. syncraft-0.3.1/syncraft/cache/f75e69062f54f1191105309cee8dccfc54687d231cbb2a9fa43266b3f2be8a20.lex +0 -0
  52. syncraft-0.3.1/syncraft/cache/fd1704e80122886e699c32ff6018e129808af0ae956b844f334b826aeaa4d0ac.lex +0 -0
  53. syncraft-0.3.1/syncraft/cache/fecdcd73b4f8c0b5cd1c7db3eab2a0ba81059fce196c3ff878b722c801f51830.lex +0 -0
  54. syncraft-0.3.1/syncraft/cache.py +472 -0
  55. syncraft-0.3.1/syncraft/charset.py +510 -0
  56. syncraft-0.3.1/syncraft/constraint.py +412 -0
  57. syncraft-0.3.1/syncraft/dev.py +335 -0
  58. syncraft-0.3.1/syncraft/fa.py +1460 -0
  59. syncraft-0.3.1/syncraft/finder.py +111 -0
  60. syncraft-0.3.1/syncraft/generator.py +508 -0
  61. syncraft-0.3.1/syncraft/input.py +484 -0
  62. syncraft-0.3.1/syncraft/lexer.py +574 -0
  63. syncraft-0.3.1/syncraft/parser.py +505 -0
  64. syncraft-0.3.1/syncraft/path.py +20 -0
  65. syncraft-0.3.1/syncraft/regex.py +515 -0
  66. {syncraft-0.1.37 → syncraft-0.3.1}/syncraft/sqlite3.py +194 -473
  67. syncraft-0.3.1/syncraft/syntax.py +1232 -0
  68. syncraft-0.3.1/syncraft/token.py +296 -0
  69. syncraft-0.3.1/syncraft/utils.py +450 -0
  70. syncraft-0.3.1/syncraft.egg-info/PKG-INFO +60 -0
  71. syncraft-0.3.1/syncraft.egg-info/SOURCES.txt +102 -0
  72. syncraft-0.3.1/syncraft.egg-info/requires.txt +2 -0
  73. syncraft-0.3.1/tests/test_anchors.py +65 -0
  74. syncraft-0.3.1/tests/test_bimap.py +321 -0
  75. syncraft-0.3.1/tests/test_charset.py +248 -0
  76. syncraft-0.3.1/tests/test_choice_kind_none.py +79 -0
  77. syncraft-0.3.1/tests/test_constraint.py +56 -0
  78. syncraft-0.3.1/tests/test_dev_syntax2svg.py +39 -0
  79. syncraft-0.3.1/tests/test_dfa_minimize_issue.py +133 -0
  80. syncraft-0.3.1/tests/test_fabuilder.py +63 -0
  81. {syncraft-0.1.37 → syncraft-0.3.1}/tests/test_find.py +21 -11
  82. syncraft-0.3.1/tests/test_generator_lr.py +101 -0
  83. syncraft-0.3.1/tests/test_graph.py +196 -0
  84. syncraft-0.3.1/tests/test_input.py +177 -0
  85. syncraft-0.3.1/tests/test_lazy.py +840 -0
  86. syncraft-0.3.1/tests/test_lazy_state_consistency.py +201 -0
  87. syncraft-0.3.1/tests/test_left_recursion_additional.py +109 -0
  88. syncraft-0.3.1/tests/test_lexer.py +152 -0
  89. syncraft-0.3.1/tests/test_nfa_dfa.py +390 -0
  90. syncraft-0.3.1/tests/test_parse.py +67 -0
  91. syncraft-0.3.1/tests/test_parser_input.py +114 -0
  92. syncraft-0.3.1/tests/test_regex.py +268 -0
  93. syncraft-0.3.1/tests/test_regex_parser.py +566 -0
  94. syncraft-0.3.1/tests/test_reverse_dfa.py +40 -0
  95. syncraft-0.3.1/tests/test_syntax_run.py +16 -0
  96. syncraft-0.3.1/tests/test_syntax_spec.py +136 -0
  97. {syncraft-0.1.37 → syncraft-0.3.1}/tests/test_to.py +23 -18
  98. syncraft-0.3.1/tests/test_token_spec.py +140 -0
  99. syncraft-0.3.1/tests/test_utils.py +41 -0
  100. syncraft-0.1.37/PKG-INFO +0 -34
  101. syncraft-0.1.37/README.md +0 -19
  102. syncraft-0.1.37/pyproject.toml +0 -23
  103. syncraft-0.1.37/syncraft/__init__.py +0 -0
  104. syncraft-0.1.37/syncraft/algebra.py +0 -377
  105. syncraft-0.1.37/syncraft/ast.py +0 -388
  106. syncraft-0.1.37/syncraft/constraint.py +0 -198
  107. syncraft-0.1.37/syncraft/diagnostic.py +0 -70
  108. syncraft-0.1.37/syncraft/finder.py +0 -58
  109. syncraft-0.1.37/syncraft/generator.py +0 -306
  110. syncraft-0.1.37/syncraft/parser.py +0 -262
  111. syncraft-0.1.37/syncraft/syntax.py +0 -365
  112. syncraft-0.1.37/syncraft.egg-info/PKG-INFO +0 -34
  113. syncraft-0.1.37/syncraft.egg-info/SOURCES.txt +0 -24
  114. syncraft-0.1.37/syncraft.egg-info/requires.txt +0 -3
  115. syncraft-0.1.37/tests/test_bimap.py +0 -267
  116. syncraft-0.1.37/tests/test_parse.py +0 -42
  117. syncraft-0.1.37/tests/test_until.py +0 -40
  118. {syncraft-0.1.37 → syncraft-0.3.1}/LICENSE +0 -0
  119. {syncraft-0.1.37 → syncraft-0.3.1}/setup.cfg +0 -0
  120. {syncraft-0.1.37 → syncraft-0.3.1}/syncraft/py.typed +0 -0
  121. {syncraft-0.1.37 → syncraft-0.3.1}/syncraft.egg-info/dependency_links.txt +0 -0
  122. {syncraft-0.1.37 → syncraft-0.3.1}/syncraft.egg-info/top_level.txt +0 -0
@@ -0,0 +1,60 @@
1
+ Metadata-Version: 2.4
2
+ Name: syncraft
3
+ Version: 0.3.1
4
+ Summary: Parser combinator library
5
+ Author-email: Michael Afmokt <michael@esacca.com>
6
+ License-Expression: MIT
7
+ Keywords: parser,combinator,sql,sqlite,generator,printer
8
+ Requires-Python: >=3.10
9
+ Description-Content-Type: text/markdown
10
+ License-File: LICENSE
11
+ Requires-Dist: rstr>=3.2.2
12
+ Requires-Dist: sqlglot>=27.14.0
13
+ Dynamic: license-file
14
+
15
+ # Syncraft
16
+
17
+ Syncraft is a parser/generator combinator library for Python. It helps you
18
+
19
+ - Build grammars
20
+ - Parse SQL statement to AST
21
+ - Search AST by grammar
22
+ - Convert AST to dataclass
23
+ - Check constraints over the AST/dataclass
24
+ - Change dataclass and convert back to AST
25
+
26
+
27
+ ## Installation
28
+
29
+ ### pip
30
+ ```bash
31
+ pip install syncraft
32
+ ```
33
+
34
+ ### uv
35
+ ```bash
36
+ uv add syncraft
37
+ ```
38
+
39
+ Python 3.10+ is required.
40
+
41
+ ### With pip
42
+ ```bash
43
+ pip install syncraft[dev]
44
+ ```
45
+
46
+ ### With uv
47
+ ```bash
48
+ uv sync --group dev
49
+ ```
50
+
51
+ TODO
52
+ - [ ] Static analysis tool based on Syntax.graph
53
+ - [ ] Profile hook on Cache
54
+ - [ ] try_parse based on Syntax.parallel
55
+ - [ ] regex.py convert Regex to FABuilder
56
+ - [ ] Visualization (railroad diagrams + AST).
57
+ - [ ] Interactive dev (Jupyter).
58
+ - [ ] Semantic layer (datalog + unification).
59
+
60
+
@@ -0,0 +1,46 @@
1
+ # Syncraft
2
+
3
+ Syncraft is a parser/generator combinator library for Python. It helps you
4
+
5
+ - Build grammars
6
+ - Parse SQL statement to AST
7
+ - Search AST by grammar
8
+ - Convert AST to dataclass
9
+ - Check constraints over the AST/dataclass
10
+ - Change dataclass and convert back to AST
11
+
12
+
13
+ ## Installation
14
+
15
+ ### pip
16
+ ```bash
17
+ pip install syncraft
18
+ ```
19
+
20
+ ### uv
21
+ ```bash
22
+ uv add syncraft
23
+ ```
24
+
25
+ Python 3.10+ is required.
26
+
27
+ ### With pip
28
+ ```bash
29
+ pip install syncraft[dev]
30
+ ```
31
+
32
+ ### With uv
33
+ ```bash
34
+ uv sync --group dev
35
+ ```
36
+
37
+ TODO
38
+ - [ ] Static analysis tool based on Syntax.graph
39
+ - [ ] Profile hook on Cache
40
+ - [ ] try_parse based on Syntax.parallel
41
+ - [ ] regex.py convert Regex to FABuilder
42
+ - [ ] Visualization (railroad diagrams + AST).
43
+ - [ ] Interactive dev (Jupyter).
44
+ - [ ] Semantic layer (datalog + unification).
45
+
46
+
@@ -0,0 +1,44 @@
1
+ [project]
2
+ name = "syncraft"
3
+ version = "0.3.1"
4
+ description = "Parser combinator library"
5
+ license = "MIT"
6
+ license-files = ["LICENSE"]
7
+ readme = "README.md"
8
+ authors = [{name = "Michael Afmokt", email = "michael@esacca.com"}]
9
+ keywords = ["parser", "combinator", "sql", "sqlite", "generator", 'printer']
10
+ requires-python = ">=3.10"
11
+ dependencies = [
12
+ "rstr>=3.2.2",
13
+ "sqlglot>=27.14.0",
14
+ ]
15
+
16
+
17
+ [dependency-groups]
18
+ dev = [
19
+ "pytest>=8.4.1",
20
+ "mkdocs>=1.6.0",
21
+ "mkdocs-material>=9.5.0",
22
+ "mkdocstrings>=0.25.0",
23
+ "mkdocstrings-python>=1.10.0",
24
+ "mkdocs-macros-plugin>=1.0.5",
25
+ "graphviz>=0.21",
26
+ "railroad-diagrams>=3.0.1",
27
+ "rich>=14.1.0",
28
+ "ipython>=8.0.0",
29
+ "jupyter>=1.0.0",
30
+ "mkdocs-jupyter>=0.24.6",
31
+ "nbval>=0.10.0",
32
+ "pytest-profiling>=1.8.1",
33
+ "snakeviz>=2.2.2",
34
+ "mypy>=1.18.2",
35
+ "regex>=2025.11.3",
36
+ "types-regex>=2025.11.3.20251106",
37
+ ]
38
+
39
+
40
+ [tool.setuptools]
41
+ packages = ["syncraft"]
42
+
43
+ [tool.setuptools.package-data]
44
+ syncraft = ["cache/**/*"]
@@ -0,0 +1,100 @@
1
+ from .syntax import (
2
+ Syntax,
3
+ SyntaxSpec,
4
+ Graph,
5
+ LazySpec,
6
+ ThenSpec,
7
+ ChoiceSpec,
8
+ )
9
+
10
+ from .algebra import (
11
+ Algebra,
12
+ Error,
13
+ Left,
14
+ Right,
15
+ Either,
16
+ )
17
+ from .parser import (
18
+ Parser,
19
+ parse,
20
+ ParserState,
21
+ parser,
22
+ parse_data,
23
+ parse_word,
24
+ )
25
+ from .generator import (
26
+ Generator,
27
+ generate,
28
+ generate_with,
29
+ validate,
30
+ )
31
+ from .finder import (
32
+ Finder,
33
+ find,
34
+ matches,
35
+ anything,
36
+ )
37
+ from .constraint import (
38
+ Constraint,
39
+ Quantifier,
40
+ forall,
41
+ exists,
42
+ )
43
+ from .ast import (
44
+ AST,
45
+ Bimap,
46
+ Biarrow,
47
+ Token,
48
+ Then,
49
+ ThenKind,
50
+ Choice,
51
+ ChoiceKind,
52
+ Many,
53
+ Marked,
54
+ Collect,
55
+ Nothing,
56
+ )
57
+ from .charset import CodeUniverse, CharSet
58
+ from .fa import FABuilder, DFA, NFA, DFARunner, NFARunner
59
+ from .lexer import ExtLexer, Lexer
60
+ from .utils import (
61
+ FrozenDict,
62
+ CallWith,
63
+ )
64
+ from .input import (
65
+ StreamCursor,
66
+ )
67
+ from .cache import Cache
68
+
69
+ # Export commonly used class methods for convenience
70
+ literal = Syntax.literal
71
+ choice = Syntax.choice
72
+
73
+ __all__ = [
74
+ # charset
75
+ "CodeUniverse", "CharSet",
76
+ # fa
77
+ "FABuilder", "DFA", "NFA", "DFARunner", "NFARunner",
78
+ # lexer
79
+ "ExtLexer", "Lexer",
80
+ # cache
81
+ "Cache",
82
+ # algebra
83
+ "Algebra", "Error", "Left", "Right", "Either",
84
+ # syntax & core
85
+ "Syntax", "SyntaxSpec", "Graph", "LazySpec", "ThenSpec", "ChoiceSpec",
86
+ # parsing/generation helpers
87
+ "parse", "parser", "parse_data", "parse_word", "ParserState",
88
+ "generate", "generate_with", "validate", "Parser", "Generator",
89
+ # finder
90
+ "find", "matches", "anything", "Finder",
91
+ # constraints
92
+ "Constraint", "Quantifier", "forall", "exists", "FrozenDict", "CallWith",
93
+ # ast
94
+ "AST", "Token", "Then", "ThenKind", "Choice", "ChoiceKind", "Many", "Marked", "Collect", "Bimap", "Biarrow", "Nothing",
95
+ # input
96
+ "StreamCursor",
97
+ # convenience exports
98
+ "literal",
99
+ "choice",
100
+ ]