From 5c703f562027ae820ec8805afaf23cf8f2897c9c Mon Sep 17 00:00:00 2001 From: Brad Arant Date: Wed, 26 Aug 2026 10:45:43 -0700 Subject: [PATCH] Implement reverse(str) and concat(a, b, ...) in the expr engine Both matched their function name but had empty branch bodies, silently producing nothing regardless of arguments. reverse(str) follows the same single-argument shape as trim/toupper/tolower; concat(a, b, ...) follows the same variadic comma-separated shape as max/min. reverse() converts to std::string and reverses in place via the already- imported (std::reverse), then assigns back through MString's std::string constructor. concat() starts from the first argument and appends each subsequent one via MString's own operator<<(ZString). Verified via real jet-2.0 runs: reverse('hello') -> "olleh", concat('a','b','c') -> "abc", concat('x','y') -> "xy". Full 9-script regression suite (custom tag scoping, dump tag tree, try/catch, if/else, keyword sigil) still passes unchanged. --- Operand.cpp | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/Operand.cpp b/Operand.cpp index 3d6f44e..ca4c94f 100644 --- a/Operand.cpp +++ b/Operand.cpp @@ -124,9 +124,26 @@ namespace jet { } else throw coreutils::Exception("Expecting ) at end of TOLOWER expression."); } else if(in.ifNextIgnoreCase("REVERSE")) { - + if(!in.ifNext("(")) + throw coreutils::Exception("Expecting ( for REVERSE parameters."); + Operand parm1(in, tag); + if(in.ifNext(")")) { + std::string reversed = parm1.string.str(); + std::reverse(reversed.begin(), reversed.end()); + string = reversed; + } else + throw coreutils::Exception("Expecting ) at end of REVERSE expression."); } else if(in.ifNextIgnoreCase("CONCAT")) { - + if(!in.ifNext("(")) + throw coreutils::Exception("Expecting ( for CONCAT parameters."); + Operand parm1(in, tag); + string = parm1.string; + while(in.ifNext(",")) { + Operand parm(in, tag); + string << parm.string; + } + if(!in.ifNext(")")) + throw coreutils::Exception("Expecting ) at end of CONCAT expression."); } else if(in.ifNextIgnoreCase("INTEGER")) { if(!in.ifNext("(")) throw coreutils::Exception("Expecting ( for INTEGER parameters.");