Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ static RE_INTERPOLATION: Lazy<Regex> =
static RE_MOVE_OR_FLASH: Lazy<Regex> = lazy_regex!(r"X?(-?[0-9]+)?Y?(-?[0-9]+)?D(0)?[2-3]*");
static RE_IMAGE_NAME: Lazy<Regex> = lazy_regex!(r"%IN(.*)\*%");
static RE_STEP_REPEAT: Lazy<Regex> =
lazy_regex!(r"%SRX([0-9]+)Y([0-9]+)I(\d+\.?\d*)J(\d+\.?\d*)\*%");
lazy_regex!(r"%SRX([0-9]+)Y([0-9]+)I(-?\d+\.?\d*)J(-?\d+\.?\d*)\*%");
static RE_MACRO_UNSIGNED_INTEGER: Lazy<Regex> =
lazy_regex!(r"^(?:(?P<value>[0-9]+)|(?P<variable>\$[0-9]+)|(?P<expression>.*))$");
static RE_MACRO_BOOLEAN: Lazy<Regex> =
Expand Down
19 changes: 17 additions & 2 deletions tests/component_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -780,7 +780,7 @@ fn test_load_scaling_zero() {
));
}

/// Test Step and Repeat command (%SR*%)
/// Test Step and Repeat command (%SR*%), including negative I/J offsets.
#[test]
fn step_and_repeat() {
// given
Expand All @@ -800,7 +800,11 @@ fn step_and_repeat() {
X-1000Y-30000D01*
%SR*%

M02*
%SRX12Y6I-3.33J-8.120*%
X0Y0D01*
%SR*%

M02*
",
);

Expand All @@ -825,6 +829,17 @@ fn step_and_repeat() {
Ok(Command::ExtendedCode(ExtendedCode::StepAndRepeat(
StepAndRepeat::Close
))),
Ok(Command::ExtendedCode(ExtendedCode::StepAndRepeat(
StepAndRepeat::Open {
repeat_x: 12,
repeat_y: 6,
distance_x: -3.33,
distance_y: -8.12,
}
))),
Ok(Command::ExtendedCode(ExtendedCode::StepAndRepeat(
StepAndRepeat::Close
))),
]
)
}
Expand Down
Loading