nc-gcode-interpreter 0.3.1__tar.gz → 0.3.2__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.
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/CHANGELOG.md +15 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/Cargo.lock +1 -1
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/Cargo.toml +1 -1
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/PKG-INFO +1 -1
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/build_backend/nc_build_backend.py +11 -7
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/ggroups/generate_g_commands.py +14 -0
- nc_gcode_interpreter-0.3.2/python/tests/test_build_backend.py +39 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/python/tests/test_g_group_enum.py +28 -4
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/src/grammar.pest +4 -4
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/src/interpret_rules.rs +19 -9
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/src/interpreter.rs +1 -1
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/src/line_driver.rs +17 -12
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/src/modal_groups.rs +14 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/src/start.rs +2 -2
- nc_gcode_interpreter-0.3.2/tests/syntax_compatibility.rs +154 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/.github/workflows/benchmark.yml +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/.github/workflows/build-and-release.yml +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/.gitignore +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/CONTRIBUTING.md +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/Development.md +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/LICENSE +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/README.md +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/TODO.md +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/benches/extensions.rs +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/benches/fixtures.rs +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/benches/workloads.rs +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/build.rs +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/docs/resumable-interpretation-design.md +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/docs/sinumerik-execution-model.md +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/examples/actual_position.csv +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/examples/actual_position.mpf +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/examples/arc.csv +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/examples/arc.mpf +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/examples/arrays.csv +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/examples/arrays.mpf +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/examples/axis_index_assignment.csv +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/examples/axis_index_assignment.mpf +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/examples/basic_math.csv +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/examples/basic_math.mpf +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/examples/case.csv +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/examples/case.mpf +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/examples/case_insensitive_variables.csv +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/examples/case_insensitive_variables.mpf +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/examples/custom_vars.csv +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/examples/custom_vars.mpf +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/examples/def_string.csv +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/examples/def_string.mpf +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/examples/defaults.csv +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/examples/defaults.def +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/examples/defaults.mpf +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/examples/defaults_start.json +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/examples/edge_cases.csv +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/examples/edge_cases.mpf +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/examples/flattening/flatten_demo.mpf +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/examples/flattening/flatten_demo_flattened.csv +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/examples/flattening/flatten_demo_raw.csv +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/examples/for_loop.csv +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/examples/for_loop.mpf +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/examples/function_calls.csv +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/examples/function_calls.mpf +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/examples/goto.csv +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/examples/goto.mpf +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/examples/if_statement.csv +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/examples/if_statement.mpf +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/examples/increment.csv +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/examples/increment.mpf +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/examples/logic_operators.csv +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/examples/logic_operators.mpf +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/examples/loop.csv +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/examples/loop.mpf +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/examples/multiple_m_codes.csv +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/examples/multiple_m_codes.mpf +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/examples/precedence.csv +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/examples/precedence.mpf +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/examples/r_param.csv +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/examples/r_param.mpf +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/examples/repeat.csv +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/examples/repeat.mpf +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/examples/rot.csv +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/examples/rot.mpf +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/examples/simple.csv +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/examples/simple.mpf +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/examples/spline.csv +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/examples/spline.mpf +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/examples/tool.csv +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/examples/tool.mpf +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/examples/trans.csv +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/examples/trans.mpf +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/examples/trans2.csv +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/examples/trans2.mpf +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/examples/trans_ic.csv +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/examples/trans_ic.mpf +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/examples/trans_reset.csv +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/examples/trans_reset.mpf +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/examples/trig.csv +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/examples/trig.mpf +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/examples/variables.csv +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/examples/variables.mpf +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/pyproject.toml +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/python/example/minimal.py +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/python/example/streaming.py +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/python/nc_gcode_interpreter/__init__.py +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/python/nc_gcode_interpreter/_internal.pyi +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/python/nc_gcode_interpreter/cli.py +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/python/nc_gcode_interpreter/ggroups.json +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/python/nc_gcode_interpreter/py.typed +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/python/nc_gcode_interpreter/viz.py +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/python/tests/nc_source.py +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/python/tests/test_arithmetic_functions.py +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/python/tests/test_batch_variables.py +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/python/tests/test_batches.py +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/python/tests/test_compare_benchmarks.py +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/python/tests/test_diagnostics.py +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/python/tests/test_expected_output.py +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/python/tests/test_feed_check.py +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/python/tests/test_feed_group.py +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/python/tests/test_field_defects.py +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/python/tests/test_flags.py +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/python/tests/test_flatten.py +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/python/tests/test_frames.py +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/python/tests/test_g_groups.py +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/python/tests/test_g_vocabulary.py +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/python/tests/test_jumps.py +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/python/tests/test_real_comparisons.py +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/python/tests/test_stage1.py +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/python/tests/test_start_inputs.py +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/python/tests/test_streaming.py +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/python/tests/test_string_operations.py +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/python/tests/test_structured_errors.py +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/python/tests/test_subprograms.py +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/python/tests/test_unsupported.py +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/rustfmt.toml +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/scripts/benchmark.py +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/scripts/compare_benchmarks.py +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/src/errors.rs +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/src/flatten.rs +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/src/frame.rs +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/src/lib.rs +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/src/line_driver/experiments.rs +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/src/main.rs +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/src/output.rs +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/src/state.rs +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/src/structure_scan.rs +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/src/subprogram.rs +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/src/types.rs +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/src/vm.rs +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/tests/cli.rs +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/tests/performance_contract.rs +0 -0
- {nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/uv.lock +0 -0
|
@@ -4,6 +4,21 @@ Notable changes to **nc-gcode-interpreter**. The format loosely follows
|
|
|
4
4
|
[Keep a Changelog](https://keepachangelog.com/); versions are git tags,
|
|
5
5
|
released to PyPI.
|
|
6
6
|
|
|
7
|
+
## [v0.3.2] - 2026-11-13
|
|
8
|
+
|
|
9
|
+
### Fixed
|
|
10
|
+
|
|
11
|
+
- A local build on Windows no longer fails with "metadata version does not
|
|
12
|
+
match". The build backend restored `Cargo.toml` and `Cargo.lock` with CRLF
|
|
13
|
+
line endings, so the tree looked modified to the next build phase, which
|
|
14
|
+
then stamped a different `.dirty` version. Both files now come back byte
|
|
15
|
+
for byte, and a CRLF `Cargo.toml` is stamped too.
|
|
16
|
+
- Accept Siemens numeric literals with leading-dot decimals (`X.5`,
|
|
17
|
+
`Z-.5`, `X=IC(.375)`) and explicit positive signs (`X+0.5`, `R1=+2`).
|
|
18
|
+
Zero-padded G and M codes (`G01`, `G017`, `M03`, `M030`) now use their
|
|
19
|
+
canonical spelling for interpretation and output, including frame and curve
|
|
20
|
+
handling. `start.g_groups` accepts padded codes too.
|
|
21
|
+
|
|
7
22
|
## [v0.3.1] - 2026-11-11
|
|
8
23
|
|
|
9
24
|
### Changed
|
|
@@ -39,7 +39,8 @@ from maturin import (
|
|
|
39
39
|
)
|
|
40
40
|
|
|
41
41
|
PLACEHOLDER = "0.0.0-dev"
|
|
42
|
-
|
|
42
|
+
# No trailing `$`: under MULTILINE it does not match before the `\r` of a CRLF file.
|
|
43
|
+
_VERSION_LINE = re.compile(rb'^version = "[^"\r\n]*"', re.MULTILINE)
|
|
43
44
|
# v0.2.6-3-g1234abc[-dirty]
|
|
44
45
|
_DESCRIBE = re.compile(r"^v(?P<tag>.+)-(?P<distance>\d+)-g(?P<sha>[0-9a-f]+)(?P<dirty>-dirty)?$")
|
|
45
46
|
|
|
@@ -71,8 +72,10 @@ def _versioned_cargo_toml():
|
|
|
71
72
|
root = Path(__file__).resolve().parent.parent
|
|
72
73
|
cargo_toml = root / "Cargo.toml"
|
|
73
74
|
cargo_lock = root / "Cargo.lock"
|
|
74
|
-
|
|
75
|
-
|
|
75
|
+
# Bytes throughout: text mode writes CRLF on Windows, which dirties the tree on restore
|
|
76
|
+
# and makes the next build phase stamp a different (.dirty) version.
|
|
77
|
+
original = cargo_toml.read_bytes()
|
|
78
|
+
if f'version = "{PLACEHOLDER}"'.encode() not in original:
|
|
76
79
|
# CI already stamped the release version; nothing to do.
|
|
77
80
|
yield
|
|
78
81
|
return
|
|
@@ -80,15 +83,16 @@ def _versioned_cargo_toml():
|
|
|
80
83
|
if version is None:
|
|
81
84
|
yield
|
|
82
85
|
return
|
|
83
|
-
lock_original = cargo_lock.
|
|
84
|
-
|
|
86
|
+
lock_original = cargo_lock.read_bytes() if cargo_lock.exists() else None
|
|
87
|
+
stamp = f'version = "{version}"'.encode()
|
|
88
|
+
cargo_toml.write_bytes(_VERSION_LINE.sub(lambda _: stamp, original, count=1))
|
|
85
89
|
try:
|
|
86
90
|
yield
|
|
87
91
|
finally:
|
|
88
|
-
cargo_toml.
|
|
92
|
+
cargo_toml.write_bytes(original)
|
|
89
93
|
# cargo rewrites the lock to match the patched version during the build.
|
|
90
94
|
if lock_original is not None:
|
|
91
|
-
cargo_lock.
|
|
95
|
+
cargo_lock.write_bytes(lock_original)
|
|
92
96
|
|
|
93
97
|
|
|
94
98
|
def build_wheel(wheel_directory, config_settings=None, metadata_directory=None):
|
|
@@ -22,6 +22,20 @@ lines = [
|
|
|
22
22
|
"// Auto-generated by ggroups/generate_g_commands.py from",
|
|
23
23
|
"// python/nc_gcode_interpreter/ggroups.json - do not edit by hand.",
|
|
24
24
|
"",
|
|
25
|
+
"/// Canonical spelling of a G word: uppercase, and numbered codes lose",
|
|
26
|
+
"/// their leading zeros (g001 -> G1, manual 3.2.2.1). Keywords only change case.",
|
|
27
|
+
"pub fn normalize_g_command(word: &str) -> String {",
|
|
28
|
+
" let mut code = word.to_ascii_uppercase();",
|
|
29
|
+
" if let Some(digits) = code.strip_prefix('G') {",
|
|
30
|
+
" if !digits.is_empty() && digits.bytes().all(|b| b.is_ascii_digit()) {",
|
|
31
|
+
" let zeros = digits.bytes().take_while(|&b| b == b'0').count();",
|
|
32
|
+
" let remove = zeros.min(digits.len() - 1);",
|
|
33
|
+
" code.drain(1..1 + remove);",
|
|
34
|
+
" }",
|
|
35
|
+
" }",
|
|
36
|
+
" code",
|
|
37
|
+
"}",
|
|
38
|
+
"",
|
|
25
39
|
"/// Classify an (uppercased) G-command word: the G-group column it",
|
|
26
40
|
"/// belongs to, and whether that group is modal. `None` means the word",
|
|
27
41
|
"/// is not a known G command.",
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"""The in-tree build backend stamps Cargo.toml and restores both Cargo files byte for byte."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import importlib.util
|
|
6
|
+
import sys
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
|
|
9
|
+
import pytest
|
|
10
|
+
|
|
11
|
+
BACKEND = Path(__file__).resolve().parents[2] / "build_backend" / "nc_build_backend.py"
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
@pytest.fixture()
|
|
15
|
+
def backend(tmp_path, monkeypatch):
|
|
16
|
+
pytest.importorskip("maturin")
|
|
17
|
+
spec = importlib.util.spec_from_file_location("_test_nc_build_backend", BACKEND)
|
|
18
|
+
module = importlib.util.module_from_spec(spec)
|
|
19
|
+
monkeypatch.setitem(sys.modules, spec.name, module)
|
|
20
|
+
spec.loader.exec_module(module)
|
|
21
|
+
monkeypatch.setattr(module, "_git_version", lambda root: "0.4.0-dev.1+gabc1234")
|
|
22
|
+
# The backend resolves its root from __file__; point it at the scratch tree.
|
|
23
|
+
(tmp_path / "build_backend").mkdir()
|
|
24
|
+
monkeypatch.setattr(module, "__file__", str(tmp_path / "build_backend" / "x.py"))
|
|
25
|
+
return module
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
@pytest.mark.parametrize("eol", [b"\n", b"\r\n"], ids=["lf", "crlf"])
|
|
29
|
+
def test_stamp_and_byte_exact_restore(backend, tmp_path, eol):
|
|
30
|
+
toml = eol.join([b"[package]", b'name = "x"', b'version = "0.0.0-dev"', b""])
|
|
31
|
+
lock = eol.join([b'name = "x"', b'version = "0.0.0-dev"', b""])
|
|
32
|
+
# Bytes, not text: write_text would emit CRLF on Windows and mask the bug under test.
|
|
33
|
+
(tmp_path / "Cargo.toml").write_bytes(toml)
|
|
34
|
+
(tmp_path / "Cargo.lock").write_bytes(lock)
|
|
35
|
+
with backend._versioned_cargo_toml():
|
|
36
|
+
assert b'version = "0.4.0-dev.1+gabc1234"' + eol in (tmp_path / "Cargo.toml").read_bytes()
|
|
37
|
+
(tmp_path / "Cargo.lock").write_bytes(b"rewritten by cargo")
|
|
38
|
+
assert (tmp_path / "Cargo.toml").read_bytes() == toml
|
|
39
|
+
assert (tmp_path / "Cargo.lock").read_bytes() == lock
|
|
@@ -93,14 +93,38 @@ def test_rows_keep_plain_strings():
|
|
|
93
93
|
|
|
94
94
|
|
|
95
95
|
def test_unknown_g_command_is_a_loud_error():
|
|
96
|
-
with pytest.raises(NcError, match="
|
|
97
|
-
nc_to_dataframe("
|
|
96
|
+
with pytest.raises(NcError, match="G09999") as info:
|
|
97
|
+
nc_to_dataframe("G09999 X1\n")
|
|
98
98
|
assert info.value.kind == "unknown_g_command"
|
|
99
|
-
|
|
100
|
-
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
def test_start_g_groups_accept_padded_codes_as_canonical_values():
|
|
102
|
+
start = {"g_groups": {"gg01_motion": "g01", "gg06_plane_select": "G018"}, "feed": 100.0}
|
|
103
|
+
df, _ = nc_to_dataframe("X1\n", start=start)
|
|
104
|
+
_assert_g_group_dtypes(df)
|
|
105
|
+
assert df["gg01_motion"].to_list() == ["G1"]
|
|
106
|
+
assert df["gg06_plane_select"].to_list() == ["G18"]
|
|
107
|
+
with pytest.raises(NcError, match="G9999") as info:
|
|
108
|
+
nc_to_dataframe("X1\n", start={"g_groups": {"gg01_motion": "G09999"}})
|
|
101
109
|
assert info.value.kind == "invalid_input"
|
|
102
110
|
|
|
103
111
|
|
|
112
|
+
@pytest.mark.parametrize("stage1,min_bytes", [("0", "0"), ("1", "0"), ("1", str(2**63))])
|
|
113
|
+
def test_padded_g_codes_reach_python_as_canonical_values(monkeypatch, stage1, min_bytes):
|
|
114
|
+
monkeypatch.setenv("NC_STAGE1", stage1)
|
|
115
|
+
monkeypatch.setenv("NC_STREAM_MIN_BYTES", min_bytes)
|
|
116
|
+
program = "G00 X.5 M03\ng001 F+100 X+.75 m005 M0\n"
|
|
117
|
+
df, _ = nc_to_dataframe(program)
|
|
118
|
+
frames = list(nc_to_batches(program, batch_size=1))
|
|
119
|
+
for frame in [df, *frames]:
|
|
120
|
+
_assert_g_group_dtypes(frame)
|
|
121
|
+
assert df["gg01_motion"].to_list() == ["G0", "G1"]
|
|
122
|
+
assert df["X"].to_list() == [0.5, 0.75]
|
|
123
|
+
assert_frame_equal(pl.concat(frames, how="diagonal").select(df.columns), df)
|
|
124
|
+
assert df["M"].to_list() == [["M3"], ["M5", "M0"]]
|
|
125
|
+
assert [row["gg01_motion"] for _, row in nc_to_rows(program)] == ["G0", "G1"]
|
|
126
|
+
|
|
127
|
+
|
|
104
128
|
@pytest.mark.parametrize("batch_size", [1, 2, 500_000])
|
|
105
129
|
def test_g_groups_seeded_from_start_have_the_enum_dtype_of_later_rows(batch_size):
|
|
106
130
|
start = {"g_groups": {"gg01_motion": "G1", "gg06_plane_select": "G18"}, "feed": 100.0}
|
|
@@ -225,9 +225,10 @@ assignment_multi = { variable_array ~ "=" ~ (value_array | value_repeating) }
|
|
|
225
225
|
value_array = { "SET" ~ "(" ~ (expression | value_none) ~ ("," ~ (expression | value_none))* ~ ")" }
|
|
226
226
|
value_repeating = { "REP" ~ "(" ~ expression ~ ("," ~ expression)? ~ ")" }
|
|
227
227
|
value_none = { "" }
|
|
228
|
-
// Atomic: the interpreter only reads the full lexeme (as_str)
|
|
229
|
-
//
|
|
230
|
-
|
|
228
|
+
// Atomic: the interpreter only reads the full lexeme (as_str). Siemens
|
|
229
|
+
// accepts X.5, Z-.5 and an explicit positive sign; at least one digit is
|
|
230
|
+
// required, on either side of the decimal point. Keep block numbers separate.
|
|
231
|
+
value = @{ ("+" | "-")? ~ (ASCII_DIGIT+ ~ ("." ~ ASCII_DIGIT*)? | "." ~ ASCII_DIGIT+) ~ !ASCII_ALPHA }
|
|
231
232
|
op = _{
|
|
232
233
|
op_add | op_sub | op_mul | op_div | op_int_div | op_mod
|
|
233
234
|
| op_b_and | op_b_xor | op_b_or
|
|
@@ -259,7 +260,6 @@ neg = { "-" }
|
|
|
259
260
|
not_op = @{ ^"NOT" ~ !(ASCII_ALPHANUMERIC | "_") }
|
|
260
261
|
// A quoted string is an operand only of == and <> (manual 4.1.3.2).
|
|
261
262
|
primary = { arith_fun | value | string_value | variable_array | variable | "(" ~ expression ~ ")" }
|
|
262
|
-
float = @{ "-"? ~ ASCII_DIGIT+ ~ "." ~ ASCII_DIGIT* ~ !ASCII_ALPHA } // Ensure floats are not followed by letters
|
|
263
263
|
integer = @{ "-"? ~ ASCII_DIGIT+ ~ !ASCII_ALPHA } // Ensure integers are not followed by letters
|
|
264
264
|
// Any call-shaped name is accepted here; the interpreter dispatches on the
|
|
265
265
|
// (case-insensitive) name and rejects unknown functions with line context.
|
|
@@ -821,16 +821,15 @@ fn evaluate_unary(pairs: &[Pair<Rule>], pos: &mut usize, state: &mut State) -> R
|
|
|
821
821
|
}
|
|
822
822
|
/// Classify a lexically G-shaped command (`G<digits>` or `GFRAME[<n>]`)
|
|
823
823
|
/// against the vocabulary table: the column key is the G-group name, the
|
|
824
|
-
/// value the command
|
|
824
|
+
/// value the canonical command. An unknown G number is a hard error, like
|
|
825
825
|
/// alarm 12470 "undefined G function" on a real control.
|
|
826
826
|
fn interpret_g_command(g_command: Pair<Rule>, state: &mut State) -> Result<(&'static str, String), ParsingError> {
|
|
827
827
|
let command_str = g_command.as_str().trim().to_string();
|
|
828
|
-
//
|
|
829
|
-
//
|
|
830
|
-
|
|
831
|
-
match crate::modal_groups::classify_g_command(&
|
|
828
|
+
// Normalize both case and padding: downstream frame/curve handling
|
|
829
|
+
// compares canonical codes, so g02 and G018 must become G2 and G18.
|
|
830
|
+
let code = crate::modal_groups::normalize_g_command(&command_str);
|
|
831
|
+
match crate::modal_groups::classify_g_command(&code) {
|
|
832
832
|
Some((group, modal)) => {
|
|
833
|
-
let code = command_str.to_uppercase();
|
|
834
833
|
// The frame model needs the active plane for RPL and the arc check.
|
|
835
834
|
if group == "gg06_plane_select" {
|
|
836
835
|
state.set_plane(&code);
|
|
@@ -3497,6 +3496,19 @@ fn interpret_control(element: Pair<Rule>, output: &mut Output, state: &mut State
|
|
|
3497
3496
|
}
|
|
3498
3497
|
Ok(BlockFlow::Continue)
|
|
3499
3498
|
}
|
|
3499
|
+
/// Canonical spelling of an M word: uppercase (m30 IS M30) and without
|
|
3500
|
+
/// leading zeros (M03 IS M3, manual 3.2.2.1), so output values compare equal.
|
|
3501
|
+
pub(crate) fn normalize_m_command(word: &str) -> String {
|
|
3502
|
+
let mut code = word.to_ascii_uppercase();
|
|
3503
|
+
if let Some(digits) = code.strip_prefix('M') {
|
|
3504
|
+
if !digits.is_empty() && digits.bytes().all(|b| b.is_ascii_digit()) {
|
|
3505
|
+
let zeros = digits.bytes().take_while(|&b| b == b'0').count();
|
|
3506
|
+
code.drain(1..1 + zeros.min(digits.len() - 1));
|
|
3507
|
+
}
|
|
3508
|
+
}
|
|
3509
|
+
code
|
|
3510
|
+
}
|
|
3511
|
+
|
|
3500
3512
|
pub(crate) fn insert_m_key(
|
|
3501
3513
|
last: &mut crate::output::CellMap,
|
|
3502
3514
|
value: &str,
|
|
@@ -3504,9 +3516,7 @@ pub(crate) fn insert_m_key(
|
|
|
3504
3516
|
preview: String,
|
|
3505
3517
|
) -> Result<(), ParsingError> {
|
|
3506
3518
|
let m_key = "M";
|
|
3507
|
-
|
|
3508
|
-
// must not leak into the output values.
|
|
3509
|
-
let value = value.to_uppercase();
|
|
3519
|
+
let value = normalize_m_command(value);
|
|
3510
3520
|
for _i in 1..=5 {
|
|
3511
3521
|
if let Some(existing_value) = last.get_mut(m_key) {
|
|
3512
3522
|
// If the key already exists and is a list, append the new value
|
|
@@ -550,7 +550,7 @@ fn describe_rule(rule: Rule) -> &'static str {
|
|
|
550
550
|
Rule::assignment_multi => "an array assignment (SET/REP)",
|
|
551
551
|
Rule::axis_increment => "an incremental value IC(...)",
|
|
552
552
|
Rule::expression | Rule::primary => "an expression",
|
|
553
|
-
Rule::value | Rule::
|
|
553
|
+
Rule::value | Rule::integer => "a number",
|
|
554
554
|
Rule::identifier | Rule::variable => "a name",
|
|
555
555
|
Rule::variable_array => "an array element",
|
|
556
556
|
Rule::indices => "array indices",
|
|
@@ -26,7 +26,7 @@ use crate::interpret_rules::{
|
|
|
26
26
|
canonical_block_number, insert_m_key, interpret_block, is_end_of_program_m_code, resolve_jump, scan_jump_targets,
|
|
27
27
|
BlockFlow,
|
|
28
28
|
};
|
|
29
|
-
use crate::modal_groups::classify_g_command;
|
|
29
|
+
use crate::modal_groups::{classify_g_command, normalize_g_command};
|
|
30
30
|
use crate::state::{ColKind, State};
|
|
31
31
|
use crate::types::{NCParser, Pair, Rule, Value};
|
|
32
32
|
use pest::Parser;
|
|
@@ -775,8 +775,8 @@ fn execute_decoded(
|
|
|
775
775
|
last.insert("non_returning_function_call", Value::Str(value.to_string()));
|
|
776
776
|
}
|
|
777
777
|
Word::GCommand(group, as_written) => {
|
|
778
|
-
//
|
|
779
|
-
let code = as_written
|
|
778
|
+
// Canonical spelling like the grammar path: g02 IS G2.
|
|
779
|
+
let code = normalize_g_command(as_written);
|
|
780
780
|
// The plane feeds the frame model, exactly as interpret_g_command does.
|
|
781
781
|
if *group == "gg06_plane_select" {
|
|
782
782
|
state.set_plane(&code);
|
|
@@ -867,26 +867,31 @@ enum DecodeResult<'a> {
|
|
|
867
867
|
}
|
|
868
868
|
|
|
869
869
|
/// Parse a single numeric literal (`value` in the grammar: optional sign,
|
|
870
|
-
/// digits
|
|
871
|
-
/// a second dot, or letter/underscore tails
|
|
870
|
+
/// digits with an optional decimal point, including .5) at `*i`, advancing
|
|
871
|
+
/// past it. Rejects exponents, a second dot, or letter/underscore tails;
|
|
872
|
+
/// those need the real grammar.
|
|
872
873
|
fn parse_number(line: &str, i: &mut usize) -> Option<f64> {
|
|
873
874
|
let bytes = line.as_bytes();
|
|
874
875
|
let start = *i;
|
|
875
|
-
if *i < bytes.len() && bytes[*i]
|
|
876
|
+
if *i < bytes.len() && matches!(bytes[*i], b'+' | b'-') {
|
|
876
877
|
*i += 1;
|
|
877
878
|
}
|
|
878
879
|
let digits_start = *i;
|
|
879
880
|
while *i < bytes.len() && bytes[*i].is_ascii_digit() {
|
|
880
881
|
*i += 1;
|
|
881
882
|
}
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
}
|
|
883
|
+
let integer_digits = *i - digits_start;
|
|
884
|
+
let mut fraction_digits = 0;
|
|
885
885
|
if *i < bytes.len() && bytes[*i] == b'.' {
|
|
886
886
|
*i += 1;
|
|
887
|
+
let fraction_start = *i;
|
|
887
888
|
while *i < bytes.len() && bytes[*i].is_ascii_digit() {
|
|
888
889
|
*i += 1;
|
|
889
890
|
}
|
|
891
|
+
fraction_digits = *i - fraction_start;
|
|
892
|
+
}
|
|
893
|
+
if integer_digits + fraction_digits == 0 {
|
|
894
|
+
return None;
|
|
890
895
|
}
|
|
891
896
|
// Exponents, a second dot, or letter tails need the real grammar.
|
|
892
897
|
if *i < bytes.len() && (bytes[*i].is_ascii_alphabetic() || bytes[*i] == b'_' || bytes[*i] == b'.') {
|
|
@@ -1172,7 +1177,7 @@ fn decode_line_inner<'a>(
|
|
|
1172
1177
|
}
|
|
1173
1178
|
let word_start = i;
|
|
1174
1179
|
i += 1;
|
|
1175
|
-
let bare_number_follows = i < n_len && (bytes[i].is_ascii_digit() || bytes[i]
|
|
1180
|
+
let bare_number_follows = i < n_len && (bytes[i].is_ascii_digit() || matches!(bytes[i], b'+' | b'-' | b'.'));
|
|
1176
1181
|
// The grammar's bare-word forms are all case-insensitive: M/G
|
|
1177
1182
|
// addresses and variable_single_char (axis letters) alike.
|
|
1178
1183
|
if bare_number_follows && bytes[word_start].is_ascii_alphabetic() {
|
|
@@ -1192,7 +1197,7 @@ fn decode_line_inner<'a>(
|
|
|
1192
1197
|
if letter == b'M' {
|
|
1193
1198
|
arena.push(Word::MCode(code));
|
|
1194
1199
|
} else {
|
|
1195
|
-
match classify_g_command(&code
|
|
1200
|
+
match classify_g_command(&normalize_g_command(code)) {
|
|
1196
1201
|
Some((group, _modal)) => arena.push(Word::GCommand(group, code)),
|
|
1197
1202
|
// Unknown G code: let the full path produce its error.
|
|
1198
1203
|
None => return DecodeResult::NeedsGrammar,
|
|
@@ -1912,7 +1917,7 @@ M30
|
|
|
1912
1917
|
"N10", "N", "10", "X5", "X", "Y1", "=", "5", "-3", "2.5", ".5", "AND", "OR", "XOR", "B_AND", "B_OR",
|
|
1913
1918
|
"B_XOR", "DIV", "MOD", "NOT", "TRANS", "ROT", "SCALE", "MIRROR", "RPL", "DEF", "IC(2)", "(3*R1)", "(", ")",
|
|
1914
1919
|
"*", "+", "/", "LBL:", ";c", "G1", "M3", "R1", "_V", "SIN(30)", "E", "F100", "IF", "GOTOF", "X1=", "T",
|
|
1915
|
-
"\"s\"", "[", ",", "<", "x5", "n10", "SET", "$P",
|
|
1920
|
+
"\"s\"", "[", ",", "<", "x5", "n10", "SET", "$P", "G01", "g003", "M03", "+.5", "1.", "-.",
|
|
1916
1921
|
];
|
|
1917
1922
|
let mut seed: u64 = 0x9E37_79B9_7F4A_7C15;
|
|
1918
1923
|
let mut next = |bound: usize| {
|
|
@@ -1,6 +1,20 @@
|
|
|
1
1
|
// Auto-generated by ggroups/generate_g_commands.py from
|
|
2
2
|
// python/nc_gcode_interpreter/ggroups.json - do not edit by hand.
|
|
3
3
|
|
|
4
|
+
/// Canonical spelling of a G word: uppercase, and numbered codes lose
|
|
5
|
+
/// their leading zeros (g001 -> G1, manual 3.2.2.1). Keywords only change case.
|
|
6
|
+
pub fn normalize_g_command(word: &str) -> String {
|
|
7
|
+
let mut code = word.to_ascii_uppercase();
|
|
8
|
+
if let Some(digits) = code.strip_prefix('G') {
|
|
9
|
+
if !digits.is_empty() && digits.bytes().all(|b| b.is_ascii_digit()) {
|
|
10
|
+
let zeros = digits.bytes().take_while(|&b| b == b'0').count();
|
|
11
|
+
let remove = zeros.min(digits.len() - 1);
|
|
12
|
+
code.drain(1..1 + remove);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
code
|
|
16
|
+
}
|
|
17
|
+
|
|
4
18
|
/// Classify an (uppercased) G-command word: the G-group column it
|
|
5
19
|
/// belongs to, and whether that group is modal. `None` means the word
|
|
6
20
|
/// is not a known G command.
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
|
|
15
15
|
use crate::errors::ParsingError;
|
|
16
16
|
use crate::frame::{self, Matrix3};
|
|
17
|
-
use crate::modal_groups::{classify_g_command, MODAL_G_GROUPS, NON_MODAL_G_GROUPS};
|
|
17
|
+
use crate::modal_groups::{classify_g_command, normalize_g_command, MODAL_G_GROUPS, NON_MODAL_G_GROUPS};
|
|
18
18
|
use crate::output::OutputRows;
|
|
19
19
|
use crate::state::{State, VarType};
|
|
20
20
|
use crate::types::{NCParser, Rule, Value};
|
|
@@ -521,7 +521,7 @@ fn modal_group(field: &str, group: &str, code: &str) -> Result<(&'static str, St
|
|
|
521
521
|
};
|
|
522
522
|
return Err(invalid(field, &reason));
|
|
523
523
|
};
|
|
524
|
-
let code = code.trim()
|
|
524
|
+
let code = normalize_g_command(code.trim());
|
|
525
525
|
match classify_g_command(&code) {
|
|
526
526
|
Some((found, _)) if found == column => Ok((column, code)),
|
|
527
527
|
Some((found, _)) => Err(invalid(field, &format!("{code} belongs to {found}, not to {column}"))),
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
//! Documented Siemens spellings must have the same meaning in the whole-file,
|
|
2
|
+
//! streaming and indexed parsers. Subprocesses isolate the parser environment.
|
|
3
|
+
use std::path::PathBuf;
|
|
4
|
+
use std::process::{Command, Output};
|
|
5
|
+
use std::sync::atomic::{AtomicUsize, Ordering};
|
|
6
|
+
|
|
7
|
+
struct Fixture(PathBuf);
|
|
8
|
+
|
|
9
|
+
impl Fixture {
|
|
10
|
+
fn new() -> Self {
|
|
11
|
+
static NEXT: AtomicUsize = AtomicUsize::new(0);
|
|
12
|
+
let path = std::env::temp_dir().join(format!(
|
|
13
|
+
"nc-syntax-{}-{}",
|
|
14
|
+
std::process::id(),
|
|
15
|
+
NEXT.fetch_add(1, Ordering::Relaxed)
|
|
16
|
+
));
|
|
17
|
+
std::fs::create_dir_all(&path).unwrap();
|
|
18
|
+
Self(path)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
fn run(&self, source: &str, mode: &str, flatten: bool) -> Output {
|
|
22
|
+
let input = self.0.join("program.mpf");
|
|
23
|
+
std::fs::write(&input, source).unwrap();
|
|
24
|
+
let mut command = Command::new(env!("CARGO_BIN_EXE_nc-gcode-interpreter"));
|
|
25
|
+
command
|
|
26
|
+
.arg(input)
|
|
27
|
+
.env("NC_STAGE1", if mode == "whole-file" { "0" } else { "1" })
|
|
28
|
+
.env(
|
|
29
|
+
"NC_STREAM_MIN_BYTES",
|
|
30
|
+
if mode == "indexed" { "18446744073709551615" } else { "0" },
|
|
31
|
+
);
|
|
32
|
+
if flatten {
|
|
33
|
+
command.args(["--flatten-tolerance", "0.01"]);
|
|
34
|
+
}
|
|
35
|
+
command.output().unwrap()
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
fn csv(&self, source: &str, mode: &str, flatten: bool) -> String {
|
|
39
|
+
let output = self.run(source, mode, flatten);
|
|
40
|
+
assert!(
|
|
41
|
+
output.status.success(),
|
|
42
|
+
"{mode}: {source}\n{}",
|
|
43
|
+
String::from_utf8_lossy(&output.stderr)
|
|
44
|
+
);
|
|
45
|
+
std::fs::read_to_string(self.0.join("program.csv")).unwrap()
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
impl Drop for Fixture {
|
|
50
|
+
fn drop(&mut self) {
|
|
51
|
+
let _ = std::fs::remove_dir_all(&self.0);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const MODES: [&str; 3] = ["whole-file", "streaming", "indexed"];
|
|
56
|
+
|
|
57
|
+
#[test]
|
|
58
|
+
fn signed_and_leading_dot_literals_match_existing_spelling() {
|
|
59
|
+
let source = "G0 X.5 Y-.25 Z+0.5\nF+100\nG1 X+.75 Y1. Z-.125\n\
|
|
60
|
+
R1=+.25*+2-.125\nX=R1\nX=IC(+.375)\n\
|
|
61
|
+
TRANS X+.5 Y-.25\nG1 X.5 Y+.25\nX=IC(.25)\n\
|
|
62
|
+
MULT=+2\nE=0\nE=IC(MULT*+.125)\nX=(+.5*MULT)\n\
|
|
63
|
+
DEF REAL DEPTH=+.5\nZ=DEPTH\nY=ABS(-.125)+.5\n";
|
|
64
|
+
let canonical = "G0 X0.5 Y-0.25 Z0.5\nF100\nG1 X0.75 Y1.0 Z-0.125\n\
|
|
65
|
+
R1=0.25*2-0.125\nX=R1\nX=IC(0.375)\n\
|
|
66
|
+
TRANS X0.5 Y-0.25\nG1 X0.5 Y0.25\nX=IC(0.25)\n\
|
|
67
|
+
MULT=2\nE=0\nE=IC(MULT*0.125)\nX=(0.5*MULT)\n\
|
|
68
|
+
DEF REAL DEPTH=0.5\nZ=DEPTH\nY=ABS(-0.125)+0.5\n";
|
|
69
|
+
let fixture = Fixture::new();
|
|
70
|
+
let expected = fixture.csv(canonical, "whole-file", false);
|
|
71
|
+
for mode in MODES {
|
|
72
|
+
assert_eq!(fixture.csv(source, mode, false), expected, "{mode}");
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
#[test]
|
|
77
|
+
fn padded_g_codes_match_canonical_output_and_flattening() {
|
|
78
|
+
let source = "G000 X0 Y0 Z0\nG017 G01 F100 X1 Y0\n\
|
|
79
|
+
g003 X0 Y1 I-1 J0\nG002 X1 Y0 I0 J-1\nG0001 X2\n";
|
|
80
|
+
let canonical = "G0 X0 Y0 Z0\nG17 G1 F100 X1 Y0\n\
|
|
81
|
+
G3 X0 Y1 I-1 J0\nG2 X1 Y0 I0 J-1\nG1 X2\n";
|
|
82
|
+
let fixture = Fixture::new();
|
|
83
|
+
for flatten in [false, true] {
|
|
84
|
+
let expected = fixture.csv(canonical, "whole-file", flatten);
|
|
85
|
+
if flatten {
|
|
86
|
+
assert!(expected.lines().count() > 6, "arcs must actually be flattened");
|
|
87
|
+
}
|
|
88
|
+
for mode in MODES {
|
|
89
|
+
assert_eq!(
|
|
90
|
+
fixture.csv(source, mode, flatten),
|
|
91
|
+
expected,
|
|
92
|
+
"{mode}, flatten={flatten}"
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
#[test]
|
|
99
|
+
fn padded_m_codes_match_canonical_output_and_end_the_program() {
|
|
100
|
+
let source = "G0 X1 M03 m008\nX2 M005 M0\nM030\nX3\n";
|
|
101
|
+
let canonical = "G0 X1 M3 M8\nX2 M5 M0\nM30\nX3\n";
|
|
102
|
+
let fixture = Fixture::new();
|
|
103
|
+
let expected = fixture.csv(canonical, "whole-file", false);
|
|
104
|
+
assert!(expected.ends_with(",M30\n"), "M30 must end the program:\n{expected}");
|
|
105
|
+
for mode in MODES {
|
|
106
|
+
assert_eq!(fixture.csv(source, mode, false), expected, "{mode}");
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
#[test]
|
|
111
|
+
fn padded_plane_codes_control_frame_rotation() {
|
|
112
|
+
let source = "G018\nROT RPL=90\nG000 X1 Y2 Z3\nG019\nROT RPL=90\nG000 X1 Y2 Z3\n";
|
|
113
|
+
let canonical = "G18\nROT RPL=90\nG0 X1 Y2 Z3\nG19\nROT RPL=90\nG0 X1 Y2 Z3\n";
|
|
114
|
+
let fixture = Fixture::new();
|
|
115
|
+
let expected = fixture.csv(canonical, "whole-file", false);
|
|
116
|
+
for mode in MODES {
|
|
117
|
+
assert_eq!(fixture.csv(source, mode, false), expected, "{mode}");
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
#[test]
|
|
122
|
+
fn malformed_literals_and_unknown_codes_still_fail() {
|
|
123
|
+
let fixture = Fixture::new();
|
|
124
|
+
for source in [
|
|
125
|
+
"G0 X.",
|
|
126
|
+
"G0 X+.",
|
|
127
|
+
"G0 X-.",
|
|
128
|
+
"G0 X+",
|
|
129
|
+
"G0 X+-1",
|
|
130
|
+
"G0 X++1",
|
|
131
|
+
"G0 X.5.6",
|
|
132
|
+
"G0 X1.2.3",
|
|
133
|
+
"G0 X=.",
|
|
134
|
+
"G0 X=+.",
|
|
135
|
+
"G0 X=1.2EX3",
|
|
136
|
+
"G00099999",
|
|
137
|
+
"G01.5 X1",
|
|
138
|
+
] {
|
|
139
|
+
for mode in MODES {
|
|
140
|
+
let output = fixture.run(source, mode, false);
|
|
141
|
+
assert!(!output.status.success(), "accepted {source:?} in {mode}");
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
#[test]
|
|
147
|
+
fn padded_looking_identifiers_remain_variables() {
|
|
148
|
+
let source = "DEF REAL G01_OFFSET=+.5\nG0 X=G01_OFFSET\n";
|
|
149
|
+
let fixture = Fixture::new();
|
|
150
|
+
let expected = fixture.csv("DEF REAL G01_OFFSET=0.5\nG0 X=G01_OFFSET\n", "whole-file", false);
|
|
151
|
+
for mode in MODES {
|
|
152
|
+
assert_eq!(fixture.csv(source, mode, false), expected, "{mode}");
|
|
153
|
+
}
|
|
154
|
+
}
|
|
File without changes
|
{nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/.github/workflows/build-and-release.yml
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/docs/resumable-interpretation-design.md
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/examples/axis_index_assignment.csv
RENAMED
|
File without changes
|
{nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/examples/axis_index_assignment.mpf
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/examples/case_insensitive_variables.csv
RENAMED
|
File without changes
|
{nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/examples/case_insensitive_variables.mpf
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/examples/flattening/flatten_demo.mpf
RENAMED
|
File without changes
|
|
File without changes
|
{nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/examples/flattening/flatten_demo_raw.csv
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/python/nc_gcode_interpreter/__init__.py
RENAMED
|
File without changes
|
{nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/python/nc_gcode_interpreter/_internal.pyi
RENAMED
|
File without changes
|
{nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/python/nc_gcode_interpreter/cli.py
RENAMED
|
File without changes
|
{nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/python/nc_gcode_interpreter/ggroups.json
RENAMED
|
File without changes
|
{nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/python/nc_gcode_interpreter/py.typed
RENAMED
|
File without changes
|
{nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/python/nc_gcode_interpreter/viz.py
RENAMED
|
File without changes
|
|
File without changes
|
{nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/python/tests/test_arithmetic_functions.py
RENAMED
|
File without changes
|
{nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/python/tests/test_batch_variables.py
RENAMED
|
File without changes
|
|
File without changes
|
{nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/python/tests/test_compare_benchmarks.py
RENAMED
|
File without changes
|
|
File without changes
|
{nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/python/tests/test_expected_output.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/python/tests/test_field_defects.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/python/tests/test_real_comparisons.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/python/tests/test_string_operations.py
RENAMED
|
File without changes
|
{nc_gcode_interpreter-0.3.1 → nc_gcode_interpreter-0.3.2}/python/tests/test_structured_errors.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|