diff --git a/Operand.cpp b/Operand.cpp index 299d391..7cea175 100644 --- a/Operand.cpp +++ b/Operand.cpp @@ -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")) { diff --git a/jet-2.0 b/jet-2.0 index d74ce3d..fa7a3d7 100755 Binary files a/jet-2.0 and b/jet-2.0 differ diff --git a/testjet.jet b/testjet.jet index d09c36b..7ec6322 100755 --- a/testjet.jet +++ b/testjet.jet @@ -21,6 +21,9 @@ $[nested] + 0123456789 + + lefty=[$[lefty]] substring('abcdefg', 1, 3)=[$[theexpr]] 5+3=($[addition]) 5-3($[subtraction])