protected boolean evaluatePredicate(CharStream input, int ruleIndex, int predIndex, boolean speculative) {
		// assume true if no recognizer was provided
		if (recog == null) {
			return true;
		}

		if (!speculative) {
			return recog.sempred(null, ruleIndex, predIndex);
		}

		int savedCharPositionInLine = charPositionInLine;
		int savedLine = line;
		int index = input.index();
		int marker = input.mark();
		try {
			consume(input);
			return recog.sempred(null, ruleIndex, predIndex);
		}
		finally {
			charPositionInLine = savedCharPositionInLine;
			line = savedLine;
			input.seek(index);
			input.release(marker);
		}
	}
Evaluate a predicate specified in the lexer.

<p>If {@code speculative} is {@code true}, this method was called before
{@link #consume} for the matched character. This method should call
{@link #consume} before evaluating the predicate to ensure position
sensitive values, including {@link Lexer#getText}, {@link Lexer#getLine},
and {@link Lexer#getCharPositionInLine}, properly reflect the current
lexer state. This method should restore {@code input} and the simulator
to the original state before returning (i.e. undo the actions made by the
call to {@link #consume}.</p>

@param input The input stream.
@param ruleIndex The rule containing the predicate.
@param predIndex The index of the predicate within the rule.
@param speculative {@code true} if the current index in {@code input} is
one character before the predicate's location.

@return {@code true} if the specified predicate evaluates to
{@code true}.
runtime/Java/src/org/antlr/v4/runtime/atn/LexerATNSimulator.java