lark-rust 0.1.0__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.
@@ -0,0 +1,43 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main, feature/*]
6
+ pull_request:
7
+ branches: [main]
8
+
9
+ jobs:
10
+ test:
11
+ runs-on: ${{ matrix.os }}
12
+ strategy:
13
+ fail-fast: false
14
+ matrix:
15
+ os: [ubuntu-latest, macos-latest, windows-latest]
16
+ python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
17
+ steps:
18
+ - uses: actions/checkout@v4
19
+ - uses: actions/setup-python@v5
20
+ with:
21
+ python-version: ${{ matrix.python-version }}
22
+ - name: Install Rust
23
+ uses: dtolnay/rust-toolchain@stable
24
+ - name: Build and install
25
+ run: |
26
+ pip install maturin lark pytest
27
+ maturin build --release
28
+ pip install --find-links target/wheels lark-rust
29
+ - name: Run tests
30
+ run: pytest tests/ -v
31
+
32
+ lint:
33
+ runs-on: ubuntu-latest
34
+ steps:
35
+ - uses: actions/checkout@v4
36
+ - name: Install Rust
37
+ uses: dtolnay/rust-toolchain@stable
38
+ with:
39
+ components: clippy, rustfmt
40
+ - name: Cargo clippy
41
+ run: cargo clippy --all-targets -- -D warnings
42
+ - name: Cargo fmt check
43
+ run: cargo fmt --check
@@ -0,0 +1,76 @@
1
+ name: Release
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - "v*"
7
+
8
+ permissions:
9
+ contents: read
10
+
11
+ jobs:
12
+ build-sdist:
13
+ runs-on: ubuntu-latest
14
+ steps:
15
+ - uses: actions/checkout@v4
16
+ - name: Build sdist
17
+ uses: PyO3/maturin-action@v1
18
+ with:
19
+ command: sdist
20
+ args: --out dist
21
+ - uses: actions/upload-artifact@v4
22
+ with:
23
+ name: sdist
24
+ path: dist/*.tar.gz
25
+
26
+ build-wheels:
27
+ runs-on: ${{ matrix.os }}
28
+ strategy:
29
+ fail-fast: false
30
+ matrix:
31
+ include:
32
+ # Linux x86_64
33
+ - os: ubuntu-latest
34
+ target: x86_64
35
+ # Linux aarch64
36
+ - os: ubuntu-latest
37
+ target: aarch64
38
+ # macOS universal2 (x86_64 + arm64 fat binary)
39
+ - os: macos-latest
40
+ target: universal2-apple-darwin
41
+ # Windows x86_64
42
+ - os: windows-latest
43
+ target: x64
44
+ steps:
45
+ - uses: actions/checkout@v4
46
+ - uses: actions/setup-python@v5
47
+ with:
48
+ python-version: "3.x"
49
+ - name: Build wheels
50
+ uses: PyO3/maturin-action@v1
51
+ with:
52
+ target: ${{ matrix.target }}
53
+ args: --release --out dist --find-interpreter
54
+ sccache: "true"
55
+ manylinux: auto
56
+ - uses: actions/upload-artifact@v4
57
+ with:
58
+ name: wheels-${{ matrix.os }}-${{ matrix.target }}
59
+ path: dist/*.whl
60
+
61
+ publish:
62
+ needs: [build-sdist, build-wheels]
63
+ runs-on: ubuntu-latest
64
+ environment: pypi
65
+ permissions:
66
+ id-token: write
67
+ steps:
68
+ - uses: actions/download-artifact@v4
69
+ with:
70
+ path: dist
71
+ merge-multiple: true
72
+ - name: Publish to PyPI
73
+ uses: PyO3/maturin-action@v1
74
+ with:
75
+ command: upload
76
+ args: --non-interactive --skip-existing dist/*
@@ -0,0 +1,25 @@
1
+ # Rust
2
+ /target
3
+ Cargo.lock
4
+
5
+ # Python
6
+ __pycache__/
7
+ *.pyc
8
+ *.pyo
9
+ *.egg-info/
10
+ dist/
11
+ .venv/
12
+ .pytest_cache/
13
+
14
+ # Build artifacts
15
+ *.so
16
+ *.dylib
17
+ *.dSYM/
18
+ *.dll
19
+ *.pyd
20
+
21
+ # IDE
22
+ .idea/
23
+ .vscode/
24
+ *.swp
25
+ *.swo
@@ -0,0 +1,232 @@
1
+ # This file is automatically @generated by Cargo.
2
+ # It is not intended for manual editing.
3
+ version = 4
4
+
5
+ [[package]]
6
+ name = "aho-corasick"
7
+ version = "1.1.4"
8
+ source = "registry+https://github.com/rust-lang/crates.io-index"
9
+ checksum = "ddd31a130427c27518df266943a5308ed92d4b226cc639f5a8f1002816174301"
10
+ dependencies = [
11
+ "memchr",
12
+ ]
13
+
14
+ [[package]]
15
+ name = "autocfg"
16
+ version = "1.5.0"
17
+ source = "registry+https://github.com/rust-lang/crates.io-index"
18
+ checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8"
19
+
20
+ [[package]]
21
+ name = "bit-set"
22
+ version = "0.8.0"
23
+ source = "registry+https://github.com/rust-lang/crates.io-index"
24
+ checksum = "08807e080ed7f9d5433fa9b275196cfc35414f66a0c79d864dc51a0d825231a3"
25
+ dependencies = [
26
+ "bit-vec",
27
+ ]
28
+
29
+ [[package]]
30
+ name = "bit-vec"
31
+ version = "0.8.0"
32
+ source = "registry+https://github.com/rust-lang/crates.io-index"
33
+ checksum = "5e764a1d40d510daf35e07be9eb06e75770908c27d411ee6c92109c9840eaaf7"
34
+
35
+ [[package]]
36
+ name = "fancy-regex"
37
+ version = "0.14.0"
38
+ source = "registry+https://github.com/rust-lang/crates.io-index"
39
+ checksum = "6e24cb5a94bcae1e5408b0effca5cd7172ea3c5755049c5f3af4cd283a165298"
40
+ dependencies = [
41
+ "bit-set",
42
+ "regex-automata",
43
+ "regex-syntax",
44
+ ]
45
+
46
+ [[package]]
47
+ name = "heck"
48
+ version = "0.5.0"
49
+ source = "registry+https://github.com/rust-lang/crates.io-index"
50
+ checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
51
+
52
+ [[package]]
53
+ name = "indoc"
54
+ version = "2.0.7"
55
+ source = "registry+https://github.com/rust-lang/crates.io-index"
56
+ checksum = "79cf5c93f93228cf8efb3ba362535fb11199ac548a09ce117c9b1adc3030d706"
57
+ dependencies = [
58
+ "rustversion",
59
+ ]
60
+
61
+ [[package]]
62
+ name = "lark-rust"
63
+ version = "0.1.0"
64
+ dependencies = [
65
+ "fancy-regex",
66
+ "pyo3",
67
+ ]
68
+
69
+ [[package]]
70
+ name = "libc"
71
+ version = "0.2.183"
72
+ source = "registry+https://github.com/rust-lang/crates.io-index"
73
+ checksum = "b5b646652bf6661599e1da8901b3b9522896f01e736bad5f723fe7a3a27f899d"
74
+
75
+ [[package]]
76
+ name = "memchr"
77
+ version = "2.8.0"
78
+ source = "registry+https://github.com/rust-lang/crates.io-index"
79
+ checksum = "f8ca58f447f06ed17d5fc4043ce1b10dd205e060fb3ce5b979b8ed8e59ff3f79"
80
+
81
+ [[package]]
82
+ name = "memoffset"
83
+ version = "0.9.1"
84
+ source = "registry+https://github.com/rust-lang/crates.io-index"
85
+ checksum = "488016bfae457b036d996092f6cb448677611ce4449e970ceaf42695203f218a"
86
+ dependencies = [
87
+ "autocfg",
88
+ ]
89
+
90
+ [[package]]
91
+ name = "once_cell"
92
+ version = "1.21.4"
93
+ source = "registry+https://github.com/rust-lang/crates.io-index"
94
+ checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
95
+
96
+ [[package]]
97
+ name = "portable-atomic"
98
+ version = "1.13.1"
99
+ source = "registry+https://github.com/rust-lang/crates.io-index"
100
+ checksum = "c33a9471896f1c69cecef8d20cbe2f7accd12527ce60845ff44c153bb2a21b49"
101
+
102
+ [[package]]
103
+ name = "proc-macro2"
104
+ version = "1.0.106"
105
+ source = "registry+https://github.com/rust-lang/crates.io-index"
106
+ checksum = "8fd00f0bb2e90d81d1044c2b32617f68fcb9fa3bb7640c23e9c748e53fb30934"
107
+ dependencies = [
108
+ "unicode-ident",
109
+ ]
110
+
111
+ [[package]]
112
+ name = "pyo3"
113
+ version = "0.25.1"
114
+ source = "registry+https://github.com/rust-lang/crates.io-index"
115
+ checksum = "8970a78afe0628a3e3430376fc5fd76b6b45c4d43360ffd6cdd40bdde72b682a"
116
+ dependencies = [
117
+ "indoc",
118
+ "libc",
119
+ "memoffset",
120
+ "once_cell",
121
+ "portable-atomic",
122
+ "pyo3-build-config",
123
+ "pyo3-ffi",
124
+ "pyo3-macros",
125
+ "unindent",
126
+ ]
127
+
128
+ [[package]]
129
+ name = "pyo3-build-config"
130
+ version = "0.25.1"
131
+ source = "registry+https://github.com/rust-lang/crates.io-index"
132
+ checksum = "458eb0c55e7ece017adeba38f2248ff3ac615e53660d7c71a238d7d2a01c7598"
133
+ dependencies = [
134
+ "once_cell",
135
+ "target-lexicon",
136
+ ]
137
+
138
+ [[package]]
139
+ name = "pyo3-ffi"
140
+ version = "0.25.1"
141
+ source = "registry+https://github.com/rust-lang/crates.io-index"
142
+ checksum = "7114fe5457c61b276ab77c5055f206295b812608083644a5c5b2640c3102565c"
143
+ dependencies = [
144
+ "libc",
145
+ "pyo3-build-config",
146
+ ]
147
+
148
+ [[package]]
149
+ name = "pyo3-macros"
150
+ version = "0.25.1"
151
+ source = "registry+https://github.com/rust-lang/crates.io-index"
152
+ checksum = "a8725c0a622b374d6cb051d11a0983786448f7785336139c3c94f5aa6bef7e50"
153
+ dependencies = [
154
+ "proc-macro2",
155
+ "pyo3-macros-backend",
156
+ "quote",
157
+ "syn",
158
+ ]
159
+
160
+ [[package]]
161
+ name = "pyo3-macros-backend"
162
+ version = "0.25.1"
163
+ source = "registry+https://github.com/rust-lang/crates.io-index"
164
+ checksum = "4109984c22491085343c05b0dbc54ddc405c3cf7b4374fc533f5c3313a572ccc"
165
+ dependencies = [
166
+ "heck",
167
+ "proc-macro2",
168
+ "pyo3-build-config",
169
+ "quote",
170
+ "syn",
171
+ ]
172
+
173
+ [[package]]
174
+ name = "quote"
175
+ version = "1.0.45"
176
+ source = "registry+https://github.com/rust-lang/crates.io-index"
177
+ checksum = "41f2619966050689382d2b44f664f4bc593e129785a36d6ee376ddf37259b924"
178
+ dependencies = [
179
+ "proc-macro2",
180
+ ]
181
+
182
+ [[package]]
183
+ name = "regex-automata"
184
+ version = "0.4.14"
185
+ source = "registry+https://github.com/rust-lang/crates.io-index"
186
+ checksum = "6e1dd4122fc1595e8162618945476892eefca7b88c52820e74af6262213cae8f"
187
+ dependencies = [
188
+ "aho-corasick",
189
+ "memchr",
190
+ "regex-syntax",
191
+ ]
192
+
193
+ [[package]]
194
+ name = "regex-syntax"
195
+ version = "0.8.10"
196
+ source = "registry+https://github.com/rust-lang/crates.io-index"
197
+ checksum = "dc897dd8d9e8bd1ed8cdad82b5966c3e0ecae09fb1907d58efaa013543185d0a"
198
+
199
+ [[package]]
200
+ name = "rustversion"
201
+ version = "1.0.22"
202
+ source = "registry+https://github.com/rust-lang/crates.io-index"
203
+ checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d"
204
+
205
+ [[package]]
206
+ name = "syn"
207
+ version = "2.0.117"
208
+ source = "registry+https://github.com/rust-lang/crates.io-index"
209
+ checksum = "e665b8803e7b1d2a727f4023456bbbbe74da67099c585258af0ad9c5013b9b99"
210
+ dependencies = [
211
+ "proc-macro2",
212
+ "quote",
213
+ "unicode-ident",
214
+ ]
215
+
216
+ [[package]]
217
+ name = "target-lexicon"
218
+ version = "0.13.5"
219
+ source = "registry+https://github.com/rust-lang/crates.io-index"
220
+ checksum = "adb6935a6f5c20170eeceb1a3835a49e12e19d792f6dd344ccc76a985ca5a6ca"
221
+
222
+ [[package]]
223
+ name = "unicode-ident"
224
+ version = "1.0.24"
225
+ source = "registry+https://github.com/rust-lang/crates.io-index"
226
+ checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75"
227
+
228
+ [[package]]
229
+ name = "unindent"
230
+ version = "0.2.4"
231
+ source = "registry+https://github.com/rust-lang/crates.io-index"
232
+ checksum = "7264e107f553ccae879d21fbea1d6724ac785e8c3bfc762137959b5802826ef3"
@@ -0,0 +1,19 @@
1
+ [package]
2
+ name = "lark-rust"
3
+ version = "0.1.0"
4
+ edition = "2021"
5
+ readme = "README.md"
6
+
7
+ [lib]
8
+ name = "lark_rust"
9
+ crate-type = ["cdylib"]
10
+
11
+ [dependencies]
12
+ pyo3 = { version = "0.25", features = ["extension-module"] }
13
+ fancy-regex = "0.14"
14
+
15
+ [profile.release]
16
+ lto = true
17
+ codegen-units = 1
18
+ opt-level = 3
19
+ strip = true
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Robert Ozimek
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.
@@ -0,0 +1,84 @@
1
+ Metadata-Version: 2.4
2
+ Name: lark-rust
3
+ Version: 0.1.0
4
+ Classifier: Development Status :: 4 - Beta
5
+ Classifier: Intended Audience :: Developers
6
+ Classifier: License :: OSI Approved :: MIT License
7
+ Classifier: Programming Language :: Rust
8
+ Classifier: Programming Language :: Python :: Implementation :: CPython
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: Programming Language :: Python :: 3.8
11
+ Classifier: Programming Language :: Python :: 3.9
12
+ Classifier: Programming Language :: Python :: 3.10
13
+ Classifier: Programming Language :: Python :: 3.11
14
+ Classifier: Programming Language :: Python :: 3.12
15
+ Classifier: Programming Language :: Python :: 3.13
16
+ Classifier: Programming Language :: Python :: 3.14
17
+ Classifier: Topic :: Software Development :: Compilers
18
+ Classifier: Topic :: Text Processing :: General
19
+ Requires-Dist: lark>=1.0
20
+ License-File: LICENSE
21
+ Summary: High-performance Rust-accelerated drop-in replacement for lark's LALR parser stack
22
+ Keywords: lark,parser,lalr,rust,performance
23
+ Author-email: Robert Ozimek <robertozimek@users.noreply.github.com>
24
+ License-Expression: MIT
25
+ Requires-Python: >=3.8
26
+ Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
27
+ Project-URL: Homepage, https://github.com/robertozimek/lark-rust
28
+ Project-URL: Issues, https://github.com/robertozimek/lark-rust/issues
29
+ Project-URL: Repository, https://github.com/robertozimek/lark-rust
30
+
31
+ # lark-rust
32
+
33
+ High-performance Rust-accelerated drop-in replacement for [lark](https://github.com/lark-parser/lark)'s LALR parser stack. A faster alternative to [lark-cython](https://github.com/lark-parser/lark_cython).
34
+
35
+ ## Installation
36
+
37
+ ```bash
38
+ pip install lark-rust
39
+ ```
40
+
41
+ ## Usage
42
+
43
+ ```python
44
+ from lark import Lark
45
+ import lark_rust
46
+
47
+ parser = Lark(grammar, parser='lalr', _plugins=lark_rust.plugins)
48
+ result = parser.parse(text)
49
+ ```
50
+
51
+ That's it — same lark API, just faster.
52
+
53
+ ## What's accelerated
54
+
55
+ The Rust native extension accelerates the hot-path components:
56
+
57
+ - **Token** — creation, hashing, equality comparison
58
+ - **Scanner** — regex matching via `fancy-regex`
59
+ - **BasicLexer** — token loop with single-pass newline counting
60
+ - **LineCounter** — position tracking
61
+ - **LexerState** — lexer state management
62
+
63
+ The parser, tree builder, and tree traversal are implemented in Python with full lark compatibility:
64
+
65
+ - **ContextualLexer**, **LALR_Parser** (with serialize/deserialize/on_error)
66
+ - **ParseTreeBuilder** with ExpandSingleChild, PropagatePositions, ChildFilter
67
+ - **Tree** with iter_subtrees, find_data, scan_values, pretty printing
68
+
69
+ ## lark-cython compatibility
70
+
71
+ lark-rust is a drop-in replacement for lark-cython. All plugins supported by lark-cython are supported:
72
+
73
+ - `BasicLexer`, `ContextualLexer`, `LexerThread`
74
+ - `LALR_Parser`, `_Parser`, `ParseTreeBuilder`
75
+
76
+ ## Requirements
77
+
78
+ - Python >= 3.8
79
+ - lark >= 1.0
80
+
81
+ ## License
82
+
83
+ MIT
84
+
@@ -0,0 +1,53 @@
1
+ # lark-rust
2
+
3
+ High-performance Rust-accelerated drop-in replacement for [lark](https://github.com/lark-parser/lark)'s LALR parser stack. A faster alternative to [lark-cython](https://github.com/lark-parser/lark_cython).
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ pip install lark-rust
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```python
14
+ from lark import Lark
15
+ import lark_rust
16
+
17
+ parser = Lark(grammar, parser='lalr', _plugins=lark_rust.plugins)
18
+ result = parser.parse(text)
19
+ ```
20
+
21
+ That's it — same lark API, just faster.
22
+
23
+ ## What's accelerated
24
+
25
+ The Rust native extension accelerates the hot-path components:
26
+
27
+ - **Token** — creation, hashing, equality comparison
28
+ - **Scanner** — regex matching via `fancy-regex`
29
+ - **BasicLexer** — token loop with single-pass newline counting
30
+ - **LineCounter** — position tracking
31
+ - **LexerState** — lexer state management
32
+
33
+ The parser, tree builder, and tree traversal are implemented in Python with full lark compatibility:
34
+
35
+ - **ContextualLexer**, **LALR_Parser** (with serialize/deserialize/on_error)
36
+ - **ParseTreeBuilder** with ExpandSingleChild, PropagatePositions, ChildFilter
37
+ - **Tree** with iter_subtrees, find_data, scan_values, pretty printing
38
+
39
+ ## lark-cython compatibility
40
+
41
+ lark-rust is a drop-in replacement for lark-cython. All plugins supported by lark-cython are supported:
42
+
43
+ - `BasicLexer`, `ContextualLexer`, `LexerThread`
44
+ - `LALR_Parser`, `_Parser`, `ParseTreeBuilder`
45
+
46
+ ## Requirements
47
+
48
+ - Python >= 3.8
49
+ - lark >= 1.0
50
+
51
+ ## License
52
+
53
+ MIT
@@ -0,0 +1,44 @@
1
+ [build-system]
2
+ requires = ["maturin>=1.0,<2.0"]
3
+ build-backend = "maturin"
4
+
5
+ [project]
6
+ name = "lark-rust"
7
+ version = "0.1.0"
8
+ description = "High-performance Rust-accelerated drop-in replacement for lark's LALR parser stack"
9
+ requires-python = ">=3.8"
10
+ license = "MIT"
11
+ authors = [
12
+ { name = "Robert Ozimek", email = "robertozimek@users.noreply.github.com" },
13
+ ]
14
+ readme = "README.md"
15
+ keywords = ["lark", "parser", "lalr", "rust", "performance"]
16
+ classifiers = [
17
+ "Development Status :: 4 - Beta",
18
+ "Intended Audience :: Developers",
19
+ "License :: OSI Approved :: MIT License",
20
+ "Programming Language :: Rust",
21
+ "Programming Language :: Python :: Implementation :: CPython",
22
+ "Programming Language :: Python :: 3",
23
+ "Programming Language :: Python :: 3.8",
24
+ "Programming Language :: Python :: 3.9",
25
+ "Programming Language :: Python :: 3.10",
26
+ "Programming Language :: Python :: 3.11",
27
+ "Programming Language :: Python :: 3.12",
28
+ "Programming Language :: Python :: 3.13",
29
+ "Programming Language :: Python :: 3.14",
30
+ "Topic :: Software Development :: Compilers",
31
+ "Topic :: Text Processing :: General",
32
+ ]
33
+ dependencies = ["lark>=1.0"]
34
+
35
+ [project.urls]
36
+ Homepage = "https://github.com/robertozimek/lark-rust"
37
+ Repository = "https://github.com/robertozimek/lark-rust"
38
+ Issues = "https://github.com/robertozimek/lark-rust/issues"
39
+
40
+ [tool.maturin]
41
+ python-source = "python"
42
+
43
+ [tool.pytest.ini_options]
44
+ testpaths = ["tests"]