From 99ffdd4e6e07349011dd7df8cef0d444a149fbc3 Mon Sep 17 00:00:00 2001 From: Andrew Cowie Date: Sun, 22 Mar 2026 21:44:16 +1100 Subject: [PATCH] Fix parsing of expressions with multiple integral parameters --- examples/prototype/AirlockPowerdown.tq | 4 ++-- src/parsing/checks/parser.rs | 14 ++++++++++++++ src/parsing/parser.rs | 17 +++++++++++++++-- 3 files changed, 31 insertions(+), 4 deletions(-) diff --git a/examples/prototype/AirlockPowerdown.tq b/examples/prototype/AirlockPowerdown.tq index 852c0593..fab5e1d9 100644 --- a/examples/prototype/AirlockPowerdown.tq +++ b/examples/prototype/AirlockPowerdown.tq @@ -21,7 +21,7 @@ node1_htr_avail_16 : # Inhibiting Node 1 B HTRS (1 to 6) @pcs - { foreach node in seq(6) } + { foreach node in seq(1, 6) } 1. Check Availability 2. Perform { cmd("Inhibit") } 3. Check Availability @@ -32,7 +32,7 @@ node1_htr_avail_79 : # Inhibiting Node 1 B HTRS (7 to 9) @pcs - { foreach node in seq(9) } + { foreach node in seq(7, 9) } 1. Check Availability 2. Perform { cmd("Inhibit") } 3. Check Availability diff --git a/src/parsing/checks/parser.rs b/src/parsing/checks/parser.rs index c16ba147..409661df 100644 --- a/src/parsing/checks/parser.rs +++ b/src/parsing/checks/parser.rs @@ -1174,6 +1174,20 @@ echo "Done"```) }"#, })) ); + // Test function with multiple integer parameters + input.initialize("{ seq(1, 6) }"); + let result = input.read_code_block(); + assert_eq!( + result, + Ok(Expression::Execution(Function { + target: Identifier("seq"), + parameters: vec![ + Expression::Number(Numeric::Integral(1)), + Expression::Number(Numeric::Integral(6)) + ] + })) + ); + // Test function with decimal quantity parameter input.initialize("{ wait(2.5 s, \"yes\") }"); let result = input.read_code_block(); diff --git a/src/parsing/parser.rs b/src/parsing/parser.rs index 0be2a9a2..ec1cbd71 100644 --- a/src/parsing/parser.rs +++ b/src/parsing/parser.rs @@ -2433,9 +2433,22 @@ impl<'i> Parser<'i> { inner.parse_string_pieces(inner.source) })?; params.push(Expression::String(parts)); - } else if is_numeric(content) { - let numeric = outer.read_numeric()?; + } else if is_numeric_quantity(content) { + let numeric = outer.read_numeric_quantity()?; params.push(Expression::Number(numeric)); + } else if is_numeric_integral(content) + || content + .as_bytes() + .first() + .is_some_and(|b| b.is_ascii_digit()) + || content.starts_with('-') + && content + .as_bytes() + .get(1) + .is_some_and(|b| b.is_ascii_digit()) + { + let decimal = outer.read_decimal_part()?; + params.push(Expression::Number(Numeric::Integral(decimal.number))); } else { let name = outer.read_identifier()?; params.push(Expression::Variable(name));