zirium 0.0.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 (36) hide show
  1. zirium-0.0.1/Cargo.lock +177 -0
  2. zirium-0.0.1/Cargo.toml +9 -0
  3. zirium-0.0.1/LICENSE-APACHE +201 -0
  4. zirium-0.0.1/LICENSE-MIT +21 -0
  5. zirium-0.0.1/PKG-INFO +164 -0
  6. zirium-0.0.1/README.md +140 -0
  7. zirium-0.0.1/crates/zirium/Cargo.toml +15 -0
  8. zirium-0.0.1/crates/zirium/README.md +140 -0
  9. zirium-0.0.1/crates/zirium/examples/indexing_editing_benchmark.rs +91 -0
  10. zirium-0.0.1/crates/zirium/examples/large_data_retention_benchmark.rs +154 -0
  11. zirium-0.0.1/crates/zirium/examples/processing_benchmark.rs +953 -0
  12. zirium-0.0.1/crates/zirium/examples/representation_benchmark.rs +296 -0
  13. zirium-0.0.1/crates/zirium/src/dialect.rs +1157 -0
  14. zirium-0.0.1/crates/zirium/src/lexer.rs +497 -0
  15. zirium-0.0.1/crates/zirium/src/lib.rs +55 -0
  16. zirium-0.0.1/crates/zirium/src/parser/parser_construction_benchmark.rs +317 -0
  17. zirium-0.0.1/crates/zirium/src/parser.rs +3117 -0
  18. zirium-0.0.1/crates/zirium/src/printer.rs +1899 -0
  19. zirium-0.0.1/crates/zirium/src/representation.rs +644 -0
  20. zirium-0.0.1/crates/zirium/src/semantic.rs +7243 -0
  21. zirium-0.0.1/crates/zirium/src/source.rs +124 -0
  22. zirium-0.0.1/crates/zirium/tests/dialect.rs +1288 -0
  23. zirium-0.0.1/crates/zirium/tests/editing.rs +1357 -0
  24. zirium-0.0.1/crates/zirium/tests/errors.rs +70 -0
  25. zirium-0.0.1/crates/zirium/tests/lexer.rs +167 -0
  26. zirium-0.0.1/crates/zirium/tests/parser.rs +837 -0
  27. zirium-0.0.1/crates/zirium/tests/printer.rs +161 -0
  28. zirium-0.0.1/crates/zirium/tests/representation.rs +75 -0
  29. zirium-0.0.1/crates/zirium/tests/semantic.rs +1231 -0
  30. zirium-0.0.1/crates/zirium-python/Cargo.toml +19 -0
  31. zirium-0.0.1/crates/zirium-python/README.md +140 -0
  32. zirium-0.0.1/crates/zirium-python/src/lib.rs +2460 -0
  33. zirium-0.0.1/pyproject.toml +44 -0
  34. zirium-0.0.1/python/zirium/__init__.py +69 -0
  35. zirium-0.0.1/python/zirium/__init__.pyi +420 -0
  36. zirium-0.0.1/python/zirium/py.typed +1 -0
