@Override public Frequency consumesInput(Language lang) { Frequency ff = lang.lali.consumesInput(first); switch (ff) { case NEVER: return lang.lali.consumesInput(second); case ALWAYS: return ff; case SOMETIMES: Frequency sf = lang.lali.consumesInput(second); switch (sf) { case ALWAYS: case SOMETIMES: return sf; case NEVER: return Frequency.SOMETIMES; } throw new AssertionError(sf.name()); } throw new AssertionError(ff.name()); }
@Override public ImmutableRangeSet<Integer> lookahead(Language lang) { Frequency ff = lang.lali.consumesInput(first); switch (ff) { case NEVER: return lang.lali.lookahead(second); case ALWAYS: return lang.lali.lookahead(first); case SOMETIMES: TreeRangeSet<Integer> r = TreeRangeSet.create(); r.addAll(lang.lali.lookahead(first)); r.addAll(lang.lali.lookahead(second)); return ImmutableRangeSet.copyOf(r); } throw new AssertionError(ff.name()); }