1 package org.apache.oro.text.awk; 2 3 59 60 import java.util.*; 61 62 66 final class CatNode extends SyntaxNode { 67 SyntaxNode _left, _right; 68 69 boolean _nullable() { 70 return (_left._nullable() && _right._nullable()); 71 } 72 73 BitSet _firstPosition() { 74 if(_left._nullable()){ 75 BitSet ls, rs, bs; 76 77 ls = _left._firstPosition(); 78 rs = _right._firstPosition(); 79 bs = new BitSet(Math.max(ls.size(), rs.size())); 80 bs.or(rs); 81 bs.or(ls); 82 83 return bs; 84 } 85 86 return _left._firstPosition(); 87 } 88 89 BitSet _lastPosition() { 90 if(_right._nullable()) { 91 BitSet ls, rs, bs; 92 93 ls = _left._lastPosition(); 94 rs = _right._lastPosition(); 95 bs = new BitSet(Math.max(ls.size(), rs.size())); 96 bs.or(rs); 97 bs.or(ls); 98 99 return bs; 100 } 101 102 return _right._lastPosition(); 103 } 104 105 106 void _followPosition(BitSet[] follow, SyntaxNode[] nodes) { 107 int size; 108 BitSet leftLast, rightFirst; 109 110 _left._followPosition(follow, nodes); 111 _right._followPosition(follow, nodes); 112 113 leftLast = _left._lastPosition(); 114 rightFirst = _right._firstPosition(); 115 116 size = leftLast.size(); 117 while(0 < size--) 118 if(leftLast.get(size)) 119 follow[size].or(rightFirst); 120 } 121 122 SyntaxNode _clone(int pos[]) { 123 CatNode node; 124 125 node = new CatNode(); 126 node._left = _left._clone(pos); 127 node._right = _right._clone(pos); 128 129 return node; 130 } 131 } 132 | Popular Tags |