@@ -0,0 +1,177 @@
1
+ # This file is automatically @generated by Cargo.
2
+ # It is not intended for manual editing.
3
+ version = 4
4
+
5
+ [[package]]
6
+ name = "autocfg"
7
+ version = "1.5.1"
8
+ source = "registry+https://github.com/rust-lang/crates.io-index"
9
+ checksum = "f2032f911046de80f0a198e0901378627c33f59ea0ac00e363d481118bd70a53"
10
+
11
+ [[package]]
12
+ name = "heck"
13
+ version = "0.5.0"
14
+ source = "registry+https://github.com/rust-lang/crates.io-index"
15
+ checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
16
+
17
+ [[package]]
18
+ name = "indoc"
19
+ version = "2.0.7"
20
+ source = "registry+https://github.com/rust-lang/crates.io-index"
21
+ checksum = "79cf5c93f93228cf8efb3ba362535fb11199ac548a09ce117c9b1adc3030d706"
22
+ dependencies = [
23
+ "rustversion",
24
+ ]
25
+
26
+ [[package]]
27
+ name = "libc"
28
+ version = "0.2.189"
29
+ source = "registry+https://github.com/rust-lang/crates.io-index"
30
+ checksum = "3eaf3ede3fee6db1a4c2ee091bf8a8b4dccdc6d17f656fb07896ee72867612f2"
31
+
32
+ [[package]]
33
+ name = "memoffset"
34
+ version = "0.9.1"
35
+ source = "registry+https://github.com/rust-lang/crates.io-index"
36
+ checksum = "488016bfae457b036d996092f6cb448677611ce4449e970ceaf42695203f218a"
37
+ dependencies = [
38
+ "autocfg",
39
+ ]
40
+
41
+ [[package]]
42
+ name = "once_cell"
43
+ version = "1.21.4"
44
+ source = "registry+https://github.com/rust-lang/crates.io-index"
45
+ checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
46
+
47
+ [[package]]
48
+ name = "portable-atomic"
49
+ version = "1.15.0"
50
+ source = "registry+https://github.com/rust-lang/crates.io-index"
51
+ checksum = "05c8b63e8d9609db387f0324918f81d68fe27748f084ef092fb35954d0539a85"
52
+
53
+ [[package]]
54
+ name = "proc-macro2"
55
+ version = "1.0.107"
56
+ source = "registry+https://github.com/rust-lang/crates.io-index"
57
+ checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9"
58
+ dependencies = [
59
+ "unicode-ident",
60
+ ]
61
+
62
+ [[package]]
63
+ name = "pyo3"
64
+ version = "0.27.2"
65
+ source = "registry+https://github.com/rust-lang/crates.io-index"
66
+ checksum = "ab53c047fcd1a1d2a8820fe84f05d6be69e9526be40cb03b73f86b6b03e6d87d"
67
+ dependencies = [
68
+ "indoc",
69
+ "libc",
70
+ "memoffset",
71
+ "once_cell",
72
+ "portable-atomic",
73
+ "pyo3-build-config",
74
+ "pyo3-ffi",
75
+ "pyo3-macros",
76
+ "unindent",
77
+ ]
78
+
79
+ [[package]]
80
+ name = "pyo3-build-config"
81
+ version = "0.27.2"
82
+ source = "registry+https://github.com/rust-lang/crates.io-index"
83
+ checksum = "b455933107de8642b4487ed26d912c2d899dec6114884214a0b3bb3be9261ea6"
84
+ dependencies = [
85
+ "target-lexicon",
86
+ ]
87
+
88
+ [[package]]
89
+ name = "pyo3-ffi"
90
+ version = "0.27.2"
91
+ source = "registry+https://github.com/rust-lang/crates.io-index"
92
+ checksum = "1c85c9cbfaddf651b1221594209aed57e9e5cff63c4d11d1feead529b872a089"
93
+ dependencies = [
94
+ "libc",
95
+ "pyo3-build-config",
96
+ ]
97
+
98
+ [[package]]
99
+ name = "pyo3-macros"
100
+ version = "0.27.2"
101
+ source = "registry+https://github.com/rust-lang/crates.io-index"
102
+ checksum = "0a5b10c9bf9888125d917fb4d2ca2d25c8df94c7ab5a52e13313a07e050a3b02"
103
+ dependencies = [
104
+ "proc-macro2",
105
+ "pyo3-macros-backend",
106
+ "quote",
107
+ "syn",
108
+ ]
109
+
110
+ [[package]]
111
+ name = "pyo3-macros-backend"
112
+ version = "0.27.2"
113
+ source = "registry+https://github.com/rust-lang/crates.io-index"
114
+ checksum = "03b51720d314836e53327f5871d4c0cfb4fb37cc2c4a11cc71907a86342c40f9"
115
+ dependencies = [
116
+ "heck",
117
+ "proc-macro2",
118
+ "pyo3-build-config",
119
+ "quote",
120
+ "syn",
121
+ ]
122
+
123
+ [[package]]
124
+ name = "quote"
125
+ version = "1.0.47"
126
+ source = "registry+https://github.com/rust-lang/crates.io-index"
127
+ checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001"
128
+ dependencies = [
129
+ "proc-macro2",
130
+ ]
131
+
132
+ [[package]]
133
+ name = "rustversion"
134
+ version = "1.0.23"
135
+ source = "registry+https://github.com/rust-lang/crates.io-index"
136
+ checksum = "cf54715a573b99ac80df0bc206da022bcd442c974952c7b9720069370852e21f"
137
+
138
+ [[package]]
139
+ name = "syn"
140
+ version = "2.0.119"
141
+ source = "registry+https://github.com/rust-lang/crates.io-index"
142
+ checksum = "872831b642d1a07999a962a351ed35b955ea2cfc8f3862091e2a240a84f17297"
143
+ dependencies = [
144
+ "proc-macro2",
145
+ "quote",
146
+ "unicode-ident",
147
+ ]
148
+
149
+ [[package]]
150
+ name = "target-lexicon"
151
+ version = "0.13.5"
152
+ source = "registry+https://github.com/rust-lang/crates.io-index"
153
+ checksum = "adb6935a6f5c20170eeceb1a3835a49e12e19d792f6dd344ccc76a985ca5a6ca"
154
+
155
+ [[package]]
156
+ name = "unicode-ident"
157
+ version = "1.0.24"
158
+ source = "registry+https://github.com/rust-lang/crates.io-index"
159
+ checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75"
160
+
161
+ [[package]]
162
+ name = "unindent"
163
+ version = "0.2.4"
164
+ source = "registry+https://github.com/rust-lang/crates.io-index"
165
+ checksum = "7264e107f553ccae879d21fbea1d6724ac785e8c3bfc762137959b5802826ef3"
166
+
167
+ [[package]]
168
+ name = "zirium"
169
+ version = "0.0.1"
170
+
171
+ [[package]]
172
+ name = "zirium-python"
173
+ version = "0.0.1"
174
+ dependencies = [
175
+ "pyo3",
176
+ "zirium",
177
+ ]
@@ -0,0 +1,9 @@
1
+ [workspace]
2
+ members = ["crates/zirium", "crates/zirium-python"]
3
+ exclude = ["fuzz"]
4
+ resolver = "2"
5
+
6
+ [workspace.package]
7
+ edition = "2024"
8
+ rust-version = "1.85"
9
+ license = "MIT OR Apache-2.0"
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Zayenz
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the `Software`), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED `AS IS`, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
zirium-0.0.1/PKG-INFO ADDED
@@ -0,0 +1,164 @@
1
+ Metadata-Version: 2.4
2
+ Name: zirium
3
+ Version: 0.0.1
4
+ Classifier: Programming Language :: Python :: 3
5
+ Classifier: Programming Language :: Python :: 3.11
6
+ Classifier: Programming Language :: Python :: 3.12
7
+ Classifier: Programming Language :: Python :: 3.13
8
+ Classifier: Programming Language :: Python :: 3.14
9
+ Classifier: Programming Language :: Python :: Implementation :: CPython
10
+ Classifier: Typing :: Typed
11
+ License-File: LICENSE-MIT
12
+ License-File: LICENSE-APACHE
13
+ Summary: Lossless textual MLIR parsing and semantic processing
14
+ Home-Page: https://github.com/zayenz/zirium
15
+ Author: Zayenz
16
+ License-Expression: MIT OR Apache-2.0
17
+ Requires-Python: >=3.11, <3.15
18
+ Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
19
+ Project-URL: Documentation, https://github.com/zayenz/zirium/blob/main/docs/getting-started.md
20
+ Project-URL: Homepage, https://github.com/zayenz/zirium
21
+ Project-URL: Issues, https://github.com/zayenz/zirium/issues
22
+ Project-URL: Repository, https://github.com/zayenz/zirium
23
+
24
+ # Zirium
25
+
26
+ Zirium 0.0.1 is an experimental release. The API may change without a
27
+ migration path.
28
+
29
+ Zirium is a Rust library for reading, inspecting, transforming, and writing textual MLIR. It also provides typed Python bindings. The parser keeps the original bytes, including comments, whitespace, malformed syntax, and invalid UTF-8. A separate semantic layer provides a compact representation for verification and editing.
30
+
31
+ The project is useful when a tool needs to understand MLIR without linking LLVM, and when source fidelity matters alongside semantic processing.
32
+
33
+ Zirium currently targets the textual syntax of MLIR 22.1. It has a
34
+ deliberately narrow dialect surface and is not a replacement for all of MLIR's
35
+ parser or ODS infrastructure.
36
+
37
+ The current release is intended for experimentation, tooling prototypes, and
38
+ evaluation of the lossless syntax/semantic split. It does not promise broad
39
+ dialect coverage, bytecode support, ODS/TableGen loading, or a stable API.
40
+
41
+ ## What it provides
42
+
43
+ - A byte-oriented lexer and lossless concrete syntax tree (CST).
44
+ - Recovery from malformed input with ranged diagnostics and useful outer structure.
45
+ - Strict and best-effort lowering into a separate semantic document.
46
+ - Operations, regions, blocks, SSA values, types, attributes, locations, symbols, and dominance queries.
47
+ - Deterministic generic MLIR output and structural round-trip comparison.
48
+ - Buffered semantic edits that commit atomically.
49
+ - Conservative source-preserving output for documents lowered with hybrid retention.
50
+ - Rust and Python APIs over the same core implementation.
51
+ - Explicit limits for file size, token count, nesting, and large payloads.
52
+
53
+ ## A small example
54
+
55
+ ```python
56
+ import zirium
57
+
58
+ source = '''\
59
+ "builtin.module"() ({
60
+ %value = "example.make"() : () -> i32
61
+ "example.consume"(%value) : (i32) -> ()
62
+ }) : () -> ()
63
+ '''
64
+
65
+ parsed = zirium.parse_text(source)
66
+ assert parsed.original_bytes() == source.encode()
67
+
68
+ lowered = parsed.lower_strict("semantic")
69
+ if lowered.document is None:
70
+ for diagnostic in lowered.diagnostics:
71
+ print(diagnostic.range, diagnostic.message)
72
+ raise SystemExit(1)
73
+
74
+ document = lowered.document
75
+ document.validate_structure()
76
+ table = document.operation_table()
77
+ print([table.operation(index).name for index in range(table.count)])
78
+ print(document.canonical_bytes().decode(), end="")
79
+ ```
80
+
81
+ Parsing and lowering are separate on purpose. A `File` owns the original bytes, tokens, CST, and syntax diagnostics. A `Document` owns resolved semantic data. This keeps malformed-source tooling from depending on a partly valid semantic model, while transformation code does not have to operate on syntax nodes.
82
+
83
+ ## Getting started
84
+
85
+ Zirium requires Rust 1.85 or newer. The Python package supports conventional
86
+ CPython 3.11 through 3.14. Release artifacts are currently proven only for
87
+ Linux x86_64 by CI; other platforms require a local source build with maturin
88
+ and are not part of the platform promise.
89
+
90
+ The [getting-started guide](https://github.com/zayenz/zirium/blob/main/docs/getting-started.md) covers:
91
+
92
+ - building and testing the Rust workspace;
93
+ - installing the Python extension into a virtual environment;
94
+ - parsing, lowering, verifying, and writing MLIR;
95
+ - choosing a retention profile and output mode.
96
+
97
+ For the shortest check from a fresh checkout:
98
+
99
+ ```sh
100
+ cargo test --workspace
101
+ ```
102
+
103
+ Install a published Python wheel with:
104
+
105
+ ~~~sh
106
+ python -m pip install zirium
107
+ ~~~
108
+
109
+ If a wheel is not available yet, build the extension locally using the
110
+ [getting-started guide](https://github.com/zayenz/zirium/blob/main/docs/getting-started.md).
111
+
112
+ ## Output modes
113
+
114
+ Zirium has three output paths, each with a different contract:
115
+
116
+ | Output | Source object | Contract |
117
+ | --- | --- | --- |
118
+ | Original | Parsed file | Reproduces the input bytes exactly. |
119
+ | Canonical | Semantic document | Emits deterministic generic MLIR from semantic storage. |
120
+ | Preserving | Hybrid semantic document | Copies unchanged source and regenerates edited operations or blocks. |
121
+
122
+ Canonical output intentionally does not preserve comments, whitespace, aliases, or SSA spelling. Use original output when no semantic edit is needed, and hybrid retention when edits should leave unrelated source text alone.
123
+
124
+ ## Dialect support
125
+
126
+ Generic quoted operations are handled without a dialect registry. Unknown dialect types and attributes keep their balanced bodies as opaque values.
127
+
128
+ Registered custom syntax is currently a proving surface rather than broad MLIR dialect coverage. The built-in proving registry covers a fixed subset of Builtin, Func, Arith, and CF operations. A declarative registry can select from that same fixed set. Zirium does not load LLVM dialect definitions, interpret arbitrary ODS/TableGen files, or run Python callbacks while parsing.
129
+
130
+ See [compatibility and local wheel checks](https://github.com/zayenz/zirium/blob/main/docs/compatibility.md) for the exact toolchain and CPython matrix. The [corpus notes](https://github.com/zayenz/zirium/blob/main/tests/corpus/mlir-22.1/README.md) explain how syntax compatibility is tied to `llvmorg-22.1.0`.
131
+
132
+ ## Repository layout
133
+
134
+ ```text
135
+ crates/zirium/ Core Rust library
136
+ crates/zirium-python/ PyO3 extension module
137
+ python/zirium/ Python package and type declarations
138
+ python/tests/ Python API tests
139
+ tests/corpus/ Versioned MLIR compatibility corpus
140
+ docs/ Usage, compatibility, and architecture notes
141
+ fuzz/ Lexer and parser fuzz targets
142
+ ```
143
+
144
+ The architecture notes include the [syntax representation baseline](https://github.com/zayenz/zirium/blob/main/docs/architecture/representation-baseline.md) and [processing benchmarks](https://github.com/zayenz/zirium/blob/main/docs/architecture/processing-benchmarks.md).
145
+
146
+ ## Development checks
147
+
148
+ The complete local quality gate, including the supported Rust and Python
149
+ versions, is documented in the [compatibility guide](https://github.com/zayenz/zirium/blob/main/docs/compatibility.md).
150
+ The CI workflow runs those same commands.
151
+
152
+ Python development details are documented in [the getting-started guide](https://github.com/zayenz/zirium/blob/main/docs/getting-started.md).
153
+ The [release guide](https://github.com/zayenz/zirium/blob/main/docs/releasing.md)
154
+ records the registry setup, package checks, and publication order.
155
+
156
+ ## License
157
+
158
+ Zirium's original code is available under the [MIT](https://github.com/zayenz/zirium/blob/main/LICENSE-MIT) or
159
+ [Apache 2.0](https://github.com/zayenz/zirium/blob/main/LICENSE-APACHE) license. Some MLIR-derived or adapted test
160
+ material retains the provenance and licensing information recorded in the
161
+ [corpus manifest](https://github.com/zayenz/zirium/blob/main/tests/corpus/mlir-22.1/manifest.toml).
162
+
163
+ Release notes are recorded in the [changelog](https://github.com/zayenz/zirium/blob/main/CHANGELOG.md).
164
+