nc-gcode-interpreter 0.1.4__tar.gz → 0.1.7__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 (58) hide show
  1. {nc_gcode_interpreter-0.1.4 → nc_gcode_interpreter-0.1.7}/.github/workflows/build-and-release.yml +148 -127
  2. {nc_gcode_interpreter-0.1.4 → nc_gcode_interpreter-0.1.7}/Cargo.lock +1 -1
  3. {nc_gcode_interpreter-0.1.4 → nc_gcode_interpreter-0.1.7}/Cargo.toml +1 -1
  4. {nc_gcode_interpreter-0.1.4 → nc_gcode_interpreter-0.1.7}/PKG-INFO +7 -3
  5. {nc_gcode_interpreter-0.1.4 → nc_gcode_interpreter-0.1.7}/README.md +1 -1
  6. nc_gcode_interpreter-0.1.7/examples/tool.csv +2 -0
  7. nc_gcode_interpreter-0.1.7/examples/tool.mpf +1 -0
  8. {nc_gcode_interpreter-0.1.4 → nc_gcode_interpreter-0.1.7}/ggroups/generate_pest.py +13 -1
  9. {nc_gcode_interpreter-0.1.4 → nc_gcode_interpreter-0.1.7}/ggroups/ggroups.pest +4 -1
  10. {nc_gcode_interpreter-0.1.4 → nc_gcode_interpreter-0.1.7}/pyproject.toml +10 -2
  11. {nc_gcode_interpreter-0.1.4 → nc_gcode_interpreter-0.1.7}/python/tests/test_expected_output.py +1 -2
  12. {nc_gcode_interpreter-0.1.4 → nc_gcode_interpreter-0.1.7}/src/grammar.pest +14 -70
  13. {nc_gcode_interpreter-0.1.4 → nc_gcode_interpreter-0.1.7}/src/interpret_rules.rs +55 -15
  14. {nc_gcode_interpreter-0.1.4 → nc_gcode_interpreter-0.1.7}/src/interpreter.rs +39 -54
  15. {nc_gcode_interpreter-0.1.4 → nc_gcode_interpreter-0.1.7}/src/lib.rs +10 -4
  16. {nc_gcode_interpreter-0.1.4 → nc_gcode_interpreter-0.1.7}/src/main.rs +10 -6
  17. {nc_gcode_interpreter-0.1.4 → nc_gcode_interpreter-0.1.7}/src/state.rs +3 -3
  18. {nc_gcode_interpreter-0.1.4 → nc_gcode_interpreter-0.1.7}/src/types.rs +1 -3
  19. nc_gcode_interpreter-0.1.7/uv.lock +1540 -0
  20. nc_gcode_interpreter-0.1.4/uv.lock +0 -33
  21. {nc_gcode_interpreter-0.1.4 → nc_gcode_interpreter-0.1.7}/.gitignore +0 -0
  22. {nc_gcode_interpreter-0.1.4 → nc_gcode_interpreter-0.1.7}/CONTRIBUTING.md +0 -0
  23. {nc_gcode_interpreter-0.1.4 → nc_gcode_interpreter-0.1.7}/Development.md +0 -0
  24. {nc_gcode_interpreter-0.1.4 → nc_gcode_interpreter-0.1.7}/Example.MPF +0 -0
  25. {nc_gcode_interpreter-0.1.4 → nc_gcode_interpreter-0.1.7}/LICENSE +0 -0
  26. {nc_gcode_interpreter-0.1.4 → nc_gcode_interpreter-0.1.7}/TODO.md +0 -0
  27. {nc_gcode_interpreter-0.1.4 → nc_gcode_interpreter-0.1.7}/examples/arrays.csv +0 -0
  28. {nc_gcode_interpreter-0.1.4 → nc_gcode_interpreter-0.1.7}/examples/arrays.mpf +0 -0
  29. {nc_gcode_interpreter-0.1.4 → nc_gcode_interpreter-0.1.7}/examples/basic_math.csv +0 -0
  30. {nc_gcode_interpreter-0.1.4 → nc_gcode_interpreter-0.1.7}/examples/basic_math.mpf +0 -0
  31. {nc_gcode_interpreter-0.1.4 → nc_gcode_interpreter-0.1.7}/examples/custom_vars.csv +0 -0
  32. {nc_gcode_interpreter-0.1.4 → nc_gcode_interpreter-0.1.7}/examples/custom_vars.mpf +0 -0
  33. {nc_gcode_interpreter-0.1.4 → nc_gcode_interpreter-0.1.7}/examples/defaults.csv +0 -0
  34. {nc_gcode_interpreter-0.1.4 → nc_gcode_interpreter-0.1.7}/examples/defaults.mpf +0 -0
  35. {nc_gcode_interpreter-0.1.4 → nc_gcode_interpreter-0.1.7}/examples/for_loop.csv +0 -0
  36. {nc_gcode_interpreter-0.1.4 → nc_gcode_interpreter-0.1.7}/examples/for_loop.mpf +0 -0
  37. {nc_gcode_interpreter-0.1.4 → nc_gcode_interpreter-0.1.7}/examples/if_statement.csv +0 -0
  38. {nc_gcode_interpreter-0.1.4 → nc_gcode_interpreter-0.1.7}/examples/if_statement.mpf +0 -0
  39. {nc_gcode_interpreter-0.1.4 → nc_gcode_interpreter-0.1.7}/examples/increment.csv +0 -0
  40. {nc_gcode_interpreter-0.1.4 → nc_gcode_interpreter-0.1.7}/examples/increment.mpf +0 -0
  41. {nc_gcode_interpreter-0.1.4 → nc_gcode_interpreter-0.1.7}/examples/loop.csv +0 -0
  42. {nc_gcode_interpreter-0.1.4 → nc_gcode_interpreter-0.1.7}/examples/loop.mpf +0 -0
  43. {nc_gcode_interpreter-0.1.4 → nc_gcode_interpreter-0.1.7}/examples/multiple_m_codes.csv +0 -0
  44. {nc_gcode_interpreter-0.1.4 → nc_gcode_interpreter-0.1.7}/examples/multiple_m_codes.mpf +0 -0
  45. {nc_gcode_interpreter-0.1.4 → nc_gcode_interpreter-0.1.7}/examples/simple.csv +0 -0
  46. {nc_gcode_interpreter-0.1.4 → nc_gcode_interpreter-0.1.7}/examples/simple.mpf +0 -0
  47. {nc_gcode_interpreter-0.1.4 → nc_gcode_interpreter-0.1.7}/examples/trans.csv +0 -0
  48. {nc_gcode_interpreter-0.1.4 → nc_gcode_interpreter-0.1.7}/examples/trans.mpf +0 -0
  49. {nc_gcode_interpreter-0.1.4 → nc_gcode_interpreter-0.1.7}/examples/variables.csv +0 -0
  50. {nc_gcode_interpreter-0.1.4 → nc_gcode_interpreter-0.1.7}/examples/variables.mpf +0 -0
  51. {nc_gcode_interpreter-0.1.4 → nc_gcode_interpreter-0.1.7}/ggroups/generate_modal_ggroups.py +0 -0
  52. {nc_gcode_interpreter-0.1.4 → nc_gcode_interpreter-0.1.7}/ggroups/ggroups.json +0 -0
  53. {nc_gcode_interpreter-0.1.4 → nc_gcode_interpreter-0.1.7}/ggroups/modal_groups.rs +0 -0
  54. {nc_gcode_interpreter-0.1.4 → nc_gcode_interpreter-0.1.7}/python/example/minimal.py +0 -0
  55. {nc_gcode_interpreter-0.1.4 → nc_gcode_interpreter-0.1.7}/python/nc_gcode_interpreter/__init__.py +0 -0
  56. {nc_gcode_interpreter-0.1.4 → nc_gcode_interpreter-0.1.7}/rustfmt.toml +0 -0
  57. {nc_gcode_interpreter-0.1.4 → nc_gcode_interpreter-0.1.7}/src/errors.rs +0 -0
  58. {nc_gcode_interpreter-0.1.4 → nc_gcode_interpreter-0.1.7}/src/modal_groups.rs +0 -0
