public static List<ParserRuleContext> getLookaheadParseTrees(Grammar g,
	                                                             ParserInterpreter originalParser,
	                                                             TokenStream tokens,
	                                                             int startRuleIndex,
	                                                             int decision,
	                                                             int startIndex,
	                                                             int stopIndex) {
		List<ParserRuleContext> trees = new ArrayList<ParserRuleContext>();
		// Create a new parser interpreter to parse the ambiguous subphrase
		ParserInterpreter parser = deriveTempParserInterpreter(g, originalParser, tokens);

		DecisionState decisionState = originalParser.getATN().decisionToState.get(decision);

		for (int alt = 1; alt<=decisionState.getTransitions().length; alt++) {
			// re-parse entire input for all ambiguous alternatives
			// (don't have to do first as it's been parsed, but do again for simplicity
			//  using this temp parser.)
			GrammarParserInterpreter.BailButConsumeErrorStrategy errorHandler =
				new GrammarParserInterpreter.BailButConsumeErrorStrategy();
			parser.setErrorHandler(errorHandler);
			parser.reset();
			parser.addDecisionOverride(decision, startIndex, alt);
			ParserRuleContext tt = parser.parse(startRuleIndex);
			int stopTreeAt = stopIndex;
			if ( errorHandler.firstErrorTokenIndex>=0 ) {
				stopTreeAt = errorHandler.firstErrorTokenIndex; // cut off rest at first error
			}
			Interval overallRange = tt.getSourceInterval();
			if ( stopTreeAt>overallRange.b ) {
				// If we try to look beyond range of tree, stopTreeAt must be EOF
				// for which there is no EOF ref in grammar. That means tree
				// will not have node for stopTreeAt; limit to overallRange.b
				stopTreeAt = overallRange.b;
			}
			ParserRuleContext subtree =
				Trees.getRootOfSubtreeEnclosingRegion(tt,
				                                      startIndex,
				                                      stopTreeAt);
			// Use higher of overridden decision tree or tree enclosing all tokens
			if ( Trees.isAncestorOf(parser.getOverrideDecisionRoot(), subtree) ) {
				subtree = parser.getOverrideDecisionRoot();
			}
			Trees.stripChildrenOutOfRange(subtree, parser.getOverrideDecisionRoot(), startIndex, stopTreeAt);
			trees.add(subtree);
		}

		return trees;
	}
Return a list of parse trees, one for each alternative in a decision
 given the same input.

 Very similar to {@link #getAllPossibleParseTrees} except
 that it re-parses the input for every alternative in a decision,
 not just the ambiguous ones (there is no alts parameter here).
 This method also tries to reduce the size of the parse trees
 by stripping away children of the tree that are completely out of range
 of startIndex..stopIndex. Also, because errors are expected, we
 use a specialized error handler that more or less bails out
 but that also consumes the first erroneous token at least. This
 ensures that an error node will be in the parse tree for display.

 NOTES:
    // we must parse the entire input now with decision overrides
	// we cannot parse a subset because it could be that a decision
	// above our decision of interest needs to read way past
	// lookaheadInfo.stopIndex. It seems like there is no escaping
	// the use of a full and complete token stream if we are
	// resetting to token index 0 and re-parsing from the start symbol.
	// It's not easy to restart parsing somewhere in the middle like a
	// continuation because our call stack does not match the
	// tree stack because of left recursive rule rewriting. grrrr!

@since 4.5.1
tool/src/org/antlr/v4/tool/GrammarParserInterpreter.java