}
}
Iterator machineItr = iv_machineSet.iterator();
while (machineItr.hasNext()) {
Machine fsm = (Machine) machineItr.next();
fsm.input(token);
State currentState = fsm.getCurrentState();
if (currentState.getStartStateFlag()) {
tokenStartMap.put(fsm, new Integer(i));
tokenOffset1 = 0;
tokenOffset2 = 0;
}
if (currentState.getEndStateFlag()) {
Object o = tokenStartMap.get(fsm);
int tokenStartIndex;
int globalOffset = 0;
if (o == null) {
// By default, all machines start with
// token zero.
tokenStartIndex = 0;
} else {
Integer tokenMap1 = new Integer(0);
Integer tokenMap2 = new Integer(0);
BaseToken lookUpOffset = (BaseToken) tokens.get(((Integer) o).intValue());
if (overrideBeginTokenMap1.get(new Integer(lookUpOffset.getStartOffset())) != null){
Integer offSet = (Integer) (overrideBeginTokenMap1.get(new Integer(lookUpOffset.getStartOffset())));
tokenMap1 = new Integer(offSet.intValue() + tokenMap1.intValue());
}
if (overrideBeginTokenMap2.get(new Integer(lookUpOffset.getStartOffset())) != null){
Integer offSet = (Integer) (overrideBeginTokenMap2.get(new Integer(lookUpOffset.getStartOffset())));
tokenMap2 = new Integer(offSet.intValue() + tokenMap2.intValue());
}
globalOffset = tokenMap1.intValue() + tokenMap2.intValue();
tokenStartIndex = ((Integer) o).intValue() + globalOffset;
// skip ahead over single token we don't want
tokenStartIndex++;
}
BaseToken startToken = null;
BaseToken endToken = token;
if (currentState instanceof IndentStartState) {
startToken = (BaseToken) tokens
.get(tokenStartIndex + 1);
} else {
startToken = (BaseToken) tokens.get(tokenStartIndex);
}
StrengthUnitToken measurementToken = null;
StrengthUnitCombinedToken measurementCombinedToken = null;
if (fsm.equals(iv_strengthCombinedMachine)) {
measurementCombinedToken = new StrengthUnitCombinedToken(startToken
.getStartOffset(), endToken.getEndOffset());
measurementSet.add(measurementCombinedToken);
}
else {
measurementToken = new StrengthUnitToken(startToken
.getStartOffset(), endToken.getEndOffset());
measurementSet.add(measurementToken);
}
fsm.reset();
}
}
}
// cleanup
tokenStartMap.clear();
// reset machines
Iterator itr = iv_machineSet.iterator();
while (itr.hasNext()) {
Machine fsm = (Machine) itr.next();
fsm.reset();
}
return measurementSet;
}