From 416b2c571f8c1c031eae3e2191964c3ae7b60635 Mon Sep 17 00:00:00 2001 From: PaddiM8 Date: Sat, 23 Mar 2024 01:57:45 +0100 Subject: [PATCH] Allow multi-character parameters --- kalk/src/analysis.rs | 7 +++++++ tests/functions.kalker | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/kalk/src/analysis.rs b/kalk/src/analysis.rs index 300fcb6..6a71b3f 100644 --- a/kalk/src/analysis.rs +++ b/kalk/src/analysis.rs @@ -484,6 +484,13 @@ fn analyse_var( with_adjacent(Expr::Var(identifier), adjacent_factor, adjacent_exponent) } else if context.symbol_table.contains_var(&identifier.pure_name) || (identifier.pure_name.len() == 1 && !context.in_equation) + || context.current_function_parameters.is_some() + && context + .current_function_parameters + .as_ref() + .unwrap() + .iter() + .any(|param| param[2..] == identifier.pure_name) { with_adjacent( build_var(context, &identifier.full_name), diff --git a/tests/functions.kalker b/tests/functions.kalker index 6628546..c4c4dd6 100644 --- a/tests/functions.kalker +++ b/tests/functions.kalker @@ -1,5 +1,5 @@ x = 3 f(x) = 2*x -g(x, y) = 2*x*y +g(x, long_name) = 2*x*long_name f(x) = 6 and fx = 6 and x = 3 and g(x, x + 1) = 24 and sqrt4 = 2 \ No newline at end of file