Added LEFT() expression function.

This commit is contained in:
Brad Arant committed 2024-10-01 07:41:05 -07:00
1 parent 8299aeaea9
commit fa711ddf86
3 files changed
+14 -5

No files matched your search

+11 -5
View File
@@ -11,16 +11,12 @@ namespace jet {
in.skipWhitespace();
// std::cout << "op: [" << in.unparsed() << "]" << std::endl;
if(in.ifNext("(")) {
// std::cout << "(" << in.unparsed() << std::endl;
Operand op(in);
string = op.string;
doubleValue = op.doubleValue;
if(!in.ifNext(")"))
throw coreutils::Exception("expected ) in expression.");
// std::cout << ")" << in.unparsed() << std::endl;
}
if(in.ifNext("SUBSTRING")) {
@@ -42,7 +38,17 @@ namespace jet {
else
throw coreutils::Exception("Expecting ) at end of substring expression.");
} else if(in.ifNext("LEFT")) {
if(!in.ifNext("("))
throw coreutils::Exception("Expecting ( for LEFT parameters.");
Operand parm1(in);
if(!in.ifNext(","))
throw coreutils::Exception("Expecting , in LEFT expression.");
Operand parm2(in);
if(in.ifNext(")")) {
string = parm1.string.substring(0, parm2.string.asInteger());
}
else
throw coreutils::Exception("Expecting ) at end of LEFT expression.");
} else if(in.ifNext("RIGHT")) {
} else if(in.ifNext("TRIM")) {