improved syntax checking on expr. Laid foundation for expr function.

This commit is contained in:
Brad Arant committed 2024-11-18 10:19:39 -08:00
1 parent 839f7e2eb8
commit c39220d39c
3 files changed
+20 -5

No files matched your search

+12 -3
View File
@@ -53,7 +53,16 @@ namespace jet {
} else } else
throw coreutils::Exception("Expecting ) at end of LEFT expression."); throw coreutils::Exception("Expecting ) at end of LEFT expression.");
} else if(in.ifNextIgnoreCase("EXPR")) { } else if(in.ifNextIgnoreCase("EXPR")) {
if(!in.ifNext("("))
throw coreutils::Exception("Expecting ( for LEFT parameters.");
Operand parm1(in, global, lvariables);
if(in.ifNext(")")) {
Operand op(in, global, lvariables);
string = op.string;
isNumber = op.isNumber;
boolean = op.boolean;
} else
throw coreutils::Exception("Expecting ) at end of EXPR expression.");
} else if(in.ifNextIgnoreCase("RIGHT")) { } else if(in.ifNextIgnoreCase("RIGHT")) {
} else if(in.ifNextIgnoreCase("TRIM")) { } else if(in.ifNextIgnoreCase("TRIM")) {
@@ -90,7 +99,8 @@ namespace jet {
string = in.getTokenExclude("'"); string = in.getTokenExclude("'");
in.ifNext("'"); in.ifNext("'");
isNumber = false; isNumber = false;
} } else
throw coreutils::Exception("operand is not valid.");
in.skipWhitespace(); in.skipWhitespace();
@@ -284,7 +294,6 @@ namespace jet {
throw coreutils::Exception("operand is not a number."); throw coreutils::Exception("operand is not a number.");
} else } else
return; return;
} }
} }
+6
View File
@@ -0,0 +1,6 @@
#!../jet-2.0
<jet name1="localname" filterblanklines="true" trimlines="true">
<set name="test1" value="5 + 5" />
<set name="test2" expr="expr($[test1])" />
$[test2]
</jet>
+2 -2
View File
@@ -1,8 +1,8 @@
#!../jet-2.0 #!../jet-2.0
<jet cgi="false" name1="localname" filterblanklines="true" trimlines="true"> <jet cgi="false" name1="localname" filterblanklines="true" trimlines="true">
<set name="ix" value="1" /> <set name="ix" value="1" />
<while expr="$[ix]<=11"> <while expr="$[ix] <= 11">
-->$[ix]<-- -->$[ix]<--
<set name="ix" expr="$[ix]+1" /> <set name="ix" expr="$[ix] + 1" />
</while> </while>
</jet> </jet>