/** * Returns the minimum value contained in the set if not isNil(). * * @return the minimum value contained in the set. * @throws RuntimeException if set is empty */ public int getMinElement() { if ( isNil() ) { throw new RuntimeException("set is empty"); } return intervals.get(0).a; }
/** * Returns the maximum value contained in the set if not isNil(). * * @return the maximum value contained in the set. * @throws RuntimeException if set is empty */ public int getMaxElement() { if ( isNil() ) { throw new RuntimeException("set is empty"); } Interval last = intervals.get(intervals.size()-1); return last.b; }
/** * Returns the minimum value contained in the set. * * @return the minimum value contained in the set. If the set is empty, this * method returns {@link Token#INVALID_TYPE}. */ public int getMinElement() { if ( isNil() ) { return Token.INVALID_TYPE; } return intervals.get(0).a; }
/** * Returns the minimum value contained in the set. * * @return the minimum value contained in the set. If the set is empty, this * method returns {@link Token#INVALID_TYPE}. */ public int getMinElement() { if ( isNil() ) { return Token.INVALID_TYPE; } return intervals.get(0).a; }
/** * Returns the minimum value contained in the set. * * @return the minimum value contained in the set. If the set is empty, this * method returns {@link Token#INVALID_TYPE}. */ public int getMinElement() { if ( isNil() ) { return Token.INVALID_TYPE; } return intervals.get(0).a; }
/** * Returns the minimum value contained in the set if not isNil(). * * @return the minimum value contained in the set. * @throws RuntimeException if set is empty */ public int getMinElement() { if ( isNil() ) { throw new RuntimeException("set is empty"); } return intervals.get(0).a; }
/** * Returns the maximum value contained in the set. * * @return the maximum value contained in the set. If the set is empty, this * method returns {@link Token#INVALID_TYPE}. */ public int getMaxElement() { if ( isNil() ) { return Token.INVALID_TYPE; } Interval last = intervals.get(intervals.size()-1); return last.b; }
/** * Returns the maximum value contained in the set. * * @return the maximum value contained in the set. If the set is empty, this * method returns {@link Token#INVALID_TYPE}. */ public int getMaxElement() { if ( isNil() ) { return Token.INVALID_TYPE; } Interval last = intervals.get(intervals.size()-1); return last.b; }
/** * Returns the maximum value contained in the set. * * @return the maximum value contained in the set. If the set is empty, this * method returns {@link Token#INVALID_TYPE}. */ public int getMaxElement() { if ( isNil() ) { return Token.INVALID_TYPE; } Interval last = intervals.get(intervals.size()-1); return last.b; }
/** * Returns the maximum value contained in the set if not isNil(). * * @return the maximum value contained in the set. * @throws RuntimeException if set is empty */ public int getMaxElement() { if ( isNil() ) { throw new RuntimeException("set is empty"); } Interval last = intervals.get(intervals.size()-1); return last.b; }
Token tok = e.getOffendingToken(); int expectedTokenType = Token.INVALID_TYPE; if ( !ime.getExpectedTokens().isNil() ) {
IntervalSet expecting = getExpectedTokens(recognizer); int expectedTokenType = Token.INVALID_TYPE; if ( !expecting.isNil() ) {
private static List<Range> intervalSetToRanges(IntervalSet intervalSet) { return intervalSet.isNil() ? new ArrayList<Range>() : intervalsToRanges(intervalSet.getIntervals()); } }
/** Return whether lookahead sets are disjoint; no lookahead ⇒ not disjoint */ public static boolean disjoint(IntervalSet[] altLook) { boolean collision = false; IntervalSet combined = new IntervalSet(); if ( altLook==null ) return false; for (IntervalSet look : altLook) { if ( look==null ) return false; // lookahead must've computation failed if ( !look.and(combined).isNil() ) { collision = true; break; } combined.addAll(look); } return !collision; } }
/** Return whether lookahead sets are disjoint; no lookahead ⇒ not disjoint */ public static boolean disjoint(IntervalSet[] altLook) { boolean collision = false; IntervalSet combined = new IntervalSet(); if ( altLook==null ) return false; for (IntervalSet look : altLook) { if ( look==null ) return false; // lookahead must've computation failed if ( !look.and(combined).isNil() ) { collision = true; break; } combined.addAll(look); } return !collision; } }
/** Return whether lookahead sets are disjoint; no lookahead ⇒ not disjoint */ public static boolean disjoint(IntervalSet[] altLook) { boolean collision = false; IntervalSet combined = new IntervalSet(); if ( altLook==null ) return false; for (IntervalSet look : altLook) { if ( look==null ) return false; // lookahead must've computation failed if ( !look.and(combined).isNil() ) { collision = true; break; } combined.addAll(look); } return !collision; } }
/** Return whether lookahead sets are disjoint; no lookahead ⇒ not disjoint */ public static boolean disjoint(IntervalSet[] altLook) { boolean collision = false; IntervalSet combined = new IntervalSet(); if ( altLook==null ) return false; for (IntervalSet look : altLook) { if ( look==null ) return false; // lookahead must've computation failed if ( !look.and(combined).isNil() ) { collision = true; break; } combined.addAll(look); } return !collision; } }
/** Return whether lookahead sets are disjoint; no lookahead => not disjoint */ public static boolean disjoint(IntervalSet[] altLook) { boolean collision = false; IntervalSet combined = new IntervalSet(); if ( altLook==null ) return false; for (IntervalSet look : altLook) { if ( look==null ) return false; // lookahead must've computation failed if ( !look.and(combined).isNil() ) { collision = true; break; } combined.addAll(look); } return !collision; } }
@Override protected Token getMissingSymbol(Parser recognizer) { Token currentSymbol = recognizer.getCurrentToken(); IntervalSet expecting = getExpectedTokens(recognizer); int expectedTokenType = Token.INVALID_TYPE; if (!expecting.isNil()) { expectedTokenType = expecting.getMinElement(); // get any element } String tokenText; if (expectedTokenType == Token.EOF) tokenText = "<missing EOF>"; else tokenText = "<missing " + recognizer.getVocabulary().getDisplayName(expectedTokenType) + ">"; Token current = currentSymbol; Token lookback = recognizer.getInputStream().LT(-1); if (current.getType() == Token.EOF && lookback != null) { current = lookback; } ProToken tok = new ProToken(ABLNodeType.getNodeType(expectedTokenType), tokenText); tok.setLine(current.getLine()); tok.setCharPositionInLine(current.getCharPositionInLine()); return tok; } }