diff --git a/libwccl/ops/functions/bool/iterations/leftlook.cpp b/libwccl/ops/functions/bool/iterations/leftlook.cpp index 57cd4a8dd7d42e5d059b2bc2b73773d90625757d..c7f4d6965f96f56acd17bae8bccbe4eeb817afd7 100644 --- a/libwccl/ops/functions/bool/iterations/leftlook.cpp +++ b/libwccl/ops/functions/bool/iterations/leftlook.cpp @@ -8,7 +8,7 @@ bool LeftLook::iterate( Wccl::Position &p, const Wccl::FunExecContext &context) const { - for(int i = left; i <= right; ++i) { + for(int i = right; i >= left; ++i) { p.set_value(i); if(evaluating_expr_->apply(context)->get_value()) { return true; diff --git a/libwccl/ops/functions/bool/iterations/leftlook.h b/libwccl/ops/functions/bool/iterations/leftlook.h index 5c07a39c3c828e5d85c14810830ca375536e56cd..92e42dab29581b899b855639df708443495f9593 100644 --- a/libwccl/ops/functions/bool/iterations/leftlook.h +++ b/libwccl/ops/functions/bool/iterations/leftlook.h @@ -6,8 +6,9 @@ namespace Wccl { /** - * Iterative operator "llook", which looks for a first - * position from left that makes evaluating expression return true. + * Iterative operator "llook", which looks for the rightmost position + * in a range that makes the evaluating expression return true, i.e. + * it "looks to the left". */ class LeftLook : public Iteration { @@ -30,12 +31,12 @@ public: protected: /** - * @returns True if, when scanning from left, - * a position within range is found that makes + * @returns True if, when scanning right-to-left, + * a position within the range is found that makes * the evaluating function return true. False * otherwise. * @note Upon success, the iteration variable is - * set to the first position in range from left + * set to the rightmost position in range * that has made evaluation function return true * (that is the position that made the stop condition * true in this case). diff --git a/libwccl/ops/functions/bool/iterations/rightlook.cpp b/libwccl/ops/functions/bool/iterations/rightlook.cpp index 36bae48af8cdb939d6dcf8f48dc414a2b0805d30..70b4cdae1dc7fcbe03e4154d19df1cfbd0c29009 100644 --- a/libwccl/ops/functions/bool/iterations/rightlook.cpp +++ b/libwccl/ops/functions/bool/iterations/rightlook.cpp @@ -8,7 +8,7 @@ bool RightLook::iterate( Wccl::Position &p, const Wccl::FunExecContext &context) const { - for(int i = right; i >= left; --i) { + for(int i = left; i <= right; ++i) { p.set_value(i); if(evaluating_expr_->apply(context)->get_value()) { return true; diff --git a/libwccl/ops/functions/bool/iterations/rightlook.h b/libwccl/ops/functions/bool/iterations/rightlook.h index b39251affb8f3defb9c9b2d81c60c3dcf17518bc..dcc5e5fa722ef007c0a14e3d583d165f40f32a85 100644 --- a/libwccl/ops/functions/bool/iterations/rightlook.h +++ b/libwccl/ops/functions/bool/iterations/rightlook.h @@ -6,8 +6,9 @@ namespace Wccl { /** - * Iterative operator "rlook", which looks for a first - * position from right that makes evaluating expression return true. + * Iterative operator "rlook", which looks for the leftmost position + * in a range that makes the evaluating expression return true, i.e. + * it "looks to the right". */ class RightLook : public Iteration { @@ -30,12 +31,12 @@ public: protected: /** - * @returns True if, when scanning from right, - * a position within range is found that makes + * @returns True if, when scanning left-to-right, + * a position within the range is found that makes * the evaluating function return true. False * otherwise. * @note Upon success, the iteration variable is - * set to the first position in range from right + * set to the leftmost position in range * that has made evaluation function return true * (that is the position that made the stop condition * true in this case). diff --git a/libwccl/parser/grammar.g b/libwccl/parser/grammar.g index a4ac6c4a554ad3f4da89b82cacbb7a519c7d2f92..6763cbc738e37da48de45e7cfeaa2a6986af57bc 100644 --- a/libwccl/parser/grammar.g +++ b/libwccl/parser/grammar.g @@ -1078,9 +1078,9 @@ bool_iteration RPAREN { ret.reset(new AtLeast(lpos, rpos, *pacc, expr, min_match)); } - | "llook" LPAREN - lpos = position_operator [tagset, vars] COMMA + | "llook" LPAREN //note inverted rpos/lpos order rpos = position_operator [tagset, vars] COMMA + lpos = position_operator [tagset, vars] COMMA pacc = position_variable_acc [vars] COMMA expr = bool_operator [tagset, vars] RPAREN {