protected SemanticContext[] getPredsForAmbigAlts(BitSet ambigAlts,
												  ATNConfigSet configs,
												  int nalts)
	{
		// REACH=[1|1|[]|0:0, 1|2|[]|0:1]
		/* altToPred starts as an array of all null contexts. The entry at index i
		 * corresponds to alternative i. altToPred[i] may have one of three values:
		 *   1. null: no ATNConfig c is found such that c.alt==i
		 *   2. SemanticContext.NONE: At least one ATNConfig c exists such that
		 *      c.alt==i and c.semanticContext==SemanticContext.NONE. In other words,
		 *      alt i has at least one unpredicated config.
		 *   3. Non-NONE Semantic Context: There exists at least one, and for all
		 *      ATNConfig c such that c.alt==i, c.semanticContext!=SemanticContext.NONE.
		 *
		 * From this, it is clear that NONE||anything==NONE.
		 */
		SemanticContext[] altToPred = new SemanticContext[nalts + 1];
		for (ATNConfig c : configs) {
			if ( ambigAlts.get(c.alt) ) {
				altToPred[c.alt] = SemanticContext.or(altToPred[c.alt], c.semanticContext);
			}
		}

		int nPredAlts = 0;
		for (int i = 1; i <= nalts; i++) {
			if (altToPred[i] == null) {
				altToPred[i] = SemanticContext.Empty.Instance;
			}
			else if (altToPred[i] != SemanticContext.Empty.Instance) {
				nPredAlts++;
			}
		}

//		// Optimize away p||p and p&&p TODO: optimize() was a no-op
//		for (int i = 0; i < altToPred.length; i++) {
//			altToPred[i] = altToPred[i].optimize();
//		}

		// nonambig alts are null in altToPred
		if ( nPredAlts==0 ) altToPred = null;
		if ( debug ) System.out.println("getPredsForAmbigAlts result "+Arrays.toString(altToPred));
		return altToPred;
	}
This method transforms the start state computed by
{@link #computeStartState} to the special start state used by a
precedence DFA for a particular precedence value. The transformation
process applies the following changes to the start state's configuration
set.

<ol>
<li>Evaluate the precedence predicates for each configuration using
{@link SemanticContext#evalPrecedence}.</li>
<li>When {@link ATNConfig#isPrecedenceFilterSuppressed} is {@code false},
remove all configurations which predict an alternative greater than 1,
for which another configuration that predicts alternative 1 is in the
same ATN state with the same prediction context. This transformation is
valid for the following reasons:
<ul>
<li>The closure block cannot contain any epsilon transitions which bypass
the body of the closure, so all states reachable via alternative 1 are
part of the precedence alternatives of the transformed left-recursive
rule.</li>
<li>The "primary" portion of a left recursive rule cannot contain an
epsilon transition, so the only way an alternative other than 1 can exist
in a state that is also reachable via alternative 1 is by nesting calls
to the left-recursive rule, with the outer calls not being at the
preferred precedence level. The
{@link ATNConfig#isPrecedenceFilterSuppressed} property marks ATN
configurations which do not meet this condition, and therefore are not
eligible for elimination during the filtering process.</li>
</ul>
</li>
</ol>

<p>
The prediction context must be considered by this filter to address
situations like the following.
</p>
<code>
<pre>
grammar TA;
prog: statement* EOF;
statement: letterA | statement letterA 'b' ;
letterA: 'a';
</pre>
</code>
<p>
If the above grammar, the ATN state immediately before the token
reference {@code 'a'} in {@code letterA} is reachable from the left edge
of both the primary and closure blocks of the left-recursive rule
{@code statement}. The prediction context associated with each of these
configurations distinguishes between them, and prevents the alternative
which stepped out to {@code prog} (and then back in to {@code statement}
from being eliminated by the filter.
</p>

@param configs The configuration set computed by
{@link #computeStartState} as the start state for the DFA.
@return The transformed configuration set representing the start state
for a precedence DFA at a particular precedence level (determined by
calling {@link Parser#getPrecedence}).
runtime/Java/src/org/antlr/v4/runtime/atn/ParserATNSimulator.java