1
16
17 import org.as2lib.regexp.node.Loop;
18 import org.as2lib.regexp.node.TreeInfo;
19
20
28
29 class org.as2lib.regexp.node.LazyLoop extends Loop {
30
31 public function LazyLoop(countIndex:Number, beginIndex:Number) {
32 super(countIndex, beginIndex);
33 }
34
35 public function match(matcher:Object, i:Number, seq:String):Boolean {
36
37 if (i > matcher.locals[beginIndex]) {
38 var count:Number = matcher.locals[countIndex];
39 if (count < cmin) {
40 matcher.locals[countIndex] = count + 1;
41 var result:Boolean = body.match(matcher, i, seq);
42
43
44 if (!result)
45 matcher.locals[countIndex] = count;
46 return result;
47 }
48 if (next.match(matcher, i, seq))
49 return true;
50 if (count < cmax) {
51 matcher.locals[countIndex] = count + 1;
52 var result:Boolean = body.match(matcher, i, seq);
53
54
55 if (!result)
56 matcher.locals[countIndex] = count;
57 return result;
58 }
59 return false;
60 }
61 return next.match(matcher, i, seq);
62 }
63
64 public function matchInit(matcher:Object, i:Number, seq:String):Boolean {
65 var save:Number = matcher.locals[countIndex];
66 var ret:Boolean = false;
67 if (0 < cmin) {
68 matcher.locals[countIndex] = 1;
69 ret = body.match(matcher, i, seq);
70 } else if (next.match(matcher, i, seq)) {
71 ret = true;
72 } else if (0 < cmax) {
73 matcher.locals[countIndex] = 1;
74 ret = body.match(matcher, i, seq);
75 }
76 matcher.locals[countIndex] = save;
77 return ret;
78 }
79
80 public function study(info:TreeInfo):Boolean {
81 info.maxValid = false;
82 info.deterministic = false;
83 return false;
84 }
85 }
86
87