@@ -13,44 +13,115 @@ name: Build and Release
13
13
 
14
14
  on:
15
15
  push:
16
+ branches:
17
+ - main
16
18
  tags:
17
19
  - 'v*'
20
+ pull_request:
18
21
  workflow_dispatch:
19
22
 
23
+
20
24
  permissions:
21
25
  contents: write
22
26
 
23
27
  env:
24
28
  PROJECT_NAME: "nc-gcode-interpreter"
25
-
26
29
  jobs:
27
- linux:
30
+ lint:
31
+ runs-on: ubuntu-latest
32
+ steps:
33
+ - uses: actions/checkout@v4
34
+ - uses: actions/setup-python@v5
35
+ with:
36
+ python-version: 3.12
37
+ - name: Install Python linter
38
+ run: pip install ruff
39
+ - name: Lint Python code with ruff
40
+ run: ruff check .
41
+
42
+ linux-x64:
43
+ needs: [lint]
28
44
  runs-on: ${{ matrix.platform.runner }}
29
45
  strategy:
30
46
  matrix:
31
47
  platform:
32
48
  - runner: ubuntu-latest
33
49
  target: x86_64
34
- # - runner: ubuntu-latest
35
- # target: x86
50
+ steps:
51
+ - uses: actions/checkout@v4
52
+ - uses: actions/setup-python@v5
53
+ with:
54
+ python-version: 3.12
55
+ - name: Update Cargo.toml Version
56
+ if: startsWith(github.ref, 'refs/tags/')
57
+ run: |
58
+ VERSION=${GITHUB_REF#refs/tags/v}
59
+ echo "Setting version to $VERSION"
60
+ sed -i "s/^version = \".*\"/version = \"$VERSION\"/" Cargo.toml
61
+ - name: Build wheels
62
+ uses: PyO3/maturin-action@v1
63
+ with:
64
+ target: ${{ matrix.platform.target }}
65
+ args: --release --out dist --find-interpreter
66
+ sccache: 'true'
67
+ manylinux: auto
68
+ - name: Upload wheels
69
+ uses: actions/upload-artifact@v4
70
+ with:
71
+ name: wheels-linux-${{ matrix.platform.target }}
72
+ path: dist
73
+
74
+ test:
75
+ needs: [linux-x64]
76
+ runs-on: ubuntu-latest
77
+ steps:
78
+ - uses: actions/checkout@v4
79
+ - uses: actions/download-artifact@v4
80
+ with:
81
+ name: wheels-linux-x86_64
82
+ path: dist
83
+ - uses: actions/setup-python@v5
84
+ with:
85
+ python-version: 3.12
86
+ - name: Install py_opw_kinematics
87
+ run: |
88
+ WHL_FILE=$(ls dist/*cp312*.whl)
89
+ pip install "${WHL_FILE}[test]"
90
+ - name: Run tests with pytest
91
+ run: pytest
92
+
93
+ linux:
94
+ if: startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch'
95
+ needs: [lint, test]
96
+ runs-on: ${{ matrix.platform.runner }}
97
+ strategy:
98
+ matrix:
99
+ platform:
100
+ # - runner: ubuntu-latest
101
+ # target: x86
36
102
  - runner: ubuntu-latest
37
103
  target: aarch64
38
- # - runner: ubuntu-latest
39
- # target: armv7
40
- # - runner: ubuntu-latest
41
- # target: s390x
42
- # - runner: ubuntu-latest
43
- # target: ppc64le
104
+ # - runner: ubuntu-latest
105
+ # target: armv7
106
+ # - runner: ubuntu-latest
107
+ # target: s390x
108
+ # - runner: ubuntu-latest
109
+ # target: ppc64le
44
110
  steps:
45
111
  - uses: actions/checkout@v4
46
112
  - uses: actions/setup-python@v5
47
113
  with:
48
114
  python-version: 3.12
115
+ - name: Update Cargo.toml Version
116
+ if: startsWith(github.ref, 'refs/tags/')
117
+ run: |
118
+ VERSION=${GITHUB_REF#refs/tags/v}
119
+ echo "Setting version to $VERSION"
120
+ sed -i "s/^version = \".*\"/version = \"$VERSION\"/" Cargo.toml
49
121
  - name: Build wheels
50
122
  uses: PyO3/maturin-action@v1
51
123
  with:
52
124
  target: ${{ matrix.platform.target }}
53
- # args: --release --out dist --find-interpreter -b bin
54
125
  args: --release --out dist --find-interpreter
55
126
  sccache: 'true'
56
127
  manylinux: auto
@@ -60,58 +131,67 @@ jobs:
60
131
  name: wheels-linux-${{ matrix.platform.target }}
61
132
  path: dist
62
133
 
63
- # musllinux:
64
- # runs-on: ${{ matrix.platform.runner }}
65
- # strategy:
66
- # matrix:
67
- # platform:
68
- # - runner: ubuntu-latest
69
- # target: x86_64
70
- # - runner: ubuntu-latest
71
- # target: x86
72
- # - runner: ubuntu-latest
73
- # target: aarch64
74
- # - runner: ubuntu-latest
75
- # target: armv7
76
- # steps:
77
- # - uses: actions/checkout@v4
78
- # - uses: actions/setup-python@v5
79
- # with:
80
- # python-version: 3.12
81
- # - name: Build wheels
82
- # uses: PyO3/maturin-action@v1
83
- # with:
84
- # target: ${{ matrix.platform.target }}
85
- # # args: --release --out dist --find-interpreter -b bin
86
- # args: --release --out dist --find-interpreter
87
- # sccache: 'true'
88
- # manylinux: musllinux_1_2
89
- # - name: Upload wheels
90
- # uses: actions/upload-artifact@v4
91
- # with:
92
- # name: wheels-musllinux-${{ matrix.platform.target }}
93
- # path: dist
134
+
135
+ # musllinux:
136
+ # needs: [lint, test]
137
+ # runs-on: ${{ matrix.platform.runner }}
138
+ # strategy:
139
+ # matrix:
140
+ # platform:
141
+ # - runner: ubuntu-latest
142
+ # target: x86_64
143
+ # # - runner: ubuntu-latest
144
+ # # target: x86
145
+ # # - runner: ubuntu-latest
146
+ # # target: aarch64
147
+ # # - runner: ubuntu-latest
148
+ # # target: armv7
149
+ # steps:
150
+ # - uses: actions/checkout@v4
151
+ # - uses: actions/setup-python@v5
152
+ # with:
153
+ # python-version: '>=3.12'
154
+ # - name: Build wheels
155
+ # uses: PyO3/maturin-action@v1
156
+ # with:
157
+ # target: ${{ matrix.platform.target }}
158
+ # args: --release --out dist --find-interpreter
159
+ # sccache: 'true'
160
+ # manylinux: musllinux_1_2
161
+ # - name: Upload wheels
162
+ # uses: actions/upload-artifact@v4
163
+ # with:
164
+ # name: wheels-musllinux-${{ matrix.platform.target }}
165
+ # path: dist
94
166
 
95
167
  windows:
168
+ if: startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch'
169
+ needs: [lint, test]
96
170
  runs-on: ${{ matrix.platform.runner }}
97
171
  strategy:
98
172
  matrix:
99
173
  platform:
100
174
  - runner: windows-latest
101
175
  target: x64
102
- # - runner: windows-latest
103
- # target: x86
176
+ # - runner: windows-latest
177
+ # target: x86
104
178
  steps:
105
179
  - uses: actions/checkout@v4
106
180
  - uses: actions/setup-python@v5
107
181
  with:
108
182
  python-version: 3.12
109
183
  architecture: ${{ matrix.platform.target }}
184
+ - name: Update Cargo.toml Version
185
+ if: startsWith(github.ref, 'refs/tags/')
186
+ shell: pwsh
187
+ run: |
188
+ $VERSION = $env:GITHUB_REF -replace 'refs/tags/v',''
189
+ Write-Host "Setting version to $VERSION"
190
+ (Get-Content Cargo.toml) -replace '^version = ".*"', ('version = "' + $VERSION + '"') | Set-Content Cargo.toml
110
191
  - name: Build wheels
111
192
  uses: PyO3/maturin-action@v1
112
193
  with:
113
194
  target: ${{ matrix.platform.target }}
114
- # args: --release --out dist --find-interpreter -b bin
115
195
  args: --release --out dist --find-interpreter
116
196
  sccache: 'true'
117
197
  - name: Upload wheels
@@ -121,6 +201,8 @@ jobs:
121
201
  path: dist
122
202
 
123
203
  macos:
204
+ if: startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch'
205
+ needs: [lint, test]
124
206
  runs-on: ${{ matrix.platform.runner }}
125
207
  strategy:
126
208
  matrix:
@@ -134,11 +216,15 @@ jobs:
134
216
  - uses: actions/setup-python@v5
135
217
  with:
136
218
  python-version: 3.12
219
+ - name: Update Cargo.toml Version
220
+ run: |
221
+ VERSION=${GITHUB_REF#refs/tags/v}
222
+ echo "Setting version to $VERSION"
223
+ sed -i '' "s/^version = \".*\"/version = \"$VERSION\"/" Cargo.toml
137
224
  - name: Build wheels
138
225
  uses: PyO3/maturin-action@v1
139
226
  with:
140
227
  target: ${{ matrix.platform.target }}
141
- # args: --release --out dist --find-interpreter -b bin
142
228
  args: --release --out dist --find-interpreter
143
229
  sccache: 'true'
144
230
  - name: Upload wheels
@@ -147,51 +233,21 @@ jobs:
147
233
  name: wheels-macos-${{ matrix.platform.target }}
148
234
  path: dist
149
235
 
150
- # emscripten:
151
- # runs-on: ${{ matrix.platform.runner }}
152
- # strategy:
153
- # matrix:
154
- # platform:
155
- # - runner: ubuntu-latest
156
- # target: wasm32-unknown-emscripten
157
- # steps:
158
- # - uses: actions/checkout@v4
159
- # - uses: actions/setup-python@v5
160
- # with:
161
- # python-version: 3.12
162
- # - run: pip install pyodide-build
163
- # - name: Get Emscripten and Python version info
164
- # shell: bash
165
- # run: |
166
- # echo EMSCRIPTEN_VERSION=$(pyodide config get emscripten_version) >> $GITHUB_ENV
167
- # echo PYTHON_VERSION=$(pyodide config get python_version | cut -d '.' -f 1-2) >> $GITHUB_ENV
168
- # pip uninstall -y pyodide-build
169
- # - uses: mymindstorm/setup-emsdk@v12
170
- # with:
171
- # version: ${{ env.EMSCRIPTEN_VERSION }}
172
- # actions-cache-folder: emsdk-cache
173
- # - uses: actions/setup-python@v5
174
- # with:
175
- # python-version: ${{ env.PYTHON_VERSION }}
176
- # - run: pip install pyodide-build
177
- # - name: Build wheels
178
- # uses: PyO3/maturin-action@v1
179
- # with:
180
- # target: ${{ matrix.platform.target }}
181
- # # args: --release --out dist -i ${{ env.PYTHON_VERSION }} -b bin
182
- # args: --release --out dist -i ${{ env.PYTHON_VERSION }}
183
- # sccache: 'true'
184
- # rust-toolchain: nightly
185
- # - name: Upload wheels
186
- # uses: actions/upload-artifact@v4
187
- # with:
188
- # name: wheels-wasm
189
- # path: dist
190
-
191
236
  sdist:
237
+ if: startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch'
238
+ needs: [lint, test]
192
239
  runs-on: ubuntu-latest
193
240
  steps:
194
241
  - uses: actions/checkout@v4
242
+ - uses: actions/setup-python@v5
243
+ with:
244
+ python-version: 3.12
245
+ - name: Update Cargo.toml Version
246
+ if: startsWith(github.ref, 'refs/tags/')
247
+ run: |
248
+ VERSION=${GITHUB_REF#refs/tags/v}
249
+ echo "Setting version to $VERSION"
250
+ sed -i "s/^version = \".*\"/version = \"$VERSION\"/" Cargo.toml
195
251
  - name: Build sdist
196
252
  uses: PyO3/maturin-action@v1
197
253
  with:
@@ -206,10 +262,8 @@ jobs:
206
262
  release:
207
263
  name: Release
208
264
  runs-on: ubuntu-latest
209
- environment: release
210
265
  if: ${{ startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch' }}
211
- # needs: [linux, musllinux, windows, macos, emscripten, sdist]
212
- needs: [linux, windows, macos, sdist]
266
+ needs: [linux, linux-x64, windows, macos, sdist]
213
267
  permissions:
214
268
  # Use to sign the release artifacts
215
269
  id-token: write
@@ -219,12 +273,15 @@ jobs:
219
273
  attestations: write
220
274
  steps:
221
275
  - uses: actions/download-artifact@v4
276
+ - uses: actions/setup-python@v5
277
+ with:
278
+ python-version: 3.12
222
279
  - name: Generate artifact attestation
223
280
  uses: actions/attest-build-provenance@v1
224
281
  with:
225
282
  subject-path: 'wheels-*/*'
226
283
  - name: Publish to PyPI
227
- if: "startsWith(github.ref, 'refs/tags/')"
284
+ if: startsWith(github.ref, 'refs/tags/')
228
285
  uses: PyO3/maturin-action@v1
229
286
  with:
230
287
  command: upload
@@ -238,39 +295,3 @@ jobs:
238
295
  wheels-linux-*/*.whl
239
296
  wheels-macos-*/*.whl
240
297
  prerelease: ${{ contains(github.ref, 'alpha') || contains(github.ref, 'beta') }}
241
- # - name: Extract binary and rename
242
- # env:
243
- # PROJECT_NAME: ${{ env.PROJECT_NAME }}
244
- # run: |
245
- # for wheel_dir in wheels-windows-* wheels-linux-* wheels-macos-*; do
246
- # arch=$(echo $wheel_dir | cut -d'-' -f3)
247
- # os=$(echo $wheel_dir | cut -d'-' -f2)
248
- # find ./$wheel_dir -name "*.whl" -exec sh -c '
249
- # wheel_name=$(basename "$1")
250
- # version=$(echo $wheel_name | sed -E "s/.*-([0-9]+\.[0-9]+\.[0-9]+)-.*/\1/")
251
- # unzip -d "$(dirname "$1")" "$1"
252
- # if [ "$2" = "windows" ]; then
253
- # binary_path=$(find "$(dirname "$1")" -name "*.exe")
254
- # if [ -n "$binary_path" ]; then
255
- # mv "$binary_path" "$(dirname "$binary_path")/${PROJECT_NAME}_${version}_${2}_${3}.exe"
256
- # fi
257
- # else
258
- # binary_path=$(find "$(dirname "$1")" -type f -executable)
259
- # if [ -n "$binary_path" ]; then
260
- # mv "$binary_path" "$(dirname "$binary_path")/${PROJECT_NAME}_${version}_${2}_${3}"
261
- # fi
262
- # fi
263
- # ' _ {} "$os" "$arch" \;
264
- # done
265
- # - name: Upload to GitHub Release
266
- # uses: softprops/action-gh-release@v2
267
- # with:
268
- # files: |
269
- # wheels-sdist/*.tar.gz
270
- # wheels-windows-*/*.whl
271
- # wheels-windows-*/*.data/scripts/${{ env.PROJECT_NAME }}_*_windows_*.exe
272
- # wheels-linux-*/*.whl
273
- # wheels-linux-*/*.data/scripts/${{ env.PROJECT_NAME }}_*_linux_*
274
- # wheels-macos-*/*.whl
275
- # wheels-macos-*/*.data/scripts/${{ env.PROJECT_NAME }}_*_macos_*
276
- # prerelease: ${{ contains(github.ref, 'alpha') || contains(github.ref, 'beta') }}
@@ -724,7 +724,7 @@ dependencies = [
724
724
 
725
725
  [[package]]
726
726
  name = "nc-gcode-interpreter"
727
- version = "0.1.4"
727
+ version = "0.1.7"
728
728
  dependencies = [
729
729
  "clap",
730
730
  "csv",
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "nc-gcode-interpreter"
3
- version = "0.1.4"
3
+ version = "0.1.7"
4
4
  edition = "2021"
5
5
 
6
6
  [lib]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: nc-gcode-interpreter
3
- Version: 0.1.4
3
+ Version: 0.1.7
4
4
  Classifier: Programming Language :: Rust
5
5
  Classifier: Programming Language :: Python :: Implementation :: CPython
6
6
  Classifier: Programming Language :: Python :: 3.12
@@ -9,10 +9,14 @@ Classifier: Operating System :: OS Independent
9
9
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
10
10
  Requires-Dist: maturin >=1.7.4
11
11
  Requires-Dist: polars >=1.9.0
12
+ Requires-Dist: jupyter >=1.1.1 ; extra == 'dev'
13
+ Requires-Dist: pytest >=8.3.3 ; extra == 'test'
14
+ Provides-Extra: dev
15
+ Provides-Extra: test
12
16
  License-File: LICENSE
13
17
  Summary: A interpreter for NC (Numerical Control) code
14
18
  Author-email: CEAD Group <software@ceadgroup.com>
15
- Requires-Python: >=3.12
19
+ Requires-Python: >=3.11
16
20
  Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
17
21
  Project-URL: Homepage, https://github.com/CEAD-group/nc-gcode-interpreter
18
22
  Project-URL: Repository, https://github.com/CEAD-group/nc-gcode-interpreter.git
@@ -84,7 +88,7 @@ Options:
84
88
  -a, --axes <AXIS> Override default axis identifiers (comma-separated, e.g., "X,Y,Z")
85
89
  -e, --extra-axes <EXTRA_AXIS> Add extra axis identifiers (comma-separated, e.g., "RA1,RA2")
86
90
  -i, --initial_state <INITIAL_STATE> Optional initial_state file to initialize state
87
- -l, --iteration_limit <LIMIT> Maximum number of iterations for loops [default: 10000]
91
+ -l, --iteration_limit <LIMIT> Maximum number of iterations for loops [default: 10000]
88
92
  -f, --disable-forward-fill Disable forward-filling of null values in axes columns
89
93
  -h, --help Print help
90
94
  -V, --version Print version
@@ -64,7 +64,7 @@ Options:
64
64
  -a, --axes <AXIS> Override default axis identifiers (comma-separated, e.g., "X,Y,Z")
65
65
  -e, --extra-axes <EXTRA_AXIS> Add extra axis identifiers (comma-separated, e.g., "RA1,RA2")
66
66
  -i, --initial_state <INITIAL_STATE> Optional initial_state file to initialize state
67
- -l, --iteration_limit <LIMIT> Maximum number of iterations for loops [default: 10000]
67
+ -l, --iteration_limit <LIMIT> Maximum number of iterations for loops [default: 10000]
68
68
  -f, --disable-forward-fill Disable forward-filling of null values in axes columns
69
69
  -h, --help Print help
70
70
  -V, --version Print version
@@ -0,0 +1,2 @@
1
+ M,T
2
+ M6,BALL_MILL_8MM_SHORT
@@ -0,0 +1 @@
1
+ T="BALL_MILL_8MM_SHORT" M6
@@ -18,6 +18,10 @@ def create_pest_grammar(g_groups):
18
18
  grammar_parts.append(
19
19
  "// Due to the way pest works, the sorting of the literals is important."
20
20
  )
21
+ all_words = [
22
+ f'^"{entry["id"]}"' for group in g_groups for entry in group["entries"]
23
+ ]
24
+
21
25
  ggroup_names = []
22
26
  for group in g_groups:
23
27
  group_rules = []
@@ -28,7 +32,15 @@ def create_pest_grammar(g_groups):
28
32
  grammar_parts.append(
29
33
  f"{ggroup_name} = @{{({' | '.join(reversed(sorted(group_rules)))}) ~ !(ASCII_ALPHANUMERIC) }}"
30
34
  )
31
- grammar_parts.append(f"g_command = {{{' | '.join(ggroup_names)}}}")
35
+
36
+ grammar_parts.append(
37
+ f"\ngcommand_list = @{{({' | '.join(reversed(sorted(all_words)))}) ~ !(ASCII_ALPHANUMERIC) }}"
38
+ )
39
+
40
+ grammar_parts.append('g_command_numbered = { &("G" ~ ASCII_DIGIT+) ~ g_command }')
41
+ grammar_parts.append(
42
+ f"g_command = {{ &gcommand_list ~ ({' | '.join(ggroup_names)})}}"
43
+ )
32
44
  return "\n".join(grammar_parts)
33
45
 
34
46
 
@@ -60,4 +60,7 @@ gg59_area_limit = @{(^"WALCS9" | ^"WALCS8" | ^"WALCS7" | ^"WALCS6" | ^"WALCS5" |
60
60
  gg61_tool_orient_smooth = @{(^"ORISON" | ^"ORISOF") ~ !(ASCII_ALPHANUMERIC) }
61
61
  gg62_repos_non_modal = @{(^"RMNBL" | ^"RMIBL" | ^"RMEBL" | ^"RMBBL") ~ !(ASCII_ALPHANUMERIC) }
62
62
  gg64_grinding_frames = @{(^"GFRAME[9]" | ^"GFRAME[99]" | ^"GFRAME[98]" | ^"GFRAME[97]" | ^"GFRAME[96]" | ^"GFRAME[95]" | ^"GFRAME[94]" | ^"GFRAME[93]" | ^"GFRAME[92]" | ^"GFRAME[91]" | ^"GFRAME[90]" | ^"GFRAME[8]" | ^"GFRAME[89]" | ^"GFRAME[88]" | ^"GFRAME[87]" | ^"GFRAME[86]" | ^"GFRAME[85]" | ^"GFRAME[84]" | ^"GFRAME[83]" | ^"GFRAME[82]" | ^"GFRAME[81]" | ^"GFRAME[80]" | ^"GFRAME[7]" | ^"GFRAME[79]" | ^"GFRAME[78]" | ^"GFRAME[77]" | ^"GFRAME[76]" | ^"GFRAME[75]" | ^"GFRAME[74]" | ^"GFRAME[73]" | ^"GFRAME[72]" | ^"GFRAME[71]" | ^"GFRAME[70]" | ^"GFRAME[6]" | ^"GFRAME[69]" | ^"GFRAME[68]" | ^"GFRAME[67]" | ^"GFRAME[66]" | ^"GFRAME[65]" | ^"GFRAME[64]" | ^"GFRAME[63]" | ^"GFRAME[62]" | ^"GFRAME[61]" | ^"GFRAME[60]" | ^"GFRAME[5]" | ^"GFRAME[59]" | ^"GFRAME[58]" | ^"GFRAME[57]" | ^"GFRAME[56]" | ^"GFRAME[55]" | ^"GFRAME[54]" | ^"GFRAME[53]" | ^"GFRAME[52]" | ^"GFRAME[51]" | ^"GFRAME[50]" | ^"GFRAME[4]" | ^"GFRAME[49]" | ^"GFRAME[48]" | ^"GFRAME[47]" | ^"GFRAME[46]" | ^"GFRAME[45]" | ^"GFRAME[44]" | ^"GFRAME[43]" | ^"GFRAME[42]" | ^"GFRAME[41]" | ^"GFRAME[40]" | ^"GFRAME[3]" | ^"GFRAME[39]" | ^"GFRAME[38]" | ^"GFRAME[37]" | ^"GFRAME[36]" | ^"GFRAME[35]" | ^"GFRAME[34]" | ^"GFRAME[33]" | ^"GFRAME[32]" | ^"GFRAME[31]" | ^"GFRAME[30]" | ^"GFRAME[2]" | ^"GFRAME[29]" | ^"GFRAME[28]" | ^"GFRAME[27]" | ^"GFRAME[26]" | ^"GFRAME[25]" | ^"GFRAME[24]" | ^"GFRAME[23]" | ^"GFRAME[22]" | ^"GFRAME[21]" | ^"GFRAME[20]" | ^"GFRAME[1]" | ^"GFRAME[19]" | ^"GFRAME[18]" | ^"GFRAME[17]" | ^"GFRAME[16]" | ^"GFRAME[15]" | ^"GFRAME[14]" | ^"GFRAME[13]" | ^"GFRAME[12]" | ^"GFRAME[11]" | ^"GFRAME[10]" | ^"GFRAME[100]" | ^"GFRAME[0]") ~ !(ASCII_ALPHANUMERIC) }
63
- g_command = {gg01_motion | gg02_wait | gg03_frame_area_limit | gg04_fifo | gg06_plane_select | gg07_tool_radius | gg08_work_offset | gg09_frame_tool_suppress | gg10_exact_stop_mode | gg11_exact_stop_non_modal | gg12_block_change_g60_g9 | gg13_wp_measure | gg14_wp_measure_mode | gg15_feed_type | gg16_feedrate_override | gg17_approach_retract_tool | gg18_corner_behavior | gg19_curve_start_spline | gg20_curve_end_spline | gg21_accel_profile | gg22_tool_offset_type | gg23_collision_monitor | gg24_precontrol | gg25_tool_orient_ref | gg26_repos_mode | gg27_tool_offset_change | gg28_area_limit | gg29_rad_diam_prog | gg30_nc_compress | gg31_oem_g | gg32_oem_g | gg33_fine_tool_offset | gg34_tool_orient_smooth | gg35_punch_nibble | gg36_punch_delay | gg37_feedrate_profile | gg39_contour_acc | gg40_tool_radius_const | gg41_thread_interrupt | gg42_tool_carrier | gg43_sar_approach | gg44_sar_segment | gg45_path_ref_fgroup | gg46_plane_fast_retract | gg47_mode_switchover | gg48_approach_retract_trc | gg49_ptp_motion | gg50_orient_prog | gg51_interp_type_orient | gg52_frame_rot_wp | gg53_tool_wear | gg54_vector_rot_poly | gg55_rapid_traverse | gg56_frame_rot_tool | gg57_corner_decel | gg58_dyn_resp_path | gg59_area_limit | gg61_tool_orient_smooth | gg62_repos_non_modal | gg64_grinding_frames}
63
+
64
+ gcommand_list = @{(^"WALIMON" | ^"WALIMOF" | ^"WALCS9" | ^"WALCS8" | ^"WALCS7" | ^"WALCS6" | ^"WALCS5" | ^"WALCS4" | ^"WALCS3" | ^"WALCS2" | ^"WALCS10" | ^"WALCS1" | ^"WALCS0" | ^"UPATH" | ^"TRANS" | ^"TOWWCS" | ^"TOWTCS" | ^"TOWSTD" | ^"TOWMCS" | ^"TOWKCS" | ^"TOWBCS" | ^"TOROTZ" | ^"TOROTY" | ^"TOROTX" | ^"TOROTOF" | ^"TOROT" | ^"TOFRAMEZ" | ^"TOFRAMEY" | ^"TOFRAMEX" | ^"TOFRAME" | ^"TCOFRZ" | ^"TCOFRY" | ^"TCOFRX" | ^"TCOFR" | ^"TCOABS" | ^"SUPD" | ^"SUPA" | ^"STOPFIFO" | ^"STARTFIFO" | ^"SPOF" | ^"SPATH" | ^"SONS" | ^"SON" | ^"SOFT" | ^"SCALE" | ^"RTLION" | ^"RTLIOF" | ^"ROTS" | ^"ROT" | ^"RMNBL" | ^"RMN" | ^"RMIBL" | ^"RMI" | ^"RMEBL" | ^"RME" | ^"RMBBL" | ^"RMB" | ^"REPOSQA" | ^"REPOSQ" | ^"REPOSL" | ^"REPOSHA" | ^"REPOSH" | ^"REPOSA" | ^"PTPWOC" | ^"PTPG0" | ^"PTP" | ^"PONS" | ^"PON" | ^"POLY" | ^"PDELAYON" | ^"PDELAYOF" | ^"PAROTOF" | ^"PAROT" | ^"OST" | ^"OSSE" | ^"OSS" | ^"OSOF" | ^"OSD" | ^"OSC" | ^"ORIWKS" | ^"ORIVIRT2" | ^"ORIVIRT1" | ^"ORIVECT" | ^"ORISON" | ^"ORISOF" | ^"ORIRPY2" | ^"ORIRPY" | ^"ORIROTT" | ^"ORIROTR" | ^"ORIROTC" | ^"ORIROTA" | ^"ORIPLANE" | ^"ORIPATHS" | ^"ORIPATH" | ^"ORIMKS" | ^"ORIEULER" | ^"ORID" | ^"ORICURVE" | ^"ORICONTO" | ^"ORICONIO" | ^"ORICONCW" | ^"ORICONCCW" | ^"ORIC" | ^"ORIAXPOS" | ^"ORIAXES" | ^"OEMIPO2" | ^"OEMIPO1" | ^"NORM" | ^"MIRROR" | ^"LFWP" | ^"LFTXT" | ^"LFPOS" | ^"LFON" | ^"LFOF" | ^"KONTT" | ^"KONTC" | ^"KONT" | ^"INVCW" | ^"INVCCW" | ^"GFRAME[9]" | ^"GFRAME[99]" | ^"GFRAME[98]" | ^"GFRAME[97]" | ^"GFRAME[96]" | ^"GFRAME[95]" | ^"GFRAME[94]" | ^"GFRAME[93]" | ^"GFRAME[92]" | ^"GFRAME[91]" | ^"GFRAME[90]" | ^"GFRAME[8]" | ^"GFRAME[89]" | ^"GFRAME[88]" | ^"GFRAME[87]" | ^"GFRAME[86]" | ^"GFRAME[85]" | ^"GFRAME[84]" | ^"GFRAME[83]" | ^"GFRAME[82]" | ^"GFRAME[81]" | ^"GFRAME[80]" | ^"GFRAME[7]" | ^"GFRAME[79]" | ^"GFRAME[78]" | ^"GFRAME[77]" | ^"GFRAME[76]" | ^"GFRAME[75]" | ^"GFRAME[74]" | ^"GFRAME[73]" | ^"GFRAME[72]" | ^"GFRAME[71]" | ^"GFRAME[70]" | ^"GFRAME[6]" | ^"GFRAME[69]" | ^"GFRAME[68]" | ^"GFRAME[67]" | ^"GFRAME[66]" | ^"GFRAME[65]" | ^"GFRAME[64]" | ^"GFRAME[63]" | ^"GFRAME[62]" | ^"GFRAME[61]" | ^"GFRAME[60]" | ^"GFRAME[5]" | ^"GFRAME[59]" | ^"GFRAME[58]" | ^"GFRAME[57]" | ^"GFRAME[56]" | ^"GFRAME[55]" | ^"GFRAME[54]" | ^"GFRAME[53]" | ^"GFRAME[52]" | ^"GFRAME[51]" | ^"GFRAME[50]" | ^"GFRAME[4]" | ^"GFRAME[49]" | ^"GFRAME[48]" | ^"GFRAME[47]" | ^"GFRAME[46]" | ^"GFRAME[45]" | ^"GFRAME[44]" | ^"GFRAME[43]" | ^"GFRAME[42]" | ^"GFRAME[41]" | ^"GFRAME[40]" | ^"GFRAME[3]" | ^"GFRAME[39]" | ^"GFRAME[38]" | ^"GFRAME[37]" | ^"GFRAME[36]" | ^"GFRAME[35]" | ^"GFRAME[34]" | ^"GFRAME[33]" | ^"GFRAME[32]" | ^"GFRAME[31]" | ^"GFRAME[30]" | ^"GFRAME[2]" | ^"GFRAME[29]" | ^"GFRAME[28]" | ^"GFRAME[27]" | ^"GFRAME[26]" | ^"GFRAME[25]" | ^"GFRAME[24]" | ^"GFRAME[23]" | ^"GFRAME[22]" | ^"GFRAME[21]" | ^"GFRAME[20]" | ^"GFRAME[1]" | ^"GFRAME[19]" | ^"GFRAME[18]" | ^"GFRAME[17]" | ^"GFRAME[16]" | ^"GFRAME[15]" | ^"GFRAME[14]" | ^"GFRAME[13]" | ^"GFRAME[12]" | ^"GFRAME[11]" | ^"GFRAME[10]" | ^"GFRAME[100]" | ^"GFRAME[0]" | ^"G973" | ^"G972" | ^"G971" | ^"G97" | ^"G962" | ^"G961" | ^"G96" | ^"G952" | ^"G95" | ^"G942" | ^"G94" | ^"G931" | ^"G93" | ^"G91" | ^"G90" | ^"G9" | ^"G829" | ^"G828" | ^"G827" | ^"G826" | ^"G825" | ^"G824" | ^"G823" | ^"G822" | ^"G821" | ^"G820" | ^"G819" | ^"G818" | ^"G817" | ^"G816" | ^"G815" | ^"G814" | ^"G813" | ^"G812" | ^"G811" | ^"G810" | ^"G75" | ^"G74" | ^"G710" | ^"G71" | ^"G700" | ^"G70" | ^"G7" | ^"G645" | ^"G644" | ^"G643" | ^"G642" | ^"G641" | ^"G64" | ^"G63" | ^"G621" | ^"G62" | ^"G603" | ^"G602" | ^"G601" | ^"G60" | ^"G599" | ^"G598" | ^"G597" | ^"G596" | ^"G595" | ^"G594" | ^"G593" | ^"G592" | ^"G591" | ^"G590" | ^"G59" | ^"G589" | ^"G588" | ^"G587" | ^"G586" | ^"G585" | ^"G584" | ^"G583" | ^"G582" | ^"G581" | ^"G580" | ^"G58" | ^"G579" | ^"G578" | ^"G577" | ^"G576" | ^"G575" | ^"G574" | ^"G573" | ^"G572" | ^"G571" | ^"G570" | ^"G57" | ^"G569" | ^"G568" | ^"G567" | ^"G566" | ^"G565" | ^"G564" | ^"G563" | ^"G562" | ^"G561" | ^"G560" | ^"G56" | ^"G559" | ^"G558" | ^"G557" | ^"G556" | ^"G555" | ^"G554" | ^"G553" | ^"G552" | ^"G551" | ^"G550" | ^"G55" | ^"G549" | ^"G548" | ^"G547" | ^"G546" | ^"G545" | ^"G544" | ^"G543" | ^"G542" | ^"G541" | ^"G540" | ^"G54" | ^"G539" | ^"G538" | ^"G537" | ^"G536" | ^"G535" | ^"G534" | ^"G533" | ^"G532" | ^"G531" | ^"G530" | ^"G53" | ^"G529" | ^"G528" | ^"G527" | ^"G526" | ^"G525" | ^"G524" | ^"G523" | ^"G522" | ^"G521" | ^"G520" | ^"G519" | ^"G518" | ^"G517" | ^"G516" | ^"G515" | ^"G514" | ^"G513" | ^"G512" | ^"G511" | ^"G510" | ^"G509" | ^"G508" | ^"G507" | ^"G506" | ^"G505" | ^"G500" | ^"G5" | ^"G462" | ^"G461" | ^"G460" | ^"G451" | ^"G450" | ^"G42" | ^"G41" | ^"G40" | ^"G4" | ^"G35" | ^"G348" | ^"G347" | ^"G341" | ^"G340" | ^"G34" | ^"G336" | ^"G335" | ^"G332" | ^"G331" | ^"G33" | ^"G3" | ^"G291" | ^"G290" | ^"G26" | ^"G25" | ^"G248" | ^"G247" | ^"G2" | ^"G19" | ^"G18" | ^"G17" | ^"G153" | ^"G148" | ^"G147" | ^"G143" | ^"G142" | ^"G141" | ^"G140" | ^"G112" | ^"G111" | ^"G110" | ^"G1" | ^"G0" | ^"FTOCON" | ^"FTOCOF" | ^"FNORM" | ^"FLIN" | ^"FIFOCTRL" | ^"FFWON" | ^"FFWOF" | ^"FENDNORM" | ^"FCUB" | ^"ETAN" | ^"ENAT" | ^"EAUTO" | ^"DYNSEMIFIN" | ^"DYNROUGH" | ^"DYNPREC" | ^"DYNPOS" | ^"DYNNORM" | ^"DYNFINISH" | ^"DRIVE" | ^"DIAMON" | ^"DIAMOF" | ^"DIAMCYCOF" | ^"DIAM90" | ^"CUTCONON" | ^"CUTCONOF" | ^"CUT3DFS" | ^"CUT3DFF" | ^"CUT3DFD" | ^"CUT3DF" | ^"CUT3DCD" | ^"CUT3DCCD" | ^"CUT3DCC" | ^"CUT3DC" | ^"CUT2DFD" | ^"CUT2DF" | ^"CUT2DD" | ^"CUT2D" | ^"CT" | ^"CSPLINE" | ^"CPRECON" | ^"CPRECOF" | ^"CP" | ^"COMPSURF" | ^"COMPON" | ^"COMPOF" | ^"COMPCURV" | ^"COMPCAD" | ^"CIP" | ^"CFTCP" | ^"CFIN" | ^"CFC" | ^"CDON" | ^"CDOF2" | ^"CDOF" | ^"BTAN" | ^"BSPLINE" | ^"BRISK" | ^"BNAT" | ^"BAUTO" | ^"ATRANS" | ^"ASPLINE" | ^"ASCALE" | ^"AROTS" | ^"AROT" | ^"AMIRROR") ~ !(ASCII_ALPHANUMERIC) }
65
+ g_command_numbered = { &("G" ~ ASCII_DIGIT+) ~ g_command }
66
+ g_command = { &gcommand_list ~ (gg01_motion | gg02_wait | gg03_frame_area_limit | gg04_fifo | gg06_plane_select | gg07_tool_radius | gg08_work_offset | gg09_frame_tool_suppress | gg10_exact_stop_mode | gg11_exact_stop_non_modal | gg12_block_change_g60_g9 | gg13_wp_measure | gg14_wp_measure_mode | gg15_feed_type | gg16_feedrate_override | gg17_approach_retract_tool | gg18_corner_behavior | gg19_curve_start_spline | gg20_curve_end_spline | gg21_accel_profile | gg22_tool_offset_type | gg23_collision_monitor | gg24_precontrol | gg25_tool_orient_ref | gg26_repos_mode | gg27_tool_offset_change | gg28_area_limit | gg29_rad_diam_prog | gg30_nc_compress | gg31_oem_g | gg32_oem_g | gg33_fine_tool_offset | gg34_tool_orient_smooth | gg35_punch_nibble | gg36_punch_delay | gg37_feedrate_profile | gg39_contour_acc | gg40_tool_radius_const | gg41_thread_interrupt | gg42_tool_carrier | gg43_sar_approach | gg44_sar_segment | gg45_path_ref_fgroup | gg46_plane_fast_retract | gg47_mode_switchover | gg48_approach_retract_trc | gg49_ptp_motion | gg50_orient_prog | gg51_interp_type_orient | gg52_frame_rot_wp | gg53_tool_wear | gg54_vector_rot_poly | gg55_rapid_traverse | gg56_frame_rot_tool | gg57_corner_decel | gg58_dyn_resp_path | gg59_area_limit | gg61_tool_orient_smooth | gg62_repos_non_modal | gg64_grinding_frames)}
@@ -4,10 +4,10 @@ build-backend = "maturin"
4
4
 
5
5
  [project]
6
6
  name = "nc-gcode-interpreter"
7
- version = "0.1.4"
7
+ dynamic = ["version"]
8
8
  description = "A interpreter for NC (Numerical Control) code"
9
9
  authors = [{ name = "CEAD Group", email = "software@ceadgroup.com" }]
10
- requires-python = ">=3.12"
10
+ requires-python = ">=3.11"
11
11
  classifiers = [
12
12
  "Programming Language :: Rust",
13
13
  "Programming Language :: Python :: Implementation :: CPython",
@@ -21,6 +21,14 @@ dependencies = [
21
21
  "polars>=1.9.0"
22
22
  ]
23
23
 
24
+ [project.optional-dependencies]
25
+ dev = [
26
+ "jupyter>=1.1.1"
27
+ ]
28
+ test = [
29
+ "pytest>=8.3.3"
30
+ ]
31
+
24
32
  [project.urls]
25
33
  Homepage = "https://github.com/CEAD-group/nc-gcode-interpreter"
26
34
  Repository = "https://github.com/CEAD-group/nc-gcode-interpreter.git"
@@ -1,7 +1,6 @@
1
1
  import pathlib
2
2
  import pytest
3
3
  from nc_gcode_interpreter import nc_to_dataframe
4
- from polars import DataFrame
5
4
 
6
5
 
7
6
  @pytest.fixture(
@@ -33,7 +32,7 @@ def test_mpf_file_to_csv(mpf_file, initial_state):
33
32
  """
34
33
  Test the nc_to_dataframe function with each .mpf file, using the default initial state.
35
34
  """
36
- df: DataFrame = nc_to_dataframe(
35
+ nc_to_dataframe(
37
36
  mpf_file.read_text(),
38
37
  initial_state=initial_state,
39
38
  iteration_limit=10000,