Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
A couple more steps toward nrx
  • Loading branch information
sorear committed Sep 1, 2010
1 parent 33f66ad commit cd6e7c1
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 9 deletions.
30 changes: 22 additions & 8 deletions lib/Cursor.cs
Expand Up @@ -113,19 +113,17 @@ public struct State {
}
}

public Frame Exact(Frame th, string st) {
public bool Exact(string st) {
if (bt.obj.pos + st.Length > end)
return Backtrack(th);
return false;
foreach (char ch in st)
if (orig[bt.obj.pos++] != ch)
return Backtrack(th);
return th;
return false;
return true;
}

public Frame ExactOne(Frame th, char ch) {
if (bt.obj.pos == end || orig[bt.obj.pos++] != ch)
return Backtrack(th);
return th;
public bool ExactOne(char ch) {
return !(bt.obj.pos == end || orig[bt.obj.pos++] != ch);
}

public void OpenQuant() {
Expand All @@ -145,6 +143,22 @@ public struct State {
public int GetQuant() {
return bt.obj.reps.obj;
}

/*
public static DynMetaObject ListMO;
public static DynMetaObject LLArrayMO;
public static DynMetaObject RegexBacktrackIteratorMO;
public static Variable FalseV;
public Frame End(Frame th) {
if (return_one) {
th.caller.resultSlot = MakeCursor();
} else {
DynObject lst = new DynObject(ListMO);
DynObject obs = new DynObject(LLArrayMO);
DynObject its = new DynObject(LLArrayMO);
DynObject it = new RegexBacktrackIteratorMO;
}
*/
}

public sealed class XAct {
Expand Down
4 changes: 3 additions & 1 deletion t/RxUnitTest.cs
Expand Up @@ -20,7 +20,9 @@ class RxExact: RxOp {
public RxExact(string s) { this.s = s; }
public override void Compile(CodeBuf cb) {
cb.ops.Add(delegate(Frame th) {
return th.rx.Exact(th, s);
if (!th.rx.Exact(th, s))
return th.rx.Backtrack(th);
return th;
});
}
}
Expand Down

0 comments on commit cd6e7c1

Please sign in to comment.