1 package org.apache.oro.text.awk; 2 3 59 60 import java.util.*; 61 62 71 final class SyntaxTree { 72 int _positions; 73 SyntaxNode _root; 74 LeafNode[] _nodes; 75 BitSet[] _followSet; 76 77 SyntaxTree(SyntaxNode root, int positions) { 78 _root = root; 79 _positions = positions; 80 } 81 82 void _computeFollowPositions() { 83 int index; 84 85 _followSet = new BitSet[_positions]; 86 _nodes = new LeafNode[_positions]; 87 index = _positions; 88 89 while(0 < index--) 90 _followSet[index] = new BitSet(_positions); 91 92 _root._followPosition(_followSet, _nodes); 93 } 94 95 private void __addToFastMap(BitSet pos, boolean[] fastMap, boolean[] done){ 96 int token, node; 97 98 for(node = 0; node < _positions; node++){ 99 if(pos.get(node) && !done[node]){ 100 done[node] = true; 101 102 for(token=0; token < LeafNode._NUM_TOKENS; token++){ 103 if(!fastMap[token]) 104 fastMap[token] = _nodes[node]._matches((char)token); 105 } 106 } 107 } 108 } 109 110 boolean[] createFastMap(){ 111 boolean[] fastMap, done; 112 int token; 113 114 fastMap = new boolean[LeafNode._NUM_TOKENS]; 115 done = new boolean[_positions]; 116 __addToFastMap(_root._firstPosition(), fastMap, done); 117 118 return fastMap; 119 } 120 } 121 | Popular Tags |