1
16
17 import org.as2lib.regexp.Pattern;
18 import org.as2lib.regexp.node.Node;
19 import org.as2lib.regexp.node.TreeInfo;
20
21
27
28 class org.as2lib.regexp.node.Ques extends Node {
29
30 private var atom:Node;
31 private var type:Number;
32
33 public function Ques(node:Node, type:Number) {
34 this.atom = node;
35 this.type = type;
36 }
37
38 public function match(matcher:Object, i:Number, seq:String):Boolean {
39 switch (type) {
40 case Pattern.GREEDY:
41 return (atom.match(matcher, i, seq) && next.match(matcher, matcher.last, seq))
42 || next.match(matcher, i, seq);
43 case Pattern.LAZY:
44 return next.match(matcher, i, seq)
45 || (atom.match(matcher, i, seq) && next.match(matcher, matcher.last, seq));
46 case Pattern.POSSESSIVE:
47 if (atom.match(matcher, i, seq)) i = matcher.last;
48 return next.match(matcher, i, seq);
49 default:
50 return atom.match(matcher, i, seq) && next.match(matcher, matcher.last, seq);
51 }
52 }
53
54 public function study(info:TreeInfo):Boolean {
55 if (type != Pattern.INDEPENDENT) {
56 var minL:Number = info.minLength;
57 atom.study(info);
58 info.minLength = minL;
59 info.deterministic = false;
60 return next.study(info);
61 } else {
62 atom.study(info);
63 return next.study(info);
64 }
65 }
66
67 public function getType(Void):Number {
68 return type;
69 }
70 }
71
72