Skip to content
Snippets Groups Projects
Commit 5bd6b3cb authored by ilor's avatar ilor
Browse files

The design doc for llook/rlook was incorrect, swapping the semantics per the...

The design doc for llook/rlook was incorrect, swapping the semantics per the updated docs and swapping argument order for llook.
parent c0ea7d66
Branches
No related merge requests found
...@@ -8,7 +8,7 @@ bool LeftLook::iterate( ...@@ -8,7 +8,7 @@ bool LeftLook::iterate(
Wccl::Position &p, Wccl::Position &p,
const Wccl::FunExecContext &context) const const Wccl::FunExecContext &context) const
{ {
for(int i = left; i <= right; ++i) { for(int i = right; i >= left; ++i) {
p.set_value(i); p.set_value(i);
if(evaluating_expr_->apply(context)->get_value()) { if(evaluating_expr_->apply(context)->get_value()) {
return true; return true;
......
...@@ -6,8 +6,9 @@ ...@@ -6,8 +6,9 @@
namespace Wccl { namespace Wccl {
/** /**
* Iterative operator "llook", which looks for a first * Iterative operator "llook", which looks for the rightmost position
* position from left that makes evaluating expression return true. * in a range that makes the evaluating expression return true, i.e.
* it "looks to the left".
*/ */
class LeftLook : public Iteration class LeftLook : public Iteration
{ {
...@@ -30,12 +31,12 @@ public: ...@@ -30,12 +31,12 @@ public:
protected: protected:
/** /**
* @returns True if, when scanning from left, * @returns True if, when scanning right-to-left,
* a position within range is found that makes * a position within the range is found that makes
* the evaluating function return true. False * the evaluating function return true. False
* otherwise. * otherwise.
* @note Upon success, the iteration variable is * @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 has made evaluation function return true
* (that is the position that made the stop condition * (that is the position that made the stop condition
* true in this case). * true in this case).
......
...@@ -8,7 +8,7 @@ bool RightLook::iterate( ...@@ -8,7 +8,7 @@ bool RightLook::iterate(
Wccl::Position &p, Wccl::Position &p,
const Wccl::FunExecContext &context) const const Wccl::FunExecContext &context) const
{ {
for(int i = right; i >= left; --i) { for(int i = left; i <= right; ++i) {
p.set_value(i); p.set_value(i);
if(evaluating_expr_->apply(context)->get_value()) { if(evaluating_expr_->apply(context)->get_value()) {
return true; return true;
......
...@@ -6,8 +6,9 @@ ...@@ -6,8 +6,9 @@
namespace Wccl { namespace Wccl {
/** /**
* Iterative operator "rlook", which looks for a first * Iterative operator "rlook", which looks for the leftmost position
* position from right that makes evaluating expression return true. * in a range that makes the evaluating expression return true, i.e.
* it "looks to the right".
*/ */
class RightLook : public Iteration class RightLook : public Iteration
{ {
...@@ -30,12 +31,12 @@ public: ...@@ -30,12 +31,12 @@ public:
protected: protected:
/** /**
* @returns True if, when scanning from right, * @returns True if, when scanning left-to-right,
* a position within range is found that makes * a position within the range is found that makes
* the evaluating function return true. False * the evaluating function return true. False
* otherwise. * otherwise.
* @note Upon success, the iteration variable is * @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 has made evaluation function return true
* (that is the position that made the stop condition * (that is the position that made the stop condition
* true in this case). * true in this case).
......
...@@ -1078,9 +1078,9 @@ bool_iteration ...@@ -1078,9 +1078,9 @@ bool_iteration
RPAREN { RPAREN {
ret.reset(new AtLeast(lpos, rpos, *pacc, expr, min_match)); ret.reset(new AtLeast(lpos, rpos, *pacc, expr, min_match));
} }
| "llook" LPAREN | "llook" LPAREN //note inverted rpos/lpos order
lpos = position_operator [tagset, vars] COMMA
rpos = position_operator [tagset, vars] COMMA rpos = position_operator [tagset, vars] COMMA
lpos = position_operator [tagset, vars] COMMA
pacc = position_variable_acc [vars] COMMA pacc = position_variable_acc [vars] COMMA
expr = bool_operator [tagset, vars] expr = bool_operator [tagset, vars]
RPAREN { RPAREN {
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment