public void calcFollowPos(BitSet[] followPosSets) { // Let's let sub-models do what they need to do mLeftModel.calcFollowPos(followPosSets); mRightModel.calcFollowPos(followPosSets); /* And then we can calculate follower sets between left and * right sub models; so that left model's last position entries * have right model's first position entries included */ BitSet foll = new BitSet(); mRightModel.addFirstPos(foll); BitSet toAddTo = new BitSet(); mLeftModel.addLastPos(toAddTo); int ix = 0; // need to/can skip the null entry (index 0) while ((ix = toAddTo.nextSetBit(ix+1)) >= 0) { /* Ok; so token at this index needs to have follow positions * added... */ followPosSets[ix].or(foll); } }
/** * Method that has to create a deep copy of the model, without * sharing any of existing Objects. */ public ModelNode cloneModel() { return new ConcatModel(mLeftModel.cloneModel(), mRightModel.cloneModel()); }
public void indexTokens(List tokens) { // First, let's ask sub-models to calc their settings for (int i = 0, len = mSubModels.length; i < len; ++i) { mSubModels[i].indexTokens(tokens); } }
public void addFirstPos(BitSet pos) { if (mFirstPos == null) { mFirstPos = new BitSet(); mLeftModel.addFirstPos(mFirstPos); if (mLeftModel.isNullable()) { mRightModel.addFirstPos(mFirstPos); } } pos.or(mFirstPos); }
public void addLastPos(BitSet pos) { if (mLastPos == null) { mLastPos = new BitSet(); mRightModel.addLastPos(mLastPos); if (mRightModel.isNullable()) { mLeftModel.addLastPos(mLastPos); } } pos.or(mLastPos); }
public void calcFollowPos(BitSet[] followPosSets) { // Let's let sub-model do its stuff mModel.calcFollowPos(followPosSets); }
public void addFirstPos(BitSet pos) { mModel.addFirstPos(pos); }
public void addLastPos(BitSet pos) { mModel.addLastPos(pos); }
public ConcatModel(ModelNode left, ModelNode right) { super(); mLeftModel = left; mRightModel = right; mNullable = mLeftModel.isNullable() && mRightModel.isNullable(); }
public void addFirstPos(BitSet pos) { if (mFirstPos == null) { mFirstPos = new BitSet(); mLeftModel.addFirstPos(mFirstPos); if (mLeftModel.isNullable()) { mRightModel.addFirstPos(mFirstPos); } } pos.or(mFirstPos); }
public void addLastPos(BitSet pos) { if (mLastPos == null) { mLastPos = new BitSet(); mRightModel.addLastPos(mLastPos); if (mRightModel.isNullable()) { mLeftModel.addLastPos(mLastPos); } } pos.or(mLastPos); }
public void calcFollowPos(BitSet[] followPosSets) { // need to let child models do their stuff: for (int i = 0, len = mSubModels.length; i < len; ++i) { mSubModels[i].calcFollowPos(followPosSets); } } }
public void addFirstPos(BitSet pos) { mModel.addFirstPos(pos); }
public void addLastPos(BitSet pos) { mModel.addLastPos(pos); }
protected ChoiceModel(ModelNode[] subModels) { super(); mSubModels = subModels; boolean nullable = false; for (int i = 0, len = subModels.length; i < len; ++i) { if (subModels[i].isNullable()) { nullable = true; break; } } mNullable = nullable; }
public void calcFollowPos(BitSet[] followPosSets) { // First, let's let sub-model do its stuff mModel.calcFollowPos(followPosSets); /* And then add the closure for the model (since sub-model * can 'follow itself' as many times as it needs to) */ BitSet foll = new BitSet(); mModel.addFirstPos(foll); BitSet toAddTo = new BitSet(); mModel.addLastPos(toAddTo); int ix = 0; // need to/can skip the null entry (index 0) while ((ix = toAddTo.nextSetBit(ix+1)) >= 0) { /* Ok; so token at this index needs to have follow positions * added... */ followPosSets[ix].or(foll); } }
@Override public void addFirstPos(BitSet pos) { if (mFirstPos == null) { mFirstPos = new BitSet(); mLeftModel.addFirstPos(mFirstPos); if (mLeftModel.isNullable()) { mRightModel.addFirstPos(mFirstPos); } } pos.or(mFirstPos); }
public void addLastPos(BitSet pos) { if (mLastPos == null) { mLastPos = new BitSet(); mRightModel.addLastPos(mLastPos); if (mRightModel.isNullable()) { mLeftModel.addLastPos(mLastPos); } } pos.or(mLastPos); }
/** * Method that has to create a deep copy of the model, without * sharing any of existing Objects. */ public ModelNode cloneModel() { return new OptionalModel(mModel.cloneModel()); }
public void indexTokens(List tokens) { mLeftModel.indexTokens(tokens); mRightModel.indexTokens(tokens); }