1
16
17 import org.as2lib.regexp.node.Node;
18 import org.as2lib.regexp.node.TreeInfo;
19
20
26
27 class org.as2lib.regexp.node.Both extends Node {
28
29 private var lhs, rhs:Node;
30
31 public function Both(lhs:Node, rhs:Node) {
32 this.lhs = lhs;
33 this.rhs = rhs;
34 }
35
36 public function match(matcher:Object, i:Number, seq:String):Boolean {
37 if (i < matcher.to) {
38 return ((lhs.match(matcher, i, seq) && rhs.match(matcher, i, seq))
39 && next.match(matcher, matcher.last, seq));
40 }
41 return false;
42 }
43
44 public function study(info:TreeInfo):Boolean {
45 var maxV:Boolean = info.maxValid;
46 var detm:Boolean = info.deterministic;
47
48 var minL:Number = info.minLength;
49 var maxL:Number = info.maxLength;
50 lhs.study(info);
51
52 var minL2:Number = info.minLength;
53 var maxL2:Number = info.maxLength;
54
55 info.minLength = minL;
56 info.maxLength = maxL;
57 rhs.study(info);
58
59 info.minLength = Math.min(minL2, info.minLength);
60 info.maxLength = Math.max(maxL2, info.maxLength);
61 info.maxValid = maxV;
62 info.deterministic = detm;
63
64 return next.study(info);
65 }
66 }
67