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