KCL: End-exclusive ranges like [0..<10] (#7179)

Closes https://github.com/KittyCAD/modeling-app/issues/6843

To clarify:
`[1..10]` is 1, 2, ..., 8, 9, 10
`[1..<10]` is 1, 2, ... 8, 9
This commit is contained in:
Adam Chalmers
2025-05-22 22:13:27 -05:00
committed by GitHub
parent fa4b3cfd1b
commit d0958220fe
5 changed files with 155 additions and 5 deletions

View File

@ -87,7 +87,7 @@ pub(super) fn token(i: &mut Input<'_>) -> PResult<Token> {
'0'..='9' => number,
';' => semi_colon,
':' => alt((double_colon, colon)),
'.' => alt((number, double_period, period)),
'.' => alt((number, double_period_less_than, double_period, period)),
'#' => hash,
'$' => dollar,
'!' => alt((operator, bang)),
@ -320,6 +320,16 @@ fn double_period(i: &mut Input<'_>) -> PResult<Token> {
))
}
fn double_period_less_than(i: &mut Input<'_>) -> PResult<Token> {
let (value, range) = "..<".with_span().parse_next(i)?;
Ok(Token::from_range(
range,
i.state.module_id,
TokenType::DoublePeriodLessThan,
value.to_string(),
))
}
/// Zero or more of either:
/// 1. Any character except " or \
/// 2. Any character preceded by \