/** combine all sets in the array returned the or'd value */ public static IntervalSet or(IntervalSet[] sets) { IntervalSet r = new IntervalSet(); for (IntervalSet s : sets) r.addAll(s); return r; }
public static IntervalSet toSet(BitSet bits) { IntervalSet s = new IntervalSet(); int i = bits.nextSetBit(0); while ( i >= 0 ) { s.add(i); i = bits.nextSetBit(i+1); } return s; }
/** Create a set with all ints within range [a..b] (inclusive) */ public static IntervalSet of(int a, int b) { IntervalSet s = new IntervalSet(); s.add(a,b); return s; }
/** Create a set with a single element, el. */ public static IntervalSet of(int a) { IntervalSet s = new IntervalSet(); s.add(a); return s; }
@Override public IntervalSet subtract(IntSet a) { if (a == null || a.isNil()) { return new IntervalSet(this); } if (a instanceof IntervalSet) { return subtract(this, (IntervalSet)a); } IntervalSet other = new IntervalSet(); other.addAll(a); return subtract(this, other); }
@Override public IntervalSet or(IntSet a) { IntervalSet o = new IntervalSet(); o.addAll(this); o.addAll(a); return o; }
/** * Compute set of tokens that can follow {@code s} in the ATN in the * specified {@code ctx}. * * <p>If {@code ctx} is {@code null} and the end of the rule containing * {@code s} is reached, {@link Token#EPSILON} is added to the result set. * If {@code ctx} is not {@code null} and the end of the outermost rule is * reached, {@link Token#EOF} is added to the result set.</p> * * @param s the ATN state * @param stopState the ATN state to stop at. This can be a * {@link BlockEndState} to detect epsilon paths through a closure. * @param ctx the complete parser context, or {@code null} if the context * should be ignored * * @return The set of tokens that can follow {@code s} in the ATN in the * specified {@code ctx}. */ public IntervalSet LOOK(ATNState s, ATNState stopState, RuleContext ctx) { IntervalSet r = new IntervalSet(); boolean seeThruPreds = true; // ignore preds; get all lookahead PredictionContext lookContext = ctx != null ? PredictionContext.fromRuleContext(s.atn, ctx) : null; _LOOK(s, stopState, lookContext, r, new HashSet<ATNConfig>(), new BitSet(), seeThruPreds, true); return r; }
return new IntervalSet(); IntervalSet result = new IntervalSet(left); if (right == null || right.isNil()) {
/** {@inheritDoc} */ @Override public IntervalSet complement(IntSet vocabulary) { if ( vocabulary==null || vocabulary.isNil() ) { return null; // nothing in common with null set } IntervalSet vocabularyIS; if (vocabulary instanceof IntervalSet) { vocabularyIS = (IntervalSet)vocabulary; } else { vocabularyIS = new IntervalSet(); vocabularyIS.addAll(vocabulary); } return vocabularyIS.subtract(this); }
protected IntervalSet getErrorRecoverySet(Parser recognizer) { ATN atn = recognizer.getInterpreter().atn; RuleContext ctx = recognizer._ctx; IntervalSet recoverSet = new IntervalSet(); while ( ctx!=null && ctx.invokingState>=0 ) { // compute what follows who invoked us ATNState invokingState = atn.states.get(ctx.invokingState); RuleTransition rt = (RuleTransition)invokingState.transition(0); IntervalSet follow = atn.nextTokens(rt.followState); recoverSet.addAll(follow); ctx = ctx.parent; } recoverSet.remove(Token.EPSILON); // System.out.println("recover set "+recoverSet.toString(recognizer.getTokenNames())); return recoverSet; }
protected int getAltThatFinishedDecisionEntryRule(ATNConfigSet configs) { IntervalSet alts = new IntervalSet(); for (ATNConfig c : configs) { if ( c.getOuterContextDepth()>0 || (c.state instanceof RuleStopState && c.context.hasEmptyPath()) ) { alts.add(c.alt); } } if ( alts.size()==0 ) return ATN.INVALID_ALT_NUMBER; return alts.getMinElement(); }
intersection = new IntervalSet(); intersection = new IntervalSet(); intersection = new IntervalSet(); return new IntervalSet();
look[alt] = new IntervalSet(); Set<ATNConfig> lookBusy = new HashSet<ATNConfig>(); boolean seeThruPreds = false; // fail to get lookahead upon pred
private int deserializeSets(char[] data, int p, List<IntervalSet> sets, UnicodeDeserializer unicodeDeserializer) { int nsets = toInt(data[p++]); for (int i=0; i<nsets; i++) { int nintervals = toInt(data[p]); p++; IntervalSet set = new IntervalSet(); sets.add(set); boolean containsEof = toInt(data[p++]) != 0; if (containsEof) { set.add(-1); } for (int j=0; j<nintervals; j++) { int a = unicodeDeserializer.readUnicode(data, p); p += unicodeDeserializer.size(); int b = unicodeDeserializer.readUnicode(data, p); p += unicodeDeserializer.size(); set.add(a, b); } } return p; }
IntervalSet expected = new IntervalSet(); expected.addAll(following); expected.remove(Token.EPSILON);
if ( lastErrorStates==null ) lastErrorStates = new IntervalSet(); lastErrorStates.add(recognizer.getState()); IntervalSet followSet = getErrorRecoverySet(recognizer);
public static IntervalSet toSet(BitSet bits) { IntervalSet s = new IntervalSet(); int i = bits.nextSetBit(0); while ( i >= 0 ) { s.add(i); i = bits.nextSetBit(i+1); } return s; } }
/** combine all sets in the array returned the or'd value */ public static IntervalSet or(IntervalSet[] sets) { IntervalSet r = new IntervalSet(); for (IntervalSet s : sets) r.addAll(s); return r; }
@Override public IntervalSet subtract(IntSet a) { if (a == null || a.isNil()) { return new IntervalSet(this); } if (a instanceof IntervalSet) { return subtract(this, (IntervalSet)a); } IntervalSet other = new IntervalSet(); other.addAll(a); return subtract(this, other); }
@Override public IntervalSet subtract(IntSet a) { if (a == null || a.isNil()) { return new IntervalSet(this); } if (a instanceof IntervalSet) { return subtract(this, (IntervalSet)a); } IntervalSet other = new IntervalSet(); other.addAll(a); return subtract(this, other); }