rm @NotNull and @Nullable from codebase to simplify
This commit is contained in:
parent
0ee58d9295
commit
be03964df3
|
@ -55,7 +55,7 @@ public class Antlr4ErrorLog implements ANTLRToolListener {
|
|||
*
|
||||
* @param log The Maven log
|
||||
*/
|
||||
public Antlr4ErrorLog(@NotNull Tool tool, @NotNull BuildContext buildContext, @NotNull Log log) {
|
||||
public Antlr4ErrorLog(Tool tool, BuildContext buildContext, Log log) {
|
||||
this.tool = tool;
|
||||
this.buildContext = buildContext;
|
||||
this.log = log;
|
||||
|
|
|
@ -356,7 +356,7 @@ public class Antlr4Mojo extends AbstractMojo {
|
|||
* @param sourceDirectory
|
||||
* @exception InclusionScanException
|
||||
*/
|
||||
@NotNull
|
||||
|
||||
private List<List<String>> processGrammarFiles(List<String> args, File sourceDirectory) throws InclusionScanException {
|
||||
// Which files under the source set should we be looking for as grammar files
|
||||
SourceMapping mapping = new SuffixMapping("g4", Collections.<String>emptySet());
|
||||
|
|
10
bild.py
10
bild.py
|
@ -75,7 +75,7 @@ def compile():
|
|||
cp = uniformpath("out") + os.pathsep + \
|
||||
os.path.join(JARCACHE, "antlr-3.5.1-complete.jar") + os.pathsep + \
|
||||
"runtime/Java/lib/org.abego.treelayout.core.jar" + os.pathsep
|
||||
srcpath = ["gen3", "gen4", "runtime/JavaAnnotations/src", "runtime/Java/src", "tool/src"]
|
||||
srcpath = ["gen3", "gen4", "runtime/Java/src", "tool/src"]
|
||||
args = ["-Xlint", "-Xlint:-serial", "-g", "-sourcepath", string.join(srcpath, os.pathsep)]
|
||||
for sp in srcpath:
|
||||
javac(sp, "out", version="1.6", cp=cp, args=args)
|
||||
|
@ -121,7 +121,7 @@ def mkjar_runtime():
|
|||
unjar("runtime/Java/lib/org.abego.treelayout.core.jar", trgdir="out/runtime")
|
||||
cp = uniformpath("out/runtime") + os.pathsep + \
|
||||
"runtime/Java/lib/org.abego.treelayout.core.jar"
|
||||
srcpath = ["gen4", "runtime/JavaAnnotations/src", "runtime/Java/src"]
|
||||
srcpath = ["gen4", "runtime/Java/src"]
|
||||
args = ["-nowarn", "-Xlint", "-Xlint:-serial", "-g", "-sourcepath", string.join(srcpath, os.pathsep)]
|
||||
for sp in srcpath:
|
||||
javac(sp, "out/runtime", version="1.6", cp=cp, args=args)
|
||||
|
@ -313,7 +313,7 @@ def mksrc():
|
|||
zip(jarfile, srcpath)
|
||||
print "Generated " + jarfile
|
||||
|
||||
srcpaths = [ srcpath, "gen3/org", "gen4/org", "runtime/JavaAnnotations/src/org", "tool/src/org"]
|
||||
srcpaths = [ srcpath, "gen3/org", "gen4/org", "tool/src/org"]
|
||||
srcfiles = allfiles(srcpaths, "*.java");
|
||||
jarfile = "dist/antlr4-" + VERSION + "-complete-sources.jar"
|
||||
if not isstale(src=newest(srcfiles), trg=jarfile):
|
||||
|
@ -333,9 +333,6 @@ def mkdoc():
|
|||
if not isstale(src=runtime_source_jarfile, trg=runtimedoc) and \
|
||||
not isstale(src=tool_source_jarfile, trg=tooldoc):
|
||||
return
|
||||
mkdir("out/Annotations")
|
||||
download("http://search.maven.org/remotecontent?filepath=org/antlr/antlr4-annotations/4.3/antlr4-annotations-4.3-sources.jar", "out/Annotations")
|
||||
unjar("out/Annotations/antlr4-annotations-4.3-sources.jar", trgdir="out/Annotations")
|
||||
# JavaDoc needs abego treelayout source code
|
||||
mkdir("out/TreeLayout")
|
||||
download("http://search.maven.org/remotecontent?filepath=org/abego/treelayout/org.abego.treelayout.core/1.0.1/org.abego.treelayout.core-1.0.1-sources.jar", "out/TreeLayout")
|
||||
|
@ -352,7 +349,6 @@ def mkdoc():
|
|||
mkdir("doc/Java")
|
||||
mkdir("doc/JavaTool")
|
||||
dirs = ["runtime/Java/src"]
|
||||
dirs += ["out/Annotations"]
|
||||
dirs += ["out/TreeLayout"]
|
||||
exclude = ["org/antlr/runtime",
|
||||
"org/abego",
|
||||
|
|
|
@ -35,8 +35,6 @@ import org.antlr.v4.runtime.atn.DecisionInfo;
|
|||
import org.antlr.v4.runtime.atn.ParserATNSimulator;
|
||||
import org.antlr.v4.runtime.atn.PredictionMode;
|
||||
import org.antlr.v4.runtime.dfa.DFA;
|
||||
import org.antlr.v4.runtime.misc.NotNull;
|
||||
import org.antlr.v4.runtime.misc.Nullable;
|
||||
|
||||
import java.util.BitSet;
|
||||
|
||||
|
@ -75,12 +73,12 @@ public interface ANTLRErrorListener {
|
|||
* the parser was able to recover in line without exiting the
|
||||
* surrounding rule.
|
||||
*/
|
||||
public void syntaxError(@NotNull Recognizer<?, ?> recognizer,
|
||||
@Nullable Object offendingSymbol,
|
||||
public void syntaxError(Recognizer<?, ?> recognizer,
|
||||
Object offendingSymbol,
|
||||
int line,
|
||||
int charPositionInLine,
|
||||
@NotNull String msg,
|
||||
@Nullable RecognitionException e);
|
||||
String msg,
|
||||
RecognitionException e);
|
||||
|
||||
/**
|
||||
* This method is called by the parser when a full-context prediction
|
||||
|
@ -122,13 +120,13 @@ public interface ANTLRErrorListener {
|
|||
* @param configs the ATN configuration set where the ambiguity was
|
||||
* identified
|
||||
*/
|
||||
void reportAmbiguity(@NotNull Parser recognizer,
|
||||
@NotNull DFA dfa,
|
||||
void reportAmbiguity(Parser recognizer,
|
||||
DFA dfa,
|
||||
int startIndex,
|
||||
int stopIndex,
|
||||
boolean exact,
|
||||
@Nullable BitSet ambigAlts,
|
||||
@NotNull ATNConfigSet configs);
|
||||
BitSet ambigAlts,
|
||||
ATNConfigSet configs);
|
||||
|
||||
/**
|
||||
* This method is called when an SLL conflict occurs and the parser is about
|
||||
|
@ -153,12 +151,12 @@ public interface ANTLRErrorListener {
|
|||
* @param configs the ATN configuration set where the SLL conflict was
|
||||
* detected
|
||||
*/
|
||||
void reportAttemptingFullContext(@NotNull Parser recognizer,
|
||||
@NotNull DFA dfa,
|
||||
void reportAttemptingFullContext(Parser recognizer,
|
||||
DFA dfa,
|
||||
int startIndex,
|
||||
int stopIndex,
|
||||
@Nullable BitSet conflictingAlts,
|
||||
@NotNull ATNConfigSet configs);
|
||||
BitSet conflictingAlts,
|
||||
ATNConfigSet configs);
|
||||
|
||||
/**
|
||||
* This method is called by the parser when a full-context prediction has a
|
||||
|
@ -198,10 +196,10 @@ public interface ANTLRErrorListener {
|
|||
* @param configs the ATN configuration set where the unambiguous prediction
|
||||
* was determined
|
||||
*/
|
||||
void reportContextSensitivity(@NotNull Parser recognizer,
|
||||
@NotNull DFA dfa,
|
||||
void reportContextSensitivity(Parser recognizer,
|
||||
DFA dfa,
|
||||
int startIndex,
|
||||
int stopIndex,
|
||||
int prediction,
|
||||
@NotNull ATNConfigSet configs);
|
||||
ATNConfigSet configs);
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ public interface ANTLRErrorStrategy {
|
|||
* Reset the error handler state for the specified {@code recognizer}.
|
||||
* @param recognizer the parser instance
|
||||
*/
|
||||
void reset(@NotNull Parser recognizer);
|
||||
void reset(Parser recognizer);
|
||||
|
||||
/**
|
||||
* This method is called when an unexpected symbol is encountered during an
|
||||
|
@ -74,9 +74,7 @@ public interface ANTLRErrorStrategy {
|
|||
* @throws RecognitionException if the error strategy was not able to
|
||||
* recover from the unexpected input symbol
|
||||
*/
|
||||
@NotNull
|
||||
Token recoverInline(@NotNull Parser recognizer)
|
||||
throws RecognitionException;
|
||||
Token recoverInline(Parser recognizer) throws RecognitionException;
|
||||
|
||||
/**
|
||||
* This method is called to recover from exception {@code e}. This method is
|
||||
|
@ -90,9 +88,7 @@ public interface ANTLRErrorStrategy {
|
|||
* @throws RecognitionException if the error strategy could not recover from
|
||||
* the recognition exception
|
||||
*/
|
||||
void recover(@NotNull Parser recognizer,
|
||||
@NotNull RecognitionException e)
|
||||
throws RecognitionException;
|
||||
void recover(Parser recognizer, RecognitionException e) throws RecognitionException;
|
||||
|
||||
/**
|
||||
* This method provides the error handler with an opportunity to handle
|
||||
|
@ -113,8 +109,7 @@ public interface ANTLRErrorStrategy {
|
|||
* strategy but cannot be automatically recovered at the current state in
|
||||
* the parsing process
|
||||
*/
|
||||
void sync(@NotNull Parser recognizer)
|
||||
throws RecognitionException;
|
||||
void sync(Parser recognizer) throws RecognitionException;
|
||||
|
||||
/**
|
||||
* Tests whether or not {@code recognizer} is in the process of recovering
|
||||
|
@ -127,7 +122,7 @@ public interface ANTLRErrorStrategy {
|
|||
* @return {@code true} if the parser is currently recovering from a parse
|
||||
* error, otherwise {@code false}
|
||||
*/
|
||||
boolean inErrorRecoveryMode(@NotNull Parser recognizer);
|
||||
boolean inErrorRecoveryMode(Parser recognizer);
|
||||
|
||||
/**
|
||||
* This method is called by when the parser successfully matches an input
|
||||
|
@ -135,7 +130,7 @@ public interface ANTLRErrorStrategy {
|
|||
*
|
||||
* @param recognizer the parser instance
|
||||
*/
|
||||
void reportMatch(@NotNull Parser recognizer);
|
||||
void reportMatch(Parser recognizer);
|
||||
|
||||
/**
|
||||
* Report any kind of {@link RecognitionException}. This method is called by
|
||||
|
@ -144,6 +139,5 @@ public interface ANTLRErrorStrategy {
|
|||
* @param recognizer the parser instance
|
||||
* @param e the recognition exception to report
|
||||
*/
|
||||
void reportError(@NotNull Parser recognizer,
|
||||
@NotNull RecognitionException e);
|
||||
void reportError(Parser recognizer, RecognitionException e);
|
||||
}
|
||||
|
|
|
@ -29,8 +29,6 @@
|
|||
*/
|
||||
package org.antlr.v4.runtime;
|
||||
|
||||
import org.antlr.v4.runtime.misc.NotNull;
|
||||
import org.antlr.v4.runtime.misc.Nullable;
|
||||
import org.antlr.v4.runtime.misc.Utils;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -42,16 +40,16 @@ import java.io.IOException;
|
|||
public class ANTLRFileStream extends ANTLRInputStream {
|
||||
protected String fileName;
|
||||
|
||||
public ANTLRFileStream(@NotNull String fileName) throws IOException {
|
||||
public ANTLRFileStream(String fileName) throws IOException {
|
||||
this(fileName, null);
|
||||
}
|
||||
|
||||
public ANTLRFileStream(@NotNull String fileName, String encoding) throws IOException {
|
||||
public ANTLRFileStream(String fileName, String encoding) throws IOException {
|
||||
this.fileName = fileName;
|
||||
load(fileName, encoding);
|
||||
}
|
||||
|
||||
public void load(@NotNull String fileName, @Nullable String encoding)
|
||||
public void load(String fileName, String encoding)
|
||||
throws IOException
|
||||
{
|
||||
data = Utils.readFile(fileName, encoding);
|
||||
|
|
|
@ -31,8 +31,6 @@ package org.antlr.v4.runtime;
|
|||
|
||||
import org.antlr.v4.runtime.atn.ATNConfigSet;
|
||||
import org.antlr.v4.runtime.dfa.DFA;
|
||||
import org.antlr.v4.runtime.misc.NotNull;
|
||||
import org.antlr.v4.runtime.misc.Nullable;
|
||||
|
||||
import java.util.BitSet;
|
||||
|
||||
|
@ -45,43 +43,43 @@ import java.util.BitSet;
|
|||
*/
|
||||
public class BaseErrorListener implements ANTLRErrorListener {
|
||||
@Override
|
||||
public void syntaxError(@NotNull Recognizer<?, ?> recognizer,
|
||||
@Nullable Object offendingSymbol,
|
||||
public void syntaxError(Recognizer<?, ?> recognizer,
|
||||
Object offendingSymbol,
|
||||
int line,
|
||||
int charPositionInLine,
|
||||
@NotNull String msg,
|
||||
@Nullable RecognitionException e)
|
||||
String msg,
|
||||
RecognitionException e)
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reportAmbiguity(@NotNull Parser recognizer,
|
||||
@NotNull DFA dfa,
|
||||
public void reportAmbiguity(Parser recognizer,
|
||||
DFA dfa,
|
||||
int startIndex,
|
||||
int stopIndex,
|
||||
boolean exact,
|
||||
@Nullable BitSet ambigAlts,
|
||||
@NotNull ATNConfigSet configs)
|
||||
BitSet ambigAlts,
|
||||
ATNConfigSet configs)
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reportAttemptingFullContext(@NotNull Parser recognizer,
|
||||
@NotNull DFA dfa,
|
||||
public void reportAttemptingFullContext(Parser recognizer,
|
||||
DFA dfa,
|
||||
int startIndex,
|
||||
int stopIndex,
|
||||
@Nullable BitSet conflictingAlts,
|
||||
@NotNull ATNConfigSet configs)
|
||||
BitSet conflictingAlts,
|
||||
ATNConfigSet configs)
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reportContextSensitivity(@NotNull Parser recognizer,
|
||||
@NotNull DFA dfa,
|
||||
public void reportContextSensitivity(Parser recognizer,
|
||||
DFA dfa,
|
||||
int startIndex,
|
||||
int stopIndex,
|
||||
int prediction,
|
||||
@NotNull ATNConfigSet configs)
|
||||
ATNConfigSet configs)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,7 +54,6 @@ public class BufferedTokenStream implements TokenStream {
|
|||
/**
|
||||
* The {@link TokenSource} from which tokens for this stream are fetched.
|
||||
*/
|
||||
@NotNull
|
||||
protected TokenSource tokenSource;
|
||||
|
||||
/**
|
||||
|
@ -92,7 +91,7 @@ public class BufferedTokenStream implements TokenStream {
|
|||
*/
|
||||
protected boolean fetchedEOF;
|
||||
|
||||
public BufferedTokenStream(@NotNull TokenSource tokenSource) {
|
||||
public BufferedTokenStream(TokenSource tokenSource) {
|
||||
if (tokenSource == null) {
|
||||
throw new NullPointerException("tokenSource cannot be null");
|
||||
}
|
||||
|
@ -228,7 +227,7 @@ public class BufferedTokenStream implements TokenStream {
|
|||
return tokens.get(p-k);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@Override
|
||||
public Token LT(int k) {
|
||||
lazyInit();
|
||||
|
@ -455,7 +454,7 @@ public class BufferedTokenStream implements TokenStream {
|
|||
public String getSourceName() { return tokenSource.getSourceName(); }
|
||||
|
||||
/** Get the text of all tokens in this buffer. */
|
||||
@NotNull
|
||||
|
||||
@Override
|
||||
public String getText() {
|
||||
lazyInit();
|
||||
|
@ -463,7 +462,7 @@ public class BufferedTokenStream implements TokenStream {
|
|||
return getText(Interval.of(0,size()-1));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@Override
|
||||
public String getText(Interval interval) {
|
||||
int start = interval.a;
|
||||
|
@ -481,13 +480,13 @@ public class BufferedTokenStream implements TokenStream {
|
|||
return buf.toString();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@Override
|
||||
public String getText(RuleContext ctx) {
|
||||
return getText(ctx.getSourceInterval());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@Override
|
||||
public String getText(Token start, Token stop) {
|
||||
if ( start!=null && stop!=null ) {
|
||||
|
|
|
@ -51,6 +51,5 @@ public interface CharStream extends IntStream {
|
|||
* @throws UnsupportedOperationException if the stream does not support
|
||||
* getting the text of the specified interval
|
||||
*/
|
||||
@NotNull
|
||||
public String getText(@NotNull Interval interval);
|
||||
public String getText(Interval interval);
|
||||
}
|
||||
|
|
|
@ -47,20 +47,24 @@ public class CommonToken implements WritableToken, Serializable {
|
|||
* This is the backing field for {@link #getType} and {@link #setType}.
|
||||
*/
|
||||
protected int type;
|
||||
|
||||
/**
|
||||
* This is the backing field for {@link #getLine} and {@link #setLine}.
|
||||
*/
|
||||
protected int line;
|
||||
|
||||
/**
|
||||
* This is the backing field for {@link #getCharPositionInLine} and
|
||||
* {@link #setCharPositionInLine}.
|
||||
*/
|
||||
protected int charPositionInLine = -1; // set to invalid position
|
||||
|
||||
/**
|
||||
* This is the backing field for {@link #getChannel} and
|
||||
* {@link #setChannel}.
|
||||
*/
|
||||
protected int channel=DEFAULT_CHANNEL;
|
||||
|
||||
/**
|
||||
* This is the backing field for {@link #getTokenSource} and
|
||||
* {@link #getInputStream}.
|
||||
|
@ -71,7 +75,7 @@ public class CommonToken implements WritableToken, Serializable {
|
|||
* the same source and input stream share a reference to the same
|
||||
* {@link Pair} containing these values.</p>
|
||||
*/
|
||||
@NotNull
|
||||
|
||||
protected Pair<TokenSource, CharStream> source;
|
||||
|
||||
/**
|
||||
|
@ -110,7 +114,7 @@ public class CommonToken implements WritableToken, Serializable {
|
|||
this.source = EMPTY_SOURCE;
|
||||
}
|
||||
|
||||
public CommonToken(@NotNull Pair<TokenSource, CharStream> source, int type, int channel, int start, int stop) {
|
||||
public CommonToken(Pair<TokenSource, CharStream> source, int type, int channel, int start, int stop) {
|
||||
this.source = source;
|
||||
this.type = type;
|
||||
this.channel = channel;
|
||||
|
@ -149,7 +153,7 @@ public class CommonToken implements WritableToken, Serializable {
|
|||
*
|
||||
* @param oldToken The token to copy.
|
||||
*/
|
||||
public CommonToken(@NotNull Token oldToken) {
|
||||
public CommonToken(Token oldToken) {
|
||||
type = oldToken.getType();
|
||||
line = oldToken.getLine();
|
||||
index = oldToken.getTokenIndex();
|
||||
|
|
|
@ -30,8 +30,6 @@
|
|||
|
||||
package org.antlr.v4.runtime;
|
||||
|
||||
import org.antlr.v4.runtime.misc.NotNull;
|
||||
|
||||
/**
|
||||
* This class extends {@link BufferedTokenStream} with functionality to filter
|
||||
* token streams to tokens on a particular channel (tokens where
|
||||
|
@ -72,7 +70,7 @@ public class CommonTokenStream extends BufferedTokenStream {
|
|||
*
|
||||
* @param tokenSource The token source.
|
||||
*/
|
||||
public CommonTokenStream(@NotNull TokenSource tokenSource) {
|
||||
public CommonTokenStream(TokenSource tokenSource) {
|
||||
super(tokenSource);
|
||||
}
|
||||
|
||||
|
@ -86,7 +84,7 @@ public class CommonTokenStream extends BufferedTokenStream {
|
|||
* @param tokenSource The token source.
|
||||
* @param channel The channel to use for filtering tokens.
|
||||
*/
|
||||
public CommonTokenStream(@NotNull TokenSource tokenSource, int channel) {
|
||||
public CommonTokenStream(TokenSource tokenSource, int channel) {
|
||||
this(tokenSource);
|
||||
this.channel = channel;
|
||||
}
|
||||
|
|
|
@ -79,7 +79,7 @@ public class DefaultErrorStrategy implements ANTLRErrorStrategy {
|
|||
*
|
||||
* @param recognizer the parser instance
|
||||
*/
|
||||
protected void beginErrorCondition(@NotNull Parser recognizer) {
|
||||
protected void beginErrorCondition(Parser recognizer) {
|
||||
errorRecoveryMode = true;
|
||||
}
|
||||
|
||||
|
@ -97,7 +97,7 @@ public class DefaultErrorStrategy implements ANTLRErrorStrategy {
|
|||
*
|
||||
* @param recognizer
|
||||
*/
|
||||
protected void endErrorCondition(@NotNull Parser recognizer) {
|
||||
protected void endErrorCondition(Parser recognizer) {
|
||||
errorRecoveryMode = false;
|
||||
lastErrorStates = null;
|
||||
lastErrorIndex = -1;
|
||||
|
@ -294,8 +294,8 @@ public class DefaultErrorStrategy implements ANTLRErrorStrategy {
|
|||
* @param recognizer the parser instance
|
||||
* @param e the recognition exception
|
||||
*/
|
||||
protected void reportNoViableAlternative(@NotNull Parser recognizer,
|
||||
@NotNull NoViableAltException e)
|
||||
protected void reportNoViableAlternative(Parser recognizer,
|
||||
NoViableAltException e)
|
||||
{
|
||||
TokenStream tokens = recognizer.getInputStream();
|
||||
String input;
|
||||
|
@ -319,8 +319,8 @@ public class DefaultErrorStrategy implements ANTLRErrorStrategy {
|
|||
* @param recognizer the parser instance
|
||||
* @param e the recognition exception
|
||||
*/
|
||||
protected void reportInputMismatch(@NotNull Parser recognizer,
|
||||
@NotNull InputMismatchException e)
|
||||
protected void reportInputMismatch(Parser recognizer,
|
||||
InputMismatchException e)
|
||||
{
|
||||
String msg = "mismatched input "+getTokenErrorDisplay(e.getOffendingToken())+
|
||||
" expecting "+e.getExpectedTokens().toString(recognizer.getVocabulary());
|
||||
|
@ -336,8 +336,8 @@ public class DefaultErrorStrategy implements ANTLRErrorStrategy {
|
|||
* @param recognizer the parser instance
|
||||
* @param e the recognition exception
|
||||
*/
|
||||
protected void reportFailedPredicate(@NotNull Parser recognizer,
|
||||
@NotNull FailedPredicateException e)
|
||||
protected void reportFailedPredicate(Parser recognizer,
|
||||
FailedPredicateException e)
|
||||
{
|
||||
String ruleName = recognizer.getRuleNames()[recognizer._ctx.getRuleIndex()];
|
||||
String msg = "rule "+ruleName+" "+e.getMessage();
|
||||
|
@ -362,7 +362,7 @@ public class DefaultErrorStrategy implements ANTLRErrorStrategy {
|
|||
*
|
||||
* @param recognizer the parser instance
|
||||
*/
|
||||
protected void reportUnwantedToken(@NotNull Parser recognizer) {
|
||||
protected void reportUnwantedToken(Parser recognizer) {
|
||||
if (inErrorRecoveryMode(recognizer)) {
|
||||
return;
|
||||
}
|
||||
|
@ -394,7 +394,7 @@ public class DefaultErrorStrategy implements ANTLRErrorStrategy {
|
|||
*
|
||||
* @param recognizer the parser instance
|
||||
*/
|
||||
protected void reportMissingToken(@NotNull Parser recognizer) {
|
||||
protected void reportMissingToken(Parser recognizer) {
|
||||
if (inErrorRecoveryMode(recognizer)) {
|
||||
return;
|
||||
}
|
||||
|
@ -498,7 +498,7 @@ public class DefaultErrorStrategy implements ANTLRErrorStrategy {
|
|||
* @return {@code true} if single-token insertion is a viable recovery
|
||||
* strategy for the current mismatched input, otherwise {@code false}
|
||||
*/
|
||||
protected boolean singleTokenInsertion(@NotNull Parser recognizer) {
|
||||
protected boolean singleTokenInsertion(Parser recognizer) {
|
||||
int currentSymbolType = recognizer.getInputStream().LA(1);
|
||||
// if current token is consistent with what could come after current
|
||||
// ATN state, then we know we're missing a token; error recovery
|
||||
|
@ -534,8 +534,7 @@ public class DefaultErrorStrategy implements ANTLRErrorStrategy {
|
|||
* deletion successfully recovers from the mismatched input, otherwise
|
||||
* {@code null}
|
||||
*/
|
||||
@Nullable
|
||||
protected Token singleTokenDeletion(@NotNull Parser recognizer) {
|
||||
protected Token singleTokenDeletion(Parser recognizer) {
|
||||
int nextTokenType = recognizer.getInputStream().LA(2);
|
||||
IntervalSet expecting = getExpectedTokens(recognizer);
|
||||
if ( expecting.contains(nextTokenType) ) {
|
||||
|
@ -574,8 +573,7 @@ public class DefaultErrorStrategy implements ANTLRErrorStrategy {
|
|||
* If you change what tokens must be created by the lexer,
|
||||
* override this method to create the appropriate tokens.
|
||||
*/
|
||||
@NotNull
|
||||
protected Token getMissingSymbol(@NotNull Parser recognizer) {
|
||||
protected Token getMissingSymbol(Parser recognizer) {
|
||||
Token currentSymbol = recognizer.getCurrentToken();
|
||||
IntervalSet expecting = getExpectedTokens(recognizer);
|
||||
int expectedTokenType = expecting.getMinElement(); // get any element
|
||||
|
@ -594,8 +592,8 @@ public class DefaultErrorStrategy implements ANTLRErrorStrategy {
|
|||
current.getLine(), current.getCharPositionInLine());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
protected IntervalSet getExpectedTokens(@NotNull Parser recognizer) {
|
||||
|
||||
protected IntervalSet getExpectedTokens(Parser recognizer) {
|
||||
return recognizer.getExpectedTokens();
|
||||
}
|
||||
|
||||
|
@ -621,16 +619,16 @@ public class DefaultErrorStrategy implements ANTLRErrorStrategy {
|
|||
return escapeWSAndQuote(s);
|
||||
}
|
||||
|
||||
protected String getSymbolText(@NotNull Token symbol) {
|
||||
protected String getSymbolText(Token symbol) {
|
||||
return symbol.getText();
|
||||
}
|
||||
|
||||
protected int getSymbolType(@NotNull Token symbol) {
|
||||
protected int getSymbolType(Token symbol) {
|
||||
return symbol.getType();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
protected String escapeWSAndQuote(@NotNull String s) {
|
||||
|
||||
protected String escapeWSAndQuote(String s) {
|
||||
// if ( s==null ) return s;
|
||||
s = s.replace("\n","\\n");
|
||||
s = s.replace("\r","\\r");
|
||||
|
@ -730,8 +728,7 @@ public class DefaultErrorStrategy implements ANTLRErrorStrategy {
|
|||
* Like Grosch I implement context-sensitive FOLLOW sets that are combined
|
||||
* at run-time upon error to avoid overhead during parsing.
|
||||
*/
|
||||
@NotNull
|
||||
protected IntervalSet getErrorRecoverySet(@NotNull Parser recognizer) {
|
||||
protected IntervalSet getErrorRecoverySet(Parser recognizer) {
|
||||
ATN atn = recognizer.getInterpreter().atn;
|
||||
RuleContext ctx = recognizer._ctx;
|
||||
IntervalSet recoverSet = new IntervalSet();
|
||||
|
@ -749,7 +746,7 @@ public class DefaultErrorStrategy implements ANTLRErrorStrategy {
|
|||
}
|
||||
|
||||
/** Consume tokens until one matches the given token set. */
|
||||
protected void consumeUntil(@NotNull Parser recognizer, @NotNull IntervalSet set) {
|
||||
protected void consumeUntil(Parser recognizer, IntervalSet set) {
|
||||
// System.err.println("consumeUntil("+set.toString(recognizer.getTokenNames())+")");
|
||||
int ttype = recognizer.getInputStream().LA(1);
|
||||
while (ttype != Token.EOF && !set.contains(ttype) ) {
|
||||
|
|
|
@ -35,7 +35,6 @@ import org.antlr.v4.runtime.atn.ATNConfigSet;
|
|||
import org.antlr.v4.runtime.dfa.DFA;
|
||||
import org.antlr.v4.runtime.misc.Interval;
|
||||
import org.antlr.v4.runtime.misc.NotNull;
|
||||
import org.antlr.v4.runtime.misc.Nullable;
|
||||
|
||||
import java.util.BitSet;
|
||||
|
||||
|
@ -86,13 +85,13 @@ public class DiagnosticErrorListener extends BaseErrorListener {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void reportAmbiguity(@NotNull Parser recognizer,
|
||||
@NotNull DFA dfa,
|
||||
public void reportAmbiguity(Parser recognizer,
|
||||
DFA dfa,
|
||||
int startIndex,
|
||||
int stopIndex,
|
||||
boolean exact,
|
||||
@Nullable BitSet ambigAlts,
|
||||
@NotNull ATNConfigSet configs)
|
||||
BitSet ambigAlts,
|
||||
ATNConfigSet configs)
|
||||
{
|
||||
if (exactOnly && !exact) {
|
||||
return;
|
||||
|
@ -107,12 +106,12 @@ public class DiagnosticErrorListener extends BaseErrorListener {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void reportAttemptingFullContext(@NotNull Parser recognizer,
|
||||
@NotNull DFA dfa,
|
||||
public void reportAttemptingFullContext(Parser recognizer,
|
||||
DFA dfa,
|
||||
int startIndex,
|
||||
int stopIndex,
|
||||
@Nullable BitSet conflictingAlts,
|
||||
@NotNull ATNConfigSet configs)
|
||||
BitSet conflictingAlts,
|
||||
ATNConfigSet configs)
|
||||
{
|
||||
String format = "reportAttemptingFullContext d=%s, input='%s'";
|
||||
String decision = getDecisionDescription(recognizer, dfa);
|
||||
|
@ -122,12 +121,12 @@ public class DiagnosticErrorListener extends BaseErrorListener {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void reportContextSensitivity(@NotNull Parser recognizer,
|
||||
@NotNull DFA dfa,
|
||||
public void reportContextSensitivity(Parser recognizer,
|
||||
DFA dfa,
|
||||
int startIndex,
|
||||
int stopIndex,
|
||||
int prediction,
|
||||
@NotNull ATNConfigSet configs)
|
||||
ATNConfigSet configs)
|
||||
{
|
||||
String format = "reportContextSensitivity d=%s, input='%s'";
|
||||
String decision = getDecisionDescription(recognizer, dfa);
|
||||
|
@ -136,7 +135,7 @@ public class DiagnosticErrorListener extends BaseErrorListener {
|
|||
recognizer.notifyErrorListeners(message);
|
||||
}
|
||||
|
||||
protected String getDecisionDescription(@NotNull Parser recognizer, @NotNull DFA dfa) {
|
||||
protected String getDecisionDescription(Parser recognizer, DFA dfa) {
|
||||
int decision = dfa.decision;
|
||||
int ruleIndex = dfa.atnStartState.ruleIndex;
|
||||
|
||||
|
@ -164,8 +163,7 @@ public class DiagnosticErrorListener extends BaseErrorListener {
|
|||
* @return Returns {@code reportedAlts} if it is not {@code null}, otherwise
|
||||
* returns the set of alternatives represented in {@code configs}.
|
||||
*/
|
||||
@NotNull
|
||||
protected BitSet getConflictingAlts(@Nullable BitSet reportedAlts, @NotNull ATNConfigSet configs) {
|
||||
protected BitSet getConflictingAlts(BitSet reportedAlts, ATNConfigSet configs) {
|
||||
if (reportedAlts != null) {
|
||||
return reportedAlts;
|
||||
}
|
||||
|
|
|
@ -47,17 +47,17 @@ public class FailedPredicateException extends RecognitionException {
|
|||
private final int predicateIndex;
|
||||
private final String predicate;
|
||||
|
||||
public FailedPredicateException(@NotNull Parser recognizer) {
|
||||
public FailedPredicateException(Parser recognizer) {
|
||||
this(recognizer, null);
|
||||
}
|
||||
|
||||
public FailedPredicateException(@NotNull Parser recognizer, @Nullable String predicate) {
|
||||
public FailedPredicateException(Parser recognizer, String predicate) {
|
||||
this(recognizer, predicate, null);
|
||||
}
|
||||
|
||||
public FailedPredicateException(@NotNull Parser recognizer,
|
||||
@Nullable String predicate,
|
||||
@Nullable String message)
|
||||
public FailedPredicateException(Parser recognizer,
|
||||
String predicate,
|
||||
String message)
|
||||
{
|
||||
super(formatMessage(predicate, message), recognizer, recognizer.getInputStream(), recognizer._ctx);
|
||||
ATNState s = recognizer.getInterpreter().atn.states.get(recognizer.getState());
|
||||
|
@ -84,13 +84,13 @@ public class FailedPredicateException extends RecognitionException {
|
|||
return predicateIndex;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
public String getPredicate() {
|
||||
return predicate;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static String formatMessage(@Nullable String predicate, @Nullable String message) {
|
||||
|
||||
private static String formatMessage(String predicate, String message) {
|
||||
if (message != null) {
|
||||
return message;
|
||||
}
|
||||
|
|
|
@ -29,13 +29,11 @@
|
|||
*/
|
||||
package org.antlr.v4.runtime;
|
||||
|
||||
import org.antlr.v4.runtime.misc.NotNull;
|
||||
|
||||
/** This signifies any kind of mismatched input exceptions such as
|
||||
* when the current input does not match the expected token.
|
||||
*/
|
||||
public class InputMismatchException extends RecognitionException {
|
||||
public InputMismatchException(@NotNull Parser recognizer) {
|
||||
public InputMismatchException(Parser recognizer) {
|
||||
super(recognizer, recognizer.getInputStream(), recognizer._ctx);
|
||||
this.setOffendingToken(recognizer.getCurrentToken());
|
||||
}
|
||||
|
|
|
@ -237,6 +237,6 @@ public interface IntStream {
|
|||
* non-null, non-empty string. If such a name is not known, this method
|
||||
* returns {@link #UNKNOWN_SOURCE_NAME}.
|
||||
*/
|
||||
@NotNull
|
||||
|
||||
public String getSourceName();
|
||||
}
|
||||
|
|
|
@ -29,8 +29,6 @@
|
|||
*/
|
||||
package org.antlr.v4.runtime;
|
||||
|
||||
import org.antlr.v4.runtime.misc.Nullable;
|
||||
|
||||
/**
|
||||
* This class extends {@link ParserRuleContext} by allowing the value of
|
||||
* {@link #getRuleIndex} to be explicitly set for the context.
|
||||
|
@ -57,7 +55,7 @@ public class InterpreterRuleContext extends ParserRuleContext {
|
|||
* @param invokingStateNumber The invoking state number.
|
||||
* @param ruleIndex The rule index for the current context.
|
||||
*/
|
||||
public InterpreterRuleContext(@Nullable ParserRuleContext parent,
|
||||
public InterpreterRuleContext(ParserRuleContext parent,
|
||||
int invokingStateNumber,
|
||||
int ruleIndex)
|
||||
{
|
||||
|
|
|
@ -48,7 +48,7 @@ public class LexerInterpreter extends Lexer {
|
|||
protected final String[] ruleNames;
|
||||
protected final String[] modeNames;
|
||||
|
||||
@NotNull
|
||||
|
||||
private final Vocabulary vocabulary;
|
||||
|
||||
protected final DFA[] _decisionToDFA;
|
||||
|
@ -60,7 +60,7 @@ public class LexerInterpreter extends Lexer {
|
|||
this(grammarFileName, VocabularyImpl.fromTokenNames(tokenNames.toArray(new String[tokenNames.size()])), ruleNames, modeNames, atn, input);
|
||||
}
|
||||
|
||||
public LexerInterpreter(String grammarFileName, @NotNull Vocabulary vocabulary, Collection<String> ruleNames, Collection<String> modeNames, ATN atn, CharStream input) {
|
||||
public LexerInterpreter(String grammarFileName, Vocabulary vocabulary, Collection<String> ruleNames, Collection<String> modeNames, ATN atn, CharStream input) {
|
||||
super(input);
|
||||
|
||||
if (atn.grammarType != ATNType.LEXER) {
|
||||
|
|
|
@ -32,7 +32,6 @@ package org.antlr.v4.runtime;
|
|||
|
||||
import org.antlr.v4.runtime.atn.ATNConfigSet;
|
||||
import org.antlr.v4.runtime.misc.Interval;
|
||||
import org.antlr.v4.runtime.misc.NotNull;
|
||||
import org.antlr.v4.runtime.misc.Nullable;
|
||||
import org.antlr.v4.runtime.misc.Utils;
|
||||
|
||||
|
@ -43,13 +42,12 @@ public class LexerNoViableAltException extends RecognitionException {
|
|||
private final int startIndex;
|
||||
|
||||
/** Which configurations did we try at input.index() that couldn't match input.LA(1)? */
|
||||
@Nullable
|
||||
private final ATNConfigSet deadEndConfigs;
|
||||
|
||||
public LexerNoViableAltException(@Nullable Lexer lexer,
|
||||
@NotNull CharStream input,
|
||||
public LexerNoViableAltException(Lexer lexer,
|
||||
CharStream input,
|
||||
int startIndex,
|
||||
@Nullable ATNConfigSet deadEndConfigs) {
|
||||
ATNConfigSet deadEndConfigs) {
|
||||
super(lexer, input, null);
|
||||
this.startIndex = startIndex;
|
||||
this.deadEndConfigs = deadEndConfigs;
|
||||
|
@ -59,7 +57,7 @@ public class LexerNoViableAltException extends RecognitionException {
|
|||
return startIndex;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
public ATNConfigSet getDeadEndConfigs() {
|
||||
return deadEndConfigs;
|
||||
}
|
||||
|
|
|
@ -53,7 +53,7 @@ public class ListTokenSource implements TokenSource {
|
|||
* {@link TokenSource}.
|
||||
* @exception NullPointerException if {@code tokens} is {@code null}
|
||||
*/
|
||||
public ListTokenSource(@NotNull List<? extends Token> tokens) {
|
||||
public ListTokenSource(List<? extends Token> tokens) {
|
||||
this(tokens, null);
|
||||
}
|
||||
|
||||
|
@ -70,7 +70,7 @@ public class ListTokenSource implements TokenSource {
|
|||
*
|
||||
* @exception NullPointerException if {@code tokens} is {@code null}
|
||||
*/
|
||||
public ListTokenSource(@NotNull List<? extends Token> tokens, String sourceName) {
|
||||
public ListTokenSource(List<? extends Token> tokens, String sourceName) {
|
||||
if (tokens == null) {
|
||||
throw new NullPointerException("tokens cannot be null");
|
||||
}
|
||||
|
@ -216,7 +216,7 @@ public class ListTokenSource implements TokenSource {
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void setTokenFactory(@NotNull TokenFactory<?> factory) {
|
||||
public void setTokenFactory(TokenFactory<?> factory) {
|
||||
this._factory = factory;
|
||||
}
|
||||
|
||||
|
@ -224,7 +224,6 @@ public class ListTokenSource implements TokenSource {
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
@NotNull
|
||||
public TokenFactory<?> getTokenFactory() {
|
||||
return _factory;
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ import org.antlr.v4.runtime.misc.Nullable;
|
|||
*/
|
||||
public class NoViableAltException extends RecognitionException {
|
||||
/** Which configurations did we try at input.index() that couldn't match input.LT(1)? */
|
||||
@Nullable
|
||||
|
||||
private final ATNConfigSet deadEndConfigs;
|
||||
|
||||
/** The token object at the start index; the input stream might
|
||||
|
@ -48,10 +48,10 @@ public class NoViableAltException extends RecognitionException {
|
|||
* time the error occurred, of course the stream needs to keep a
|
||||
* buffer all of the tokens but later we might not have access to those.)
|
||||
*/
|
||||
@NotNull
|
||||
|
||||
private final Token startToken;
|
||||
|
||||
public NoViableAltException(@NotNull Parser recognizer) { // LL(1) error
|
||||
public NoViableAltException(Parser recognizer) { // LL(1) error
|
||||
this(recognizer,
|
||||
recognizer.getInputStream(),
|
||||
recognizer.getCurrentToken(),
|
||||
|
@ -60,12 +60,12 @@ public class NoViableAltException extends RecognitionException {
|
|||
recognizer._ctx);
|
||||
}
|
||||
|
||||
public NoViableAltException(@NotNull Parser recognizer,
|
||||
@NotNull TokenStream input,
|
||||
@NotNull Token startToken,
|
||||
@NotNull Token offendingToken,
|
||||
@Nullable ATNConfigSet deadEndConfigs,
|
||||
@NotNull ParserRuleContext ctx)
|
||||
public NoViableAltException(Parser recognizer,
|
||||
TokenStream input,
|
||||
Token startToken,
|
||||
Token offendingToken,
|
||||
ATNConfigSet deadEndConfigs,
|
||||
ParserRuleContext ctx)
|
||||
{
|
||||
super(recognizer, input, ctx);
|
||||
this.deadEndConfigs = deadEndConfigs;
|
||||
|
@ -73,12 +73,12 @@ public class NoViableAltException extends RecognitionException {
|
|||
this.setOffendingToken(offendingToken);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
public Token getStartToken() {
|
||||
return startToken;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
public ATNConfigSet getDeadEndConfigs() {
|
||||
return deadEndConfigs;
|
||||
}
|
||||
|
|
|
@ -118,7 +118,7 @@ public abstract class Parser extends Recognizer<Token, ParserATNSimulator> {
|
|||
* @see #getErrorHandler
|
||||
* @see #setErrorHandler
|
||||
*/
|
||||
@NotNull
|
||||
|
||||
protected ANTLRErrorStrategy _errHandler = new DefaultErrorStrategy();
|
||||
|
||||
/**
|
||||
|
@ -166,7 +166,6 @@ public abstract class Parser extends Recognizer<Token, ParserATNSimulator> {
|
|||
*
|
||||
* @see #addParseListener
|
||||
*/
|
||||
@Nullable
|
||||
protected List<ParseTreeListener> _parseListeners;
|
||||
|
||||
/**
|
||||
|
@ -212,7 +211,6 @@ public abstract class Parser extends Recognizer<Token, ParserATNSimulator> {
|
|||
* {@code ttype} and the error strategy could not recover from the
|
||||
* mismatched symbol
|
||||
*/
|
||||
@NotNull
|
||||
public Token match(int ttype) throws RecognitionException {
|
||||
Token t = getCurrentToken();
|
||||
if ( t.getType()==ttype ) {
|
||||
|
@ -247,7 +245,6 @@ public abstract class Parser extends Recognizer<Token, ParserATNSimulator> {
|
|||
* a wildcard and the error strategy could not recover from the mismatched
|
||||
* symbol
|
||||
*/
|
||||
@NotNull
|
||||
public Token matchWildcard() throws RecognitionException {
|
||||
Token t = getCurrentToken();
|
||||
if (t.getType() > 0) {
|
||||
|
@ -321,7 +318,7 @@ public abstract class Parser extends Recognizer<Token, ParserATNSimulator> {
|
|||
return getParseListeners().contains(TrimToSizeListener.INSTANCE);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
public List<ParseTreeListener> getParseListeners() {
|
||||
List<ParseTreeListener> listeners = _parseListeners;
|
||||
if (listeners == null) {
|
||||
|
@ -360,7 +357,7 @@ public abstract class Parser extends Recognizer<Token, ParserATNSimulator> {
|
|||
*
|
||||
* @throws NullPointerException if {@code} listener is {@code null}
|
||||
*/
|
||||
public void addParseListener(@NotNull ParseTreeListener listener) {
|
||||
public void addParseListener(ParseTreeListener listener) {
|
||||
if (listener == null) {
|
||||
throw new NullPointerException("listener");
|
||||
}
|
||||
|
@ -455,7 +452,7 @@ public abstract class Parser extends Recognizer<Token, ParserATNSimulator> {
|
|||
* @throws UnsupportedOperationException if the current parser does not
|
||||
* implement the {@link #getSerializedATN()} method.
|
||||
*/
|
||||
@NotNull
|
||||
|
||||
public ATN getATNWithBypassAlts() {
|
||||
String serializedAtn = getSerializedATN();
|
||||
if (serializedAtn == null) {
|
||||
|
@ -508,12 +505,12 @@ public abstract class Parser extends Recognizer<Token, ParserATNSimulator> {
|
|||
return m.compile(pattern, patternRuleIndex);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
public ANTLRErrorStrategy getErrorHandler() {
|
||||
return _errHandler;
|
||||
}
|
||||
|
||||
public void setErrorHandler(@NotNull ANTLRErrorStrategy handler) {
|
||||
public void setErrorHandler(ANTLRErrorStrategy handler) {
|
||||
this._errHandler = handler;
|
||||
}
|
||||
|
||||
|
@ -539,17 +536,17 @@ public abstract class Parser extends Recognizer<Token, ParserATNSimulator> {
|
|||
/** Match needs to return the current input symbol, which gets put
|
||||
* into the label for the associated token ref; e.g., x=ID.
|
||||
*/
|
||||
@NotNull
|
||||
|
||||
public Token getCurrentToken() {
|
||||
return _input.LT(1);
|
||||
}
|
||||
|
||||
public final void notifyErrorListeners(@NotNull String msg) {
|
||||
public final void notifyErrorListeners(String msg) {
|
||||
notifyErrorListeners(getCurrentToken(), msg, null);
|
||||
}
|
||||
|
||||
public void notifyErrorListeners(@NotNull Token offendingToken, @NotNull String msg,
|
||||
@Nullable RecognitionException e)
|
||||
public void notifyErrorListeners(Token offendingToken, String msg,
|
||||
RecognitionException e)
|
||||
{
|
||||
_syntaxErrors++;
|
||||
int line = -1;
|
||||
|
@ -621,7 +618,7 @@ public abstract class Parser extends Recognizer<Token, ParserATNSimulator> {
|
|||
* Always called by generated parsers upon entry to a rule. Access field
|
||||
* {@link #_ctx} get the current context.
|
||||
*/
|
||||
public void enterRule(@NotNull ParserRuleContext localctx, int state, int ruleIndex) {
|
||||
public void enterRule(ParserRuleContext localctx, int state, int ruleIndex) {
|
||||
setState(state);
|
||||
_ctx = localctx;
|
||||
_ctx.start = _input.LT(1);
|
||||
|
@ -746,7 +743,7 @@ public abstract class Parser extends Recognizer<Token, ParserATNSimulator> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean precpred(@Nullable RuleContext localctx, int precedence) {
|
||||
public boolean precpred(RuleContext localctx, int precedence) {
|
||||
return precedence >= _precedenceStack.peek();
|
||||
}
|
||||
|
||||
|
@ -806,12 +803,11 @@ public abstract class Parser extends Recognizer<Token, ParserATNSimulator> {
|
|||
*
|
||||
* @see ATN#getExpectedTokens(int, RuleContext)
|
||||
*/
|
||||
@NotNull
|
||||
public IntervalSet getExpectedTokens() {
|
||||
return getATN().getExpectedTokens(getState(), getContext());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
public IntervalSet getExpectedTokensWithinCurrentRule() {
|
||||
ATN atn = getInterpreter().atn;
|
||||
ATNState s = atn.states.get(getState());
|
||||
|
|
|
@ -78,7 +78,7 @@ public class ParserInterpreter extends Parser {
|
|||
@Deprecated
|
||||
protected final String[] tokenNames;
|
||||
protected final String[] ruleNames;
|
||||
@NotNull
|
||||
|
||||
private final Vocabulary vocabulary;
|
||||
|
||||
protected final Deque<Pair<ParserRuleContext, Integer>> _parentContextStack = new ArrayDeque<Pair<ParserRuleContext, Integer>>();
|
||||
|
@ -92,7 +92,7 @@ public class ParserInterpreter extends Parser {
|
|||
this(grammarFileName, VocabularyImpl.fromTokenNames(tokenNames.toArray(new String[tokenNames.size()])), ruleNames, atn, input);
|
||||
}
|
||||
|
||||
public ParserInterpreter(String grammarFileName, @NotNull Vocabulary vocabulary,
|
||||
public ParserInterpreter(String grammarFileName, Vocabulary vocabulary,
|
||||
Collection<String> ruleNames, ATN atn, TokenStream input)
|
||||
{
|
||||
super(input);
|
||||
|
|
|
@ -30,14 +30,12 @@
|
|||
package org.antlr.v4.runtime;
|
||||
|
||||
import org.antlr.v4.runtime.misc.Interval;
|
||||
import org.antlr.v4.runtime.misc.Nullable;
|
||||
import org.antlr.v4.runtime.tree.ErrorNode;
|
||||
import org.antlr.v4.runtime.tree.ErrorNodeImpl;
|
||||
import org.antlr.v4.runtime.tree.ParseTree;
|
||||
import org.antlr.v4.runtime.tree.ParseTreeListener;
|
||||
import org.antlr.v4.runtime.tree.TerminalNode;
|
||||
import org.antlr.v4.runtime.tree.TerminalNodeImpl;
|
||||
import org.antlr.v4.runtime.tree.pattern.RuleTagToken;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
|
@ -115,7 +113,7 @@ public class ParserRuleContext extends RuleContext {
|
|||
this.stop = ctx.stop;
|
||||
}
|
||||
|
||||
public ParserRuleContext(@Nullable ParserRuleContext parent, int invokingStateNumber) {
|
||||
public ParserRuleContext(ParserRuleContext parent, int invokingStateNumber) {
|
||||
super(parent, invokingStateNumber);
|
||||
}
|
||||
|
||||
|
@ -278,13 +276,13 @@ public class ParserRuleContext extends RuleContext {
|
|||
return Interval.of(start.getTokenIndex(), stop.getTokenIndex());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the initial token in this context.
|
||||
/**
|
||||
* Get the initial token in this context.
|
||||
* Note that the range from start to stop is inclusive, so for rules that do not consume anything
|
||||
* (for example, zero length or error productions) this token may exceed stop.
|
||||
*/
|
||||
public Token getStart() { return start; }
|
||||
/**
|
||||
/**
|
||||
* Get the final token in this context.
|
||||
* Note that the range from start to stop is inclusive, so for rules that do not consume anything
|
||||
* (for example, zero length or error productions) this token may precede start.
|
||||
|
|
|
@ -31,8 +31,6 @@ package org.antlr.v4.runtime;
|
|||
|
||||
import org.antlr.v4.runtime.atn.ATNConfigSet;
|
||||
import org.antlr.v4.runtime.dfa.DFA;
|
||||
import org.antlr.v4.runtime.misc.NotNull;
|
||||
import org.antlr.v4.runtime.misc.Nullable;
|
||||
|
||||
import java.util.BitSet;
|
||||
import java.util.Collection;
|
||||
|
@ -56,12 +54,12 @@ public class ProxyErrorListener implements ANTLRErrorListener {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void syntaxError(@NotNull Recognizer<?, ?> recognizer,
|
||||
@Nullable Object offendingSymbol,
|
||||
public void syntaxError(Recognizer<?, ?> recognizer,
|
||||
Object offendingSymbol,
|
||||
int line,
|
||||
int charPositionInLine,
|
||||
@NotNull String msg,
|
||||
@Nullable RecognitionException e)
|
||||
String msg,
|
||||
RecognitionException e)
|
||||
{
|
||||
for (ANTLRErrorListener listener : delegates) {
|
||||
listener.syntaxError(recognizer, offendingSymbol, line, charPositionInLine, msg, e);
|
||||
|
@ -69,13 +67,13 @@ public class ProxyErrorListener implements ANTLRErrorListener {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void reportAmbiguity(@NotNull Parser recognizer,
|
||||
@NotNull DFA dfa,
|
||||
public void reportAmbiguity(Parser recognizer,
|
||||
DFA dfa,
|
||||
int startIndex,
|
||||
int stopIndex,
|
||||
boolean exact,
|
||||
@Nullable BitSet ambigAlts,
|
||||
@NotNull ATNConfigSet configs)
|
||||
BitSet ambigAlts,
|
||||
ATNConfigSet configs)
|
||||
{
|
||||
for (ANTLRErrorListener listener : delegates) {
|
||||
listener.reportAmbiguity(recognizer, dfa, startIndex, stopIndex, exact, ambigAlts, configs);
|
||||
|
@ -83,12 +81,12 @@ public class ProxyErrorListener implements ANTLRErrorListener {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void reportAttemptingFullContext(@NotNull Parser recognizer,
|
||||
@NotNull DFA dfa,
|
||||
public void reportAttemptingFullContext(Parser recognizer,
|
||||
DFA dfa,
|
||||
int startIndex,
|
||||
int stopIndex,
|
||||
@Nullable BitSet conflictingAlts,
|
||||
@NotNull ATNConfigSet configs)
|
||||
BitSet conflictingAlts,
|
||||
ATNConfigSet configs)
|
||||
{
|
||||
for (ANTLRErrorListener listener : delegates) {
|
||||
listener.reportAttemptingFullContext(recognizer, dfa, startIndex, stopIndex, conflictingAlts, configs);
|
||||
|
@ -96,12 +94,12 @@ public class ProxyErrorListener implements ANTLRErrorListener {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void reportContextSensitivity(@NotNull Parser recognizer,
|
||||
@NotNull DFA dfa,
|
||||
public void reportContextSensitivity(Parser recognizer,
|
||||
DFA dfa,
|
||||
int startIndex,
|
||||
int stopIndex,
|
||||
int prediction,
|
||||
@NotNull ATNConfigSet configs)
|
||||
ATNConfigSet configs)
|
||||
{
|
||||
for (ANTLRErrorListener listener : delegates) {
|
||||
listener.reportContextSensitivity(recognizer, dfa, startIndex, stopIndex, prediction, configs);
|
||||
|
|
|
@ -41,13 +41,10 @@ import org.antlr.v4.runtime.misc.Nullable;
|
|||
*/
|
||||
public class RecognitionException extends RuntimeException {
|
||||
/** The {@link Recognizer} where this exception originated. */
|
||||
@Nullable
|
||||
private final Recognizer<?, ?> recognizer;
|
||||
|
||||
@Nullable
|
||||
private final RuleContext ctx;
|
||||
|
||||
@Nullable
|
||||
private final IntStream input;
|
||||
|
||||
/**
|
||||
|
@ -59,9 +56,9 @@ public class RecognitionException extends RuntimeException {
|
|||
|
||||
private int offendingState = -1;
|
||||
|
||||
public RecognitionException(@Nullable Recognizer<?, ?> recognizer,
|
||||
@Nullable IntStream input,
|
||||
@Nullable ParserRuleContext ctx)
|
||||
public RecognitionException(Recognizer<?, ?> recognizer,
|
||||
IntStream input,
|
||||
ParserRuleContext ctx)
|
||||
{
|
||||
this.recognizer = recognizer;
|
||||
this.input = input;
|
||||
|
@ -70,9 +67,9 @@ public class RecognitionException extends RuntimeException {
|
|||
}
|
||||
|
||||
public RecognitionException(String message,
|
||||
@Nullable Recognizer<?, ?> recognizer,
|
||||
@Nullable IntStream input,
|
||||
@Nullable ParserRuleContext ctx)
|
||||
Recognizer<?, ?> recognizer,
|
||||
IntStream input,
|
||||
ParserRuleContext ctx)
|
||||
{
|
||||
super(message);
|
||||
this.recognizer = recognizer;
|
||||
|
@ -108,7 +105,6 @@ public class RecognitionException extends RuntimeException {
|
|||
* @return The set of token types that could potentially follow the current
|
||||
* state in the ATN, or {@code null} if the information is not available.
|
||||
*/
|
||||
@Nullable
|
||||
public IntervalSet getExpectedTokens() {
|
||||
if (recognizer != null) {
|
||||
return recognizer.getATN().getExpectedTokens(offendingState, ctx);
|
||||
|
@ -125,7 +121,6 @@ public class RecognitionException extends RuntimeException {
|
|||
* @return The {@link RuleContext} at the time this exception was thrown.
|
||||
* If the context is not available, this method returns {@code null}.
|
||||
*/
|
||||
@Nullable
|
||||
public RuleContext getCtx() {
|
||||
return ctx;
|
||||
}
|
||||
|
@ -140,17 +135,16 @@ public class RecognitionException extends RuntimeException {
|
|||
* where this exception was thrown, or {@code null} if the stream is not
|
||||
* available.
|
||||
*/
|
||||
@Nullable
|
||||
public IntStream getInputStream() {
|
||||
return input;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
public Token getOffendingToken() {
|
||||
return offendingToken;
|
||||
}
|
||||
|
||||
protected final void setOffendingToken(@Nullable Token offendingToken) {
|
||||
protected final void setOffendingToken(Token offendingToken) {
|
||||
this.offendingToken = offendingToken;
|
||||
}
|
||||
|
||||
|
@ -162,7 +156,6 @@ public class RecognitionException extends RuntimeException {
|
|||
* @return The recognizer where this exception occurred, or {@code null} if
|
||||
* the recognizer is not available.
|
||||
*/
|
||||
@Nullable
|
||||
public Recognizer<?, ?> getRecognizer() {
|
||||
return recognizer;
|
||||
}
|
||||
|
|
|
@ -34,7 +34,6 @@ import org.antlr.v4.runtime.atn.ATN;
|
|||
import org.antlr.v4.runtime.atn.ATNSimulator;
|
||||
import org.antlr.v4.runtime.atn.ParseInfo;
|
||||
import org.antlr.v4.runtime.misc.NotNull;
|
||||
import org.antlr.v4.runtime.misc.Nullable;
|
||||
import org.antlr.v4.runtime.misc.Utils;
|
||||
|
||||
import java.util.Collections;
|
||||
|
@ -52,7 +51,7 @@ public abstract class Recognizer<Symbol, ATNInterpreter extends ATNSimulator> {
|
|||
private static final Map<String[], Map<String, Integer>> ruleIndexMapCache =
|
||||
new WeakHashMap<String[], Map<String, Integer>>();
|
||||
|
||||
@NotNull
|
||||
|
||||
private List<ANTLRErrorListener> _listeners =
|
||||
new CopyOnWriteArrayList<ANTLRErrorListener>() {{
|
||||
add(ConsoleErrorListener.INSTANCE);
|
||||
|
@ -79,7 +78,6 @@ public abstract class Recognizer<Symbol, ATNInterpreter extends ATNSimulator> {
|
|||
* @return A {@link Vocabulary} instance providing information about the
|
||||
* vocabulary used by the grammar.
|
||||
*/
|
||||
@NotNull
|
||||
@SuppressWarnings("deprecation")
|
||||
public Vocabulary getVocabulary() {
|
||||
return VocabularyImpl.fromTokenNames(getTokenNames());
|
||||
|
@ -90,7 +88,6 @@ public abstract class Recognizer<Symbol, ATNInterpreter extends ATNSimulator> {
|
|||
*
|
||||
* <p>Used for XPath and tree pattern compilation.</p>
|
||||
*/
|
||||
@NotNull
|
||||
public Map<String, Integer> getTokenTypeMap() {
|
||||
Vocabulary vocabulary = getVocabulary();
|
||||
synchronized (tokenTypeMapCache) {
|
||||
|
@ -123,7 +120,6 @@ public abstract class Recognizer<Symbol, ATNInterpreter extends ATNSimulator> {
|
|||
*
|
||||
* <p>Used for XPath and tree pattern compilation.</p>
|
||||
*/
|
||||
@NotNull
|
||||
public Map<String, Integer> getRuleIndexMap() {
|
||||
String[] ruleNames = getRuleNames();
|
||||
if (ruleNames == null) {
|
||||
|
@ -154,7 +150,6 @@ public abstract class Recognizer<Symbol, ATNInterpreter extends ATNSimulator> {
|
|||
* <p>For interpreters, we don't know their serialized ATN despite having
|
||||
* created the interpreter from it.</p>
|
||||
*/
|
||||
@NotNull
|
||||
public String getSerializedATN() {
|
||||
throw new UnsupportedOperationException("there is no serialized ATN");
|
||||
}
|
||||
|
@ -169,7 +164,6 @@ public abstract class Recognizer<Symbol, ATNInterpreter extends ATNSimulator> {
|
|||
*
|
||||
* @return The {@link ATN} used by the recognizer for prediction.
|
||||
*/
|
||||
@NotNull
|
||||
public abstract ATN getATN();
|
||||
|
||||
/**
|
||||
|
@ -177,7 +171,6 @@ public abstract class Recognizer<Symbol, ATNInterpreter extends ATNSimulator> {
|
|||
*
|
||||
* @return The ATN interpreter used by the recognizer for prediction.
|
||||
*/
|
||||
@NotNull
|
||||
public ATNInterpreter getInterpreter() {
|
||||
return _interp;
|
||||
}
|
||||
|
@ -197,13 +190,12 @@ public abstract class Recognizer<Symbol, ATNInterpreter extends ATNSimulator> {
|
|||
* @param interpreter The ATN interpreter used by the recognizer for
|
||||
* prediction.
|
||||
*/
|
||||
public void setInterpreter(@NotNull ATNInterpreter interpreter) {
|
||||
public void setInterpreter(ATNInterpreter interpreter) {
|
||||
_interp = interpreter;
|
||||
}
|
||||
|
||||
/** What is the error header, normally line/character position information? */
|
||||
@NotNull
|
||||
public String getErrorHeader(@NotNull RecognitionException e) {
|
||||
public String getErrorHeader(RecognitionException e) {
|
||||
int line = e.getOffendingToken().getLine();
|
||||
int charPositionInLine = e.getOffendingToken().getCharPositionInLine();
|
||||
return "line "+line+":"+charPositionInLine;
|
||||
|
@ -243,7 +235,7 @@ public abstract class Recognizer<Symbol, ATNInterpreter extends ATNSimulator> {
|
|||
/**
|
||||
* @exception NullPointerException if {@code listener} is {@code null}.
|
||||
*/
|
||||
public void addErrorListener(@NotNull ANTLRErrorListener listener) {
|
||||
public void addErrorListener(ANTLRErrorListener listener) {
|
||||
if (listener == null) {
|
||||
throw new NullPointerException("listener cannot be null.");
|
||||
}
|
||||
|
@ -251,7 +243,7 @@ public abstract class Recognizer<Symbol, ATNInterpreter extends ATNSimulator> {
|
|||
_listeners.add(listener);
|
||||
}
|
||||
|
||||
public void removeErrorListener(@NotNull ANTLRErrorListener listener) {
|
||||
public void removeErrorListener(ANTLRErrorListener listener) {
|
||||
_listeners.remove(listener);
|
||||
}
|
||||
|
||||
|
@ -259,7 +251,7 @@ public abstract class Recognizer<Symbol, ATNInterpreter extends ATNSimulator> {
|
|||
_listeners.clear();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
public List<? extends ANTLRErrorListener> getErrorListeners() {
|
||||
return _listeners;
|
||||
}
|
||||
|
@ -270,15 +262,15 @@ public abstract class Recognizer<Symbol, ATNInterpreter extends ATNSimulator> {
|
|||
|
||||
// subclass needs to override these if there are sempreds or actions
|
||||
// that the ATN interp needs to execute
|
||||
public boolean sempred(@Nullable RuleContext _localctx, int ruleIndex, int actionIndex) {
|
||||
public boolean sempred(RuleContext _localctx, int ruleIndex, int actionIndex) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean precpred(@Nullable RuleContext localctx, int precedence) {
|
||||
public boolean precpred(RuleContext localctx, int precedence) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void action(@Nullable RuleContext _localctx, int ruleIndex, int actionIndex) {
|
||||
public void action(RuleContext _localctx, int ruleIndex, int actionIndex) {
|
||||
}
|
||||
|
||||
public final int getState() {
|
||||
|
@ -302,8 +294,8 @@ public abstract class Recognizer<Symbol, ATNInterpreter extends ATNSimulator> {
|
|||
|
||||
public abstract void setInputStream(IntStream input);
|
||||
|
||||
@NotNull
|
||||
|
||||
public abstract TokenFactory<?> getTokenFactory();
|
||||
|
||||
public abstract void setTokenFactory(@NotNull TokenFactory<?> input);
|
||||
public abstract void setTokenFactory(TokenFactory<?> input);
|
||||
}
|
||||
|
|
|
@ -30,7 +30,6 @@
|
|||
package org.antlr.v4.runtime;
|
||||
|
||||
import org.antlr.v4.runtime.misc.Interval;
|
||||
import org.antlr.v4.runtime.misc.Nullable;
|
||||
import org.antlr.v4.runtime.tree.ParseTree;
|
||||
import org.antlr.v4.runtime.tree.ParseTreeVisitor;
|
||||
import org.antlr.v4.runtime.tree.RuleNode;
|
||||
|
@ -154,18 +153,18 @@ public class RuleContext implements RuleNode {
|
|||
public <T> T accept(ParseTreeVisitor<? extends T> visitor) { return visitor.visitChildren(this); }
|
||||
|
||||
/** Call this method to view a parse tree in a dialog box visually. */
|
||||
public Future<JDialog> inspect(@Nullable Parser parser) {
|
||||
public Future<JDialog> inspect(Parser parser) {
|
||||
List<String> ruleNames = parser != null ? Arrays.asList(parser.getRuleNames()) : null;
|
||||
return inspect(ruleNames);
|
||||
}
|
||||
|
||||
public Future<JDialog> inspect(@Nullable List<String> ruleNames) {
|
||||
public Future<JDialog> inspect(List<String> ruleNames) {
|
||||
TreeViewer viewer = new TreeViewer(ruleNames, this);
|
||||
return viewer.open();
|
||||
}
|
||||
|
||||
/** Save this tree in a postscript file */
|
||||
public void save(@Nullable Parser parser, String fileName)
|
||||
public void save(Parser parser, String fileName)
|
||||
throws IOException, PrintException
|
||||
{
|
||||
List<String> ruleNames = parser != null ? Arrays.asList(parser.getRuleNames()) : null;
|
||||
|
@ -173,7 +172,7 @@ public class RuleContext implements RuleNode {
|
|||
}
|
||||
|
||||
/** Save this tree in a postscript file using a particular font name and size */
|
||||
public void save(@Nullable Parser parser, String fileName,
|
||||
public void save(Parser parser, String fileName,
|
||||
String fontName, int fontSize)
|
||||
throws IOException
|
||||
{
|
||||
|
@ -182,14 +181,14 @@ public class RuleContext implements RuleNode {
|
|||
}
|
||||
|
||||
/** Save this tree in a postscript file */
|
||||
public void save(@Nullable List<String> ruleNames, String fileName)
|
||||
public void save(List<String> ruleNames, String fileName)
|
||||
throws IOException, PrintException
|
||||
{
|
||||
Trees.writePS(this, ruleNames, fileName);
|
||||
}
|
||||
|
||||
/** Save this tree in a postscript file using a particular font name and size */
|
||||
public void save(@Nullable List<String> ruleNames, String fileName,
|
||||
public void save(List<String> ruleNames, String fileName,
|
||||
String fontName, int fontSize)
|
||||
throws IOException
|
||||
{
|
||||
|
@ -201,14 +200,14 @@ public class RuleContext implements RuleNode {
|
|||
* We have to know the recognizer so we can get rule names.
|
||||
*/
|
||||
@Override
|
||||
public String toStringTree(@Nullable Parser recog) {
|
||||
public String toStringTree(Parser recog) {
|
||||
return Trees.toStringTree(this, recog);
|
||||
}
|
||||
|
||||
/** Print out a whole tree, not just a node, in LISP format
|
||||
* (root child1 .. childN). Print just a node if this is a leaf.
|
||||
*/
|
||||
public String toStringTree(@Nullable List<String> ruleNames) {
|
||||
public String toStringTree(List<String> ruleNames) {
|
||||
return Trees.toStringTree(this, ruleNames);
|
||||
}
|
||||
|
||||
|
@ -222,22 +221,22 @@ public class RuleContext implements RuleNode {
|
|||
return toString((List<String>)null, (RuleContext)null);
|
||||
}
|
||||
|
||||
public final String toString(@Nullable Recognizer<?,?> recog) {
|
||||
public final String toString(Recognizer<?,?> recog) {
|
||||
return toString(recog, ParserRuleContext.EMPTY);
|
||||
}
|
||||
|
||||
public final String toString(@Nullable List<String> ruleNames) {
|
||||
public final String toString(List<String> ruleNames) {
|
||||
return toString(ruleNames, null);
|
||||
}
|
||||
|
||||
// recog null unless ParserRuleContext, in which case we use subclass toString(...)
|
||||
public String toString(@Nullable Recognizer<?,?> recog, @Nullable RuleContext stop) {
|
||||
public String toString(Recognizer<?,?> recog, RuleContext stop) {
|
||||
String[] ruleNames = recog != null ? recog.getRuleNames() : null;
|
||||
List<String> ruleNamesList = ruleNames != null ? Arrays.asList(ruleNames) : null;
|
||||
return toString(ruleNamesList, stop);
|
||||
}
|
||||
|
||||
public String toString(@Nullable List<String> ruleNames, @Nullable RuleContext stop) {
|
||||
public String toString(List<String> ruleNames, RuleContext stop) {
|
||||
StringBuilder buf = new StringBuilder();
|
||||
RuleContext p = this;
|
||||
buf.append("[");
|
||||
|
|
|
@ -31,7 +31,6 @@
|
|||
package org.antlr.v4.runtime;
|
||||
|
||||
import org.antlr.v4.runtime.misc.NotNull;
|
||||
import org.antlr.v4.runtime.misc.Nullable;
|
||||
|
||||
/**
|
||||
* This class provides access to the current version of the ANTLR 4 runtime
|
||||
|
@ -105,7 +104,7 @@ public class RuntimeMetaData {
|
|||
*
|
||||
* @return The currently executing version of the ANTLR 4 library
|
||||
*/
|
||||
@NotNull
|
||||
|
||||
public static String getRuntimeVersion() {
|
||||
return VERSION;
|
||||
}
|
||||
|
@ -168,7 +167,7 @@ public class RuntimeMetaData {
|
|||
* compiled against. This should always be passed using a direct reference
|
||||
* to {@link #VERSION}.
|
||||
*/
|
||||
public static void checkVersion(@Nullable String generatingToolVersion, @NotNull String compileTimeVersion) {
|
||||
public static void checkVersion(String generatingToolVersion, String compileTimeVersion) {
|
||||
String runtimeVersion = VERSION;
|
||||
boolean runtimeConflictsWithGeneratingTool = false;
|
||||
boolean runtimeConflictsWithCompileTimeTool = false;
|
||||
|
@ -202,8 +201,7 @@ public class RuntimeMetaData {
|
|||
* @return A string of the form <em>major</em>.<em>minor</em> containing
|
||||
* only the major and minor components of the version string.
|
||||
*/
|
||||
@NotNull
|
||||
public static String getMajorMinorVersion(@NotNull String version) {
|
||||
public static String getMajorMinorVersion(String version) {
|
||||
int firstDot = version.indexOf('.');
|
||||
int secondDot = firstDot >= 0 ? version.indexOf('.', firstDot + 1) : -1;
|
||||
int firstDash = version.indexOf('-');
|
||||
|
|
|
@ -42,12 +42,10 @@ public interface TokenFactory<Symbol extends Token> {
|
|||
* error handling strategy. If text!=null, than the start and stop positions
|
||||
* are wiped to -1 in the text override is set in the CommonToken.
|
||||
*/
|
||||
@NotNull
|
||||
Symbol create(@NotNull Pair<TokenSource, CharStream> source, int type, String text,
|
||||
Symbol create(Pair<TokenSource, CharStream> source, int type, String text,
|
||||
int channel, int start, int stop,
|
||||
int line, int charPositionInLine);
|
||||
|
||||
/** Generically useful */
|
||||
@NotNull
|
||||
Symbol create(int type, String text);
|
||||
}
|
||||
|
|
|
@ -54,7 +54,6 @@ public interface TokenSource {
|
|||
* on the characters until you get a good one; errors are not passed through
|
||||
* to the parser.
|
||||
*/
|
||||
@NotNull
|
||||
public Token nextToken();
|
||||
|
||||
/**
|
||||
|
@ -83,7 +82,6 @@ public interface TokenSource {
|
|||
* the input, or {@code null} if no input stream is available for the token
|
||||
* source.
|
||||
*/
|
||||
@Nullable
|
||||
public CharStream getInputStream();
|
||||
|
||||
/**
|
||||
|
@ -91,7 +89,6 @@ public interface TokenSource {
|
|||
* non-null, non-empty string. If such a name is not known, this method
|
||||
* returns {@link IntStream#UNKNOWN_SOURCE_NAME}.
|
||||
*/
|
||||
@NotNull
|
||||
public String getSourceName();
|
||||
|
||||
/**
|
||||
|
@ -100,7 +97,7 @@ public interface TokenSource {
|
|||
*
|
||||
* @param factory The {@link TokenFactory} to use for creating tokens.
|
||||
*/
|
||||
public void setTokenFactory(@NotNull TokenFactory<?> factory);
|
||||
public void setTokenFactory(TokenFactory<?> factory);
|
||||
|
||||
/**
|
||||
* Gets the {@link TokenFactory} this token source is currently using for
|
||||
|
@ -108,6 +105,5 @@ public interface TokenSource {
|
|||
*
|
||||
* @return The {@link TokenFactory} currently used by this token source.
|
||||
*/
|
||||
@NotNull
|
||||
public TokenFactory<?> getTokenFactory();
|
||||
}
|
||||
|
|
|
@ -46,7 +46,6 @@ public interface TokenStream extends IntStream {
|
|||
*
|
||||
* @see IntStream#LA
|
||||
*/
|
||||
@NotNull
|
||||
public Token LT(int k);
|
||||
|
||||
/**
|
||||
|
@ -67,14 +66,12 @@ public interface TokenStream extends IntStream {
|
|||
* @throws UnsupportedOperationException if the stream does not support
|
||||
* retrieving the token at the specified index
|
||||
*/
|
||||
@NotNull
|
||||
public Token get(int index);
|
||||
|
||||
/**
|
||||
* Gets the underlying {@link TokenSource} which provides tokens for this
|
||||
* stream.
|
||||
*/
|
||||
@NotNull
|
||||
public TokenSource getTokenSource();
|
||||
|
||||
/**
|
||||
|
@ -98,8 +95,7 @@ public interface TokenStream extends IntStream {
|
|||
*
|
||||
* @throws NullPointerException if {@code interval} is {@code null}
|
||||
*/
|
||||
@NotNull
|
||||
public String getText(@NotNull Interval interval);
|
||||
public String getText(Interval interval);
|
||||
|
||||
/**
|
||||
* Return the text of all tokens in the stream. This method behaves like the
|
||||
|
@ -114,7 +110,6 @@ public interface TokenStream extends IntStream {
|
|||
*
|
||||
* @return The text of all tokens in the stream.
|
||||
*/
|
||||
@NotNull
|
||||
public String getText();
|
||||
|
||||
/**
|
||||
|
@ -135,8 +130,7 @@ public interface TokenStream extends IntStream {
|
|||
* text for.
|
||||
* @return The text of all tokens within the source interval of {@code ctx}.
|
||||
*/
|
||||
@NotNull
|
||||
public String getText(@NotNull RuleContext ctx);
|
||||
public String getText(RuleContext ctx);
|
||||
|
||||
/**
|
||||
* Return the text of all tokens in this stream between {@code start} and
|
||||
|
@ -167,6 +161,5 @@ public interface TokenStream extends IntStream {
|
|||
* @throws UnsupportedOperationException if this stream does not support
|
||||
* this method for the specified tokens
|
||||
*/
|
||||
@NotNull
|
||||
public String getText(@NotNull Token start, @NotNull Token stop);
|
||||
public String getText(Token start, Token stop);
|
||||
}
|
||||
|
|
|
@ -30,7 +30,6 @@
|
|||
package org.antlr.v4.runtime;
|
||||
|
||||
import org.antlr.v4.runtime.misc.Interval;
|
||||
import org.antlr.v4.runtime.misc.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
@ -294,7 +293,7 @@ public class TokenStreamRewriter {
|
|||
replace(DEFAULT_PROGRAM_NAME, from, to, text);
|
||||
}
|
||||
|
||||
public void replace(String programName, int from, int to, @Nullable Object text) {
|
||||
public void replace(String programName, int from, int to, Object text) {
|
||||
if ( from > to || from<0 || to<0 || to >= tokens.size() ) {
|
||||
throw new IllegalArgumentException("replace: range invalid: "+from+".."+to+"(size="+tokens.size()+")");
|
||||
}
|
||||
|
@ -304,7 +303,7 @@ public class TokenStreamRewriter {
|
|||
rewrites.add(op);
|
||||
}
|
||||
|
||||
public void replace(String programName, Token from, Token to, @Nullable Object text) {
|
||||
public void replace(String programName, Token from, Token to, Object text) {
|
||||
replace(programName,
|
||||
from.getTokenIndex(),
|
||||
to.getTokenIndex(),
|
||||
|
|
|
@ -140,19 +140,19 @@ public class UnbufferedTokenStream<T extends Token> implements TokenStream {
|
|||
return tokenSource;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@Override
|
||||
public String getText() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@Override
|
||||
public String getText(RuleContext ctx) {
|
||||
return getText(ctx.getSourceInterval());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@Override
|
||||
public String getText(Token start, Token stop) {
|
||||
return getText(Interval.of(start.getTokenIndex(), stop.getTokenIndex()));
|
||||
|
@ -208,7 +208,7 @@ public class UnbufferedTokenStream<T extends Token> implements TokenStream {
|
|||
return n;
|
||||
}
|
||||
|
||||
protected void add(@NotNull Token t) {
|
||||
protected void add(Token t) {
|
||||
if ( n>=tokens.length ) {
|
||||
tokens = Arrays.copyOf(tokens, tokens.length * 2);
|
||||
}
|
||||
|
@ -305,7 +305,7 @@ public class UnbufferedTokenStream<T extends Token> implements TokenStream {
|
|||
return tokenSource.getSourceName();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@Override
|
||||
public String getText(Interval interval) {
|
||||
int bufferStartIndex = getBufferStartIndex();
|
||||
|
|
|
@ -40,7 +40,6 @@ import org.antlr.v4.runtime.misc.Nullable;
|
|||
* @author Sam Harwell
|
||||
*/
|
||||
public interface Vocabulary {
|
||||
|
||||
/**
|
||||
* Gets the string literal associated with a token type. The string returned
|
||||
* by this method, when not {@code null}, can be used unaltered in a parser
|
||||
|
@ -77,7 +76,6 @@ public interface Vocabulary {
|
|||
* @return The string literal associated with the specified token type, or
|
||||
* {@code null} if no string literal is associated with the type.
|
||||
*/
|
||||
@Nullable
|
||||
String getLiteralName(int tokenType);
|
||||
|
||||
/**
|
||||
|
@ -123,7 +121,6 @@ public interface Vocabulary {
|
|||
* @return The symbolic name associated with the specified token type, or
|
||||
* {@code null} if no symbolic name is associated with the type.
|
||||
*/
|
||||
@Nullable
|
||||
String getSymbolicName(int tokenType);
|
||||
|
||||
/**
|
||||
|
@ -146,7 +143,5 @@ public interface Vocabulary {
|
|||
* @return The display name of the token type, for use in error reporting or
|
||||
* other user-visible messages which reference specific token types.
|
||||
*/
|
||||
@NotNull
|
||||
String getDisplayName(int tokenType);
|
||||
|
||||
}
|
||||
|
|
|
@ -51,14 +51,13 @@ public class VocabularyImpl implements Vocabulary {
|
|||
* {@link #getDisplayName(int)} returns the numeric value for all tokens
|
||||
* except {@link Token#EOF}.</p>
|
||||
*/
|
||||
@NotNull
|
||||
public static final VocabularyImpl EMPTY_VOCABULARY = new VocabularyImpl(EMPTY_NAMES, EMPTY_NAMES, EMPTY_NAMES);
|
||||
|
||||
@NotNull
|
||||
|
||||
private final String[] literalNames;
|
||||
@NotNull
|
||||
|
||||
private final String[] symbolicNames;
|
||||
@NotNull
|
||||
|
||||
private final String[] displayNames;
|
||||
|
||||
/**
|
||||
|
@ -73,7 +72,7 @@ public class VocabularyImpl implements Vocabulary {
|
|||
* @see #getLiteralName(int)
|
||||
* @see #getSymbolicName(int)
|
||||
*/
|
||||
public VocabularyImpl(@Nullable String[] literalNames, @Nullable String[] symbolicNames) {
|
||||
public VocabularyImpl(String[] literalNames, String[] symbolicNames) {
|
||||
this(literalNames, symbolicNames, null);
|
||||
}
|
||||
|
||||
|
@ -94,7 +93,7 @@ public class VocabularyImpl implements Vocabulary {
|
|||
* @see #getSymbolicName(int)
|
||||
* @see #getDisplayName(int)
|
||||
*/
|
||||
public VocabularyImpl(@Nullable String[] literalNames, @Nullable String[] symbolicNames, @Nullable String[] displayNames) {
|
||||
public VocabularyImpl(String[] literalNames, String[] symbolicNames, String[] displayNames) {
|
||||
this.literalNames = literalNames != null ? literalNames : EMPTY_NAMES;
|
||||
this.symbolicNames = symbolicNames != null ? symbolicNames : EMPTY_NAMES;
|
||||
this.displayNames = displayNames != null ? displayNames : EMPTY_NAMES;
|
||||
|
@ -114,7 +113,7 @@ public class VocabularyImpl implements Vocabulary {
|
|||
* @return A {@link Vocabulary} instance which uses {@code tokenNames} for
|
||||
* the display names of tokens.
|
||||
*/
|
||||
public static Vocabulary fromTokenNames(@Nullable String[] tokenNames) {
|
||||
public static Vocabulary fromTokenNames(String[] tokenNames) {
|
||||
if (tokenNames == null || tokenNames.length == 0) {
|
||||
return EMPTY_VOCABULARY;
|
||||
}
|
||||
|
@ -148,7 +147,6 @@ public class VocabularyImpl implements Vocabulary {
|
|||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public String getLiteralName(int tokenType) {
|
||||
if (tokenType >= 0 && tokenType < literalNames.length) {
|
||||
return literalNames[tokenType];
|
||||
|
@ -158,7 +156,6 @@ public class VocabularyImpl implements Vocabulary {
|
|||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public String getSymbolicName(int tokenType) {
|
||||
if (tokenType >= 0 && tokenType < symbolicNames.length) {
|
||||
return symbolicNames[tokenType];
|
||||
|
@ -172,7 +169,6 @@ public class VocabularyImpl implements Vocabulary {
|
|||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getDisplayName(int tokenType) {
|
||||
if (tokenType >= 0 && tokenType < displayNames.length) {
|
||||
String displayName = displayNames[tokenType];
|
||||
|
|
|
@ -35,7 +35,6 @@ import org.antlr.v4.runtime.RuleContext;
|
|||
import org.antlr.v4.runtime.Token;
|
||||
import org.antlr.v4.runtime.misc.IntervalSet;
|
||||
import org.antlr.v4.runtime.misc.NotNull;
|
||||
import org.antlr.v4.runtime.misc.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
|
@ -46,14 +45,13 @@ import java.util.Map;
|
|||
public class ATN {
|
||||
public static final int INVALID_ALT_NUMBER = 0;
|
||||
|
||||
@NotNull
|
||||
|
||||
public final List<ATNState> states = new ArrayList<ATNState>();
|
||||
|
||||
/** Each subrule/rule is a decision point and we must track them so we
|
||||
* can go back later and build DFA predictors for them. This includes
|
||||
* all the rules, subrules, optional blocks, ()+, ()* etc...
|
||||
*/
|
||||
@NotNull
|
||||
public final List<DecisionState> decisionToState = new ArrayList<DecisionState>();
|
||||
|
||||
/**
|
||||
|
@ -66,7 +64,7 @@ public class ATN {
|
|||
*/
|
||||
public RuleStopState[] ruleToStopState;
|
||||
|
||||
@NotNull
|
||||
|
||||
public final Map<String, TokensStartState> modeNameToStartState =
|
||||
new LinkedHashMap<String, TokensStartState>();
|
||||
|
||||
|
@ -95,11 +93,10 @@ public class ATN {
|
|||
*/
|
||||
public LexerAction[] lexerActions;
|
||||
|
||||
@NotNull
|
||||
public final List<TokensStartState> modeToStartState = new ArrayList<TokensStartState>();
|
||||
|
||||
/** Used for runtime deserialization of ATNs from strings */
|
||||
public ATN(@NotNull ATNType grammarType, int maxTokenType) {
|
||||
public ATN(ATNType grammarType, int maxTokenType) {
|
||||
this.grammarType = grammarType;
|
||||
this.maxTokenType = maxTokenType;
|
||||
}
|
||||
|
@ -109,7 +106,6 @@ public class ATN {
|
|||
* the rule surrounding {@code s}. In other words, the set will be
|
||||
* restricted to tokens reachable staying within {@code s}'s rule.
|
||||
*/
|
||||
@NotNull
|
||||
public IntervalSet nextTokens(ATNState s, RuleContext ctx) {
|
||||
LL1Analyzer anal = new LL1Analyzer(this);
|
||||
IntervalSet next = anal.LOOK(s, ctx);
|
||||
|
@ -121,15 +117,14 @@ public class ATN {
|
|||
* staying in same rule. {@link Token#EPSILON} is in set if we reach end of
|
||||
* rule.
|
||||
*/
|
||||
@NotNull
|
||||
public IntervalSet nextTokens(@NotNull ATNState s) {
|
||||
public IntervalSet nextTokens(ATNState s) {
|
||||
if ( s.nextTokenWithinRule != null ) return s.nextTokenWithinRule;
|
||||
s.nextTokenWithinRule = nextTokens(s, null);
|
||||
s.nextTokenWithinRule.setReadonly(true);
|
||||
return s.nextTokenWithinRule;
|
||||
}
|
||||
|
||||
public void addState(@Nullable ATNState state) {
|
||||
public void addState(ATNState state) {
|
||||
if (state != null) {
|
||||
state.atn = this;
|
||||
state.stateNumber = states.size();
|
||||
|
@ -138,11 +133,11 @@ public class ATN {
|
|||
states.add(state);
|
||||
}
|
||||
|
||||
public void removeState(@NotNull ATNState state) {
|
||||
public void removeState(ATNState state) {
|
||||
states.set(state.stateNumber, null); // just free mem, don't shift states in list
|
||||
}
|
||||
|
||||
public int defineDecisionState(@NotNull DecisionState s) {
|
||||
public int defineDecisionState(DecisionState s) {
|
||||
decisionToState.add(s);
|
||||
s.decision = decisionToState.size()-1;
|
||||
return s.decision;
|
||||
|
@ -178,8 +173,7 @@ public class ATN {
|
|||
* @throws IllegalArgumentException if the ATN does not contain a state with
|
||||
* number {@code stateNumber}
|
||||
*/
|
||||
@NotNull
|
||||
public IntervalSet getExpectedTokens(int stateNumber, @Nullable RuleContext context) {
|
||||
public IntervalSet getExpectedTokens(int stateNumber, RuleContext context) {
|
||||
if (stateNumber < 0 || stateNumber >= states.size()) {
|
||||
throw new IllegalArgumentException("Invalid state number.");
|
||||
}
|
||||
|
|
|
@ -51,7 +51,6 @@ public class ATNConfig {
|
|||
private static final int SUPPRESS_PRECEDENCE_FILTER = 0x40000000;
|
||||
|
||||
/** The ATN state associated with this configuration */
|
||||
@NotNull
|
||||
public final ATNState state;
|
||||
|
||||
/** What alt (or lexer rule) is predicted by this configuration */
|
||||
|
@ -61,7 +60,6 @@ public class ATNConfig {
|
|||
* with this config. We track only those contexts pushed during
|
||||
* execution of the ATN simulator.
|
||||
*/
|
||||
@Nullable
|
||||
public PredictionContext context;
|
||||
|
||||
/**
|
||||
|
@ -89,7 +87,7 @@ public class ATNConfig {
|
|||
*/
|
||||
public int reachesIntoOuterContext;
|
||||
|
||||
@NotNull
|
||||
|
||||
public final SemanticContext semanticContext;
|
||||
|
||||
public ATNConfig(ATNConfig old) { // dup
|
||||
|
@ -100,17 +98,17 @@ public class ATNConfig {
|
|||
this.reachesIntoOuterContext = old.reachesIntoOuterContext;
|
||||
}
|
||||
|
||||
public ATNConfig(@NotNull ATNState state,
|
||||
public ATNConfig(ATNState state,
|
||||
int alt,
|
||||
@Nullable PredictionContext context)
|
||||
PredictionContext context)
|
||||
{
|
||||
this(state, alt, context, SemanticContext.NONE);
|
||||
}
|
||||
|
||||
public ATNConfig(@NotNull ATNState state,
|
||||
public ATNConfig(ATNState state,
|
||||
int alt,
|
||||
@Nullable PredictionContext context,
|
||||
@NotNull SemanticContext semanticContext)
|
||||
PredictionContext context,
|
||||
SemanticContext semanticContext)
|
||||
{
|
||||
this.state = state;
|
||||
this.alt = alt;
|
||||
|
@ -118,31 +116,31 @@ public class ATNConfig {
|
|||
this.semanticContext = semanticContext;
|
||||
}
|
||||
|
||||
public ATNConfig(@NotNull ATNConfig c, @NotNull ATNState state) {
|
||||
public ATNConfig(ATNConfig c, ATNState state) {
|
||||
this(c, state, c.context, c.semanticContext);
|
||||
}
|
||||
|
||||
public ATNConfig(@NotNull ATNConfig c, @NotNull ATNState state,
|
||||
@NotNull SemanticContext semanticContext)
|
||||
public ATNConfig(ATNConfig c, ATNState state,
|
||||
SemanticContext semanticContext)
|
||||
{
|
||||
this(c, state, c.context, semanticContext);
|
||||
}
|
||||
|
||||
public ATNConfig(@NotNull ATNConfig c,
|
||||
@NotNull SemanticContext semanticContext)
|
||||
public ATNConfig(ATNConfig c,
|
||||
SemanticContext semanticContext)
|
||||
{
|
||||
this(c, c.state, c.context, semanticContext);
|
||||
}
|
||||
|
||||
public ATNConfig(@NotNull ATNConfig c, @NotNull ATNState state,
|
||||
@Nullable PredictionContext context)
|
||||
public ATNConfig(ATNConfig c, ATNState state,
|
||||
PredictionContext context)
|
||||
{
|
||||
this(c, state, context, c.semanticContext);
|
||||
}
|
||||
|
||||
public ATNConfig(@NotNull ATNConfig c, @NotNull ATNState state,
|
||||
@Nullable PredictionContext context,
|
||||
@NotNull SemanticContext semanticContext)
|
||||
public ATNConfig(ATNConfig c, ATNState state,
|
||||
PredictionContext context,
|
||||
SemanticContext semanticContext)
|
||||
{
|
||||
this.state = state;
|
||||
this.alt = c.alt;
|
||||
|
@ -216,7 +214,7 @@ public class ATNConfig {
|
|||
return toString(null, true);
|
||||
}
|
||||
|
||||
public String toString(@Nullable Recognizer<?, ?> recog, boolean showAlt) {
|
||||
public String toString(Recognizer<?, ?> recog, boolean showAlt) {
|
||||
StringBuilder buf = new StringBuilder();
|
||||
// if ( state.ruleIndex>=0 ) {
|
||||
// if ( recog!=null ) buf.append(recog.getRuleNames()[state.ruleIndex]+":");
|
||||
|
|
|
@ -34,7 +34,6 @@ import org.antlr.v4.runtime.misc.AbstractEqualityComparator;
|
|||
import org.antlr.v4.runtime.misc.Array2DHashSet;
|
||||
import org.antlr.v4.runtime.misc.DoubleKeyMap;
|
||||
import org.antlr.v4.runtime.misc.NotNull;
|
||||
import org.antlr.v4.runtime.misc.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.BitSet;
|
||||
|
@ -154,8 +153,8 @@ public class ATNConfigSet implements Set<ATNConfig> {
|
|||
* {@link #hasSemanticContext} when necessary.</p>
|
||||
*/
|
||||
public boolean add(
|
||||
@NotNull ATNConfig config,
|
||||
@Nullable DoubleKeyMap<PredictionContext,PredictionContext,PredictionContext> mergeCache)
|
||||
ATNConfig config,
|
||||
DoubleKeyMap<PredictionContext,PredictionContext,PredictionContext> mergeCache)
|
||||
{
|
||||
if ( readonly ) throw new IllegalStateException("This set is readonly");
|
||||
if ( config.semanticContext!=SemanticContext.NONE ) {
|
||||
|
@ -208,7 +207,7 @@ public class ATNConfigSet implements Set<ATNConfig> {
|
|||
*
|
||||
* @since 4.3
|
||||
*/
|
||||
@NotNull
|
||||
|
||||
public BitSet getAlts() {
|
||||
BitSet alts = new BitSet();
|
||||
for (ATNConfig config : configs) {
|
||||
|
|
|
@ -57,7 +57,7 @@ public class ATNDeserializationOptions {
|
|||
this.generateRuleBypassTransitions = options.generateRuleBypassTransitions;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
public static ATNDeserializationOptions getDefaultOptions() {
|
||||
return defaultOptions;
|
||||
}
|
||||
|
|
|
@ -33,7 +33,6 @@ package org.antlr.v4.runtime.atn;
|
|||
import org.antlr.v4.runtime.Token;
|
||||
import org.antlr.v4.runtime.misc.IntervalSet;
|
||||
import org.antlr.v4.runtime.misc.NotNull;
|
||||
import org.antlr.v4.runtime.misc.Nullable;
|
||||
import org.antlr.v4.runtime.misc.Pair;
|
||||
|
||||
import java.io.InvalidClassException;
|
||||
|
@ -96,14 +95,14 @@ public class ATNDeserializer {
|
|||
SERIALIZED_UUID = ADDED_LEXER_ACTIONS;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
private final ATNDeserializationOptions deserializationOptions;
|
||||
|
||||
public ATNDeserializer() {
|
||||
this(ATNDeserializationOptions.getDefaultOptions());
|
||||
}
|
||||
|
||||
public ATNDeserializer(@Nullable ATNDeserializationOptions deserializationOptions) {
|
||||
public ATNDeserializer(ATNDeserializationOptions deserializationOptions) {
|
||||
if (deserializationOptions == null) {
|
||||
deserializationOptions = ATNDeserializationOptions.getDefaultOptions();
|
||||
}
|
||||
|
@ -134,7 +133,7 @@ public class ATNDeserializer {
|
|||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public ATN deserialize(@NotNull char[] data) {
|
||||
public ATN deserialize(char[] data) {
|
||||
data = data.clone();
|
||||
// don't adjust the first value since that's the version number
|
||||
for (int i = 1; i < data.length; i++) {
|
||||
|
@ -531,7 +530,7 @@ public class ATNDeserializer {
|
|||
*
|
||||
* @param atn The ATN.
|
||||
*/
|
||||
protected void markPrecedenceDecisions(@NotNull ATN atn) {
|
||||
protected void markPrecedenceDecisions(ATN atn) {
|
||||
for (ATNState state : atn.states) {
|
||||
if (!(state instanceof StarLoopEntryState)) {
|
||||
continue;
|
||||
|
@ -643,8 +642,8 @@ public class ATNDeserializer {
|
|||
return new UUID(mostSigBits, leastSigBits);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
protected Transition edgeFactory(@NotNull ATN atn,
|
||||
|
||||
protected Transition edgeFactory(ATN atn,
|
||||
int type, int src, int trg,
|
||||
int arg1, int arg2, int arg3,
|
||||
List<IntervalSet> sets)
|
||||
|
|
|
@ -59,9 +59,9 @@ public abstract class ATNSimulator {
|
|||
}
|
||||
|
||||
/** Must distinguish between missing edge and edge we know leads nowhere */
|
||||
@NotNull
|
||||
|
||||
public static final DFAState ERROR;
|
||||
@NotNull
|
||||
|
||||
public final ATN atn;
|
||||
|
||||
/** The context cache maps all PredictionContext objects that are equals()
|
||||
|
@ -91,8 +91,8 @@ public abstract class ATNSimulator {
|
|||
ERROR.stateNumber = Integer.MAX_VALUE;
|
||||
}
|
||||
|
||||
public ATNSimulator(@NotNull ATN atn,
|
||||
@NotNull PredictionContextCache sharedContextCache)
|
||||
public ATNSimulator(ATN atn,
|
||||
PredictionContextCache sharedContextCache)
|
||||
{
|
||||
this.atn = atn;
|
||||
this.sharedContextCache = sharedContextCache;
|
||||
|
@ -135,7 +135,7 @@ public abstract class ATNSimulator {
|
|||
* @deprecated Use {@link ATNDeserializer#deserialize} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public static ATN deserialize(@NotNull char[] data) {
|
||||
public static ATN deserialize(char[] data) {
|
||||
return new ATNDeserializer().deserialize(data);
|
||||
}
|
||||
|
||||
|
@ -191,8 +191,8 @@ public abstract class ATNSimulator {
|
|||
* @deprecated Use {@link ATNDeserializer#edgeFactory} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
@NotNull
|
||||
public static Transition edgeFactory(@NotNull ATN atn,
|
||||
|
||||
public static Transition edgeFactory(ATN atn,
|
||||
int type, int src, int trg,
|
||||
int arg1, int arg2, int arg3,
|
||||
List<IntervalSet> sets)
|
||||
|
@ -208,15 +208,4 @@ public abstract class ATNSimulator {
|
|||
return new ATNDeserializer().stateFactory(type, ruleIndex);
|
||||
}
|
||||
|
||||
/*
|
||||
public static void dump(DFA dfa, Grammar g) {
|
||||
DOTGenerator dot = new DOTGenerator(g);
|
||||
String output = dot.getDOT(dfa, false);
|
||||
System.out.println(output);
|
||||
}
|
||||
|
||||
public static void dump(DFA dfa) {
|
||||
dump(dfa, null);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
|
|
@ -30,18 +30,16 @@
|
|||
|
||||
package org.antlr.v4.runtime.atn;
|
||||
|
||||
import org.antlr.v4.runtime.misc.NotNull;
|
||||
|
||||
public final class ActionTransition extends Transition {
|
||||
public final int ruleIndex;
|
||||
public final int actionIndex;
|
||||
public final boolean isCtxDependent; // e.g., $i ref in action
|
||||
|
||||
public ActionTransition(@NotNull ATNState target, int ruleIndex) {
|
||||
public ActionTransition(ATNState target, int ruleIndex) {
|
||||
this(target, ruleIndex, -1, false);
|
||||
}
|
||||
|
||||
public ActionTransition(@NotNull ATNState target, int ruleIndex, int actionIndex, boolean isCtxDependent) {
|
||||
public ActionTransition(ATNState target, int ruleIndex, int actionIndex, boolean isCtxDependent) {
|
||||
super(target);
|
||||
this.ruleIndex = ruleIndex;
|
||||
this.actionIndex = actionIndex;
|
||||
|
|
|
@ -32,7 +32,6 @@ package org.antlr.v4.runtime.atn;
|
|||
|
||||
import org.antlr.v4.runtime.ANTLRErrorListener;
|
||||
import org.antlr.v4.runtime.TokenStream;
|
||||
import org.antlr.v4.runtime.misc.NotNull;
|
||||
|
||||
/**
|
||||
* This class represents profiling event information for an ambiguity.
|
||||
|
@ -79,7 +78,7 @@ public class AmbiguityInfo extends DecisionEventInfo {
|
|||
* prediction; otherwise, {@code false} if the ambiguity was identified
|
||||
* during SLL prediction
|
||||
*/
|
||||
public AmbiguityInfo(int decision, @NotNull ATNConfigSet configs, @NotNull TokenStream input,
|
||||
public AmbiguityInfo(int decision, ATNConfigSet configs, TokenStream input,
|
||||
int startIndex, int stopIndex, boolean fullCtx)
|
||||
{
|
||||
super(decision, configs, input, startIndex, stopIndex, fullCtx);
|
||||
|
|
|
@ -38,7 +38,7 @@ public final class AtomTransition extends Transition {
|
|||
/** The token type or character value; or, signifies special label. */
|
||||
public final int label;
|
||||
|
||||
public AtomTransition(@NotNull ATNState target, int label) {
|
||||
public AtomTransition(ATNState target, int label) {
|
||||
super(target);
|
||||
this.label = label;
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ public final class AtomTransition extends Transition {
|
|||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
|
||||
public IntervalSet label() { return IntervalSet.of(label); }
|
||||
|
||||
@Override
|
||||
|
@ -58,7 +58,6 @@ public final class AtomTransition extends Transition {
|
|||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String toString() {
|
||||
return String.valueOf(label);
|
||||
}
|
||||
|
|
|
@ -32,7 +32,6 @@ package org.antlr.v4.runtime.atn;
|
|||
|
||||
import org.antlr.v4.runtime.ANTLRErrorListener;
|
||||
import org.antlr.v4.runtime.TokenStream;
|
||||
import org.antlr.v4.runtime.misc.NotNull;
|
||||
|
||||
/**
|
||||
* This class represents profiling event information for a context sensitivity.
|
||||
|
@ -65,8 +64,8 @@ public class ContextSensitivityInfo extends DecisionEventInfo {
|
|||
* @param stopIndex The index at which the context sensitivity was
|
||||
* identified during full-context prediction
|
||||
*/
|
||||
public ContextSensitivityInfo(int decision, @NotNull ATNConfigSet configs,
|
||||
@NotNull TokenStream input, int startIndex, int stopIndex)
|
||||
public ContextSensitivityInfo(int decision, ATNConfigSet configs,
|
||||
TokenStream input, int startIndex, int stopIndex)
|
||||
{
|
||||
super(decision, configs, input, startIndex, stopIndex, true);
|
||||
}
|
||||
|
|
|
@ -47,35 +47,38 @@ public class DecisionEventInfo {
|
|||
* @see ATN#decisionToState
|
||||
*/
|
||||
public final int decision;
|
||||
|
||||
/**
|
||||
* The configuration set containing additional information relevant to the
|
||||
* prediction state when the current event occurred, or {@code null} if no
|
||||
* additional information is relevant or available.
|
||||
*/
|
||||
@Nullable
|
||||
public final ATNConfigSet configs;
|
||||
|
||||
/**
|
||||
* The input token stream which is being parsed.
|
||||
*/
|
||||
@NotNull
|
||||
public final TokenStream input;
|
||||
|
||||
/**
|
||||
* The token index in the input stream at which the current prediction was
|
||||
* originally invoked.
|
||||
*/
|
||||
public final int startIndex;
|
||||
|
||||
/**
|
||||
* The token index in the input stream at which the current event occurred.
|
||||
*/
|
||||
public final int stopIndex;
|
||||
|
||||
/**
|
||||
* {@code true} if the current event occurred during LL prediction;
|
||||
* otherwise, {@code false} if the input occurred during SLL prediction.
|
||||
*/
|
||||
public final boolean fullCtx;
|
||||
|
||||
public DecisionEventInfo(int decision, @Nullable ATNConfigSet configs,
|
||||
@NotNull TokenStream input, int startIndex,
|
||||
public DecisionEventInfo(int decision, ATNConfigSet configs,
|
||||
TokenStream input, int startIndex,
|
||||
int stopIndex, boolean fullCtx)
|
||||
{
|
||||
this.decision = decision;
|
||||
|
|
|
@ -51,11 +51,13 @@ public class DecisionInfo {
|
|||
* The decision number, which is an index into {@link ATN#decisionToState}.
|
||||
*/
|
||||
public final int decision;
|
||||
|
||||
/**
|
||||
* The total number of times {@link ParserATNSimulator#adaptivePredict} was
|
||||
* invoked for this decision.
|
||||
*/
|
||||
public long invocations;
|
||||
|
||||
/**
|
||||
* The total time spent in {@link ParserATNSimulator#adaptivePredict} for
|
||||
* this decision, in nanoseconds.
|
||||
|
@ -79,18 +81,21 @@ public class DecisionInfo {
|
|||
* {@link PredictionMode#LL_EXACT_AMBIG_DETECTION} is used.
|
||||
*/
|
||||
public long SLL_TotalLook;
|
||||
|
||||
/**
|
||||
* Gets the minimum lookahead required for any single SLL prediction to
|
||||
* complete for this decision, by reaching a unique prediction, reaching an
|
||||
* SLL conflict state, or encountering a syntax error.
|
||||
*/
|
||||
public long SLL_MinLook;
|
||||
|
||||
/**
|
||||
* Gets the maximum lookahead required for any single SLL prediction to
|
||||
* complete for this decision, by reaching a unique prediction, reaching an
|
||||
* SLL conflict state, or encountering a syntax error.
|
||||
*/
|
||||
public long SLL_MaxLook;
|
||||
|
||||
/**
|
||||
* Gets the {@link LookaheadEventInfo} associated with the event where the
|
||||
* {@link #SLL_MaxLook} value was set.
|
||||
|
@ -103,6 +108,7 @@ public class DecisionInfo {
|
|||
* conflict state.
|
||||
*/
|
||||
public long LL_TotalLook;
|
||||
|
||||
/**
|
||||
* Gets the minimum lookahead required for any single LL prediction to
|
||||
* complete for this decision. An LL prediction completes when the algorithm
|
||||
|
@ -111,6 +117,7 @@ public class DecisionInfo {
|
|||
* {@link PredictionMode#LL_EXACT_AMBIG_DETECTION}, or a syntax error.
|
||||
*/
|
||||
public long LL_MinLook;
|
||||
|
||||
/**
|
||||
* Gets the maximum lookahead required for any single LL prediction to
|
||||
* complete for this decision. An LL prediction completes when the algorithm
|
||||
|
@ -119,6 +126,7 @@ public class DecisionInfo {
|
|||
* {@link PredictionMode#LL_EXACT_AMBIG_DETECTION}, or a syntax error.
|
||||
*/
|
||||
public long LL_MaxLook;
|
||||
|
||||
/**
|
||||
* Gets the {@link LookaheadEventInfo} associated with the event where the
|
||||
* {@link #LL_MaxLook} value was set.
|
||||
|
@ -132,6 +140,7 @@ public class DecisionInfo {
|
|||
* @see ContextSensitivityInfo
|
||||
*/
|
||||
public final List<ContextSensitivityInfo> contextSensitivities = new ArrayList<ContextSensitivityInfo>();
|
||||
|
||||
/**
|
||||
* A collection of {@link ErrorInfo} instances describing the parse errors
|
||||
* identified during calls to {@link ParserATNSimulator#adaptivePredict} for
|
||||
|
@ -140,6 +149,7 @@ public class DecisionInfo {
|
|||
* @see ErrorInfo
|
||||
*/
|
||||
public final List<ErrorInfo> errors = new ArrayList<ErrorInfo>();
|
||||
|
||||
/**
|
||||
* A collection of {@link AmbiguityInfo} instances describing the
|
||||
* ambiguities encountered during LL prediction for this decision.
|
||||
|
@ -174,6 +184,7 @@ public class DecisionInfo {
|
|||
* @see LexerATNSimulator#computeTargetState
|
||||
*/
|
||||
public long SLL_ATNTransitions;
|
||||
|
||||
/**
|
||||
* The total number of DFA transitions required during SLL prediction for
|
||||
* this decision.
|
||||
|
@ -216,6 +227,7 @@ public class DecisionInfo {
|
|||
* @see LexerATNSimulator#computeTargetState
|
||||
*/
|
||||
public long LL_ATNTransitions;
|
||||
|
||||
/**
|
||||
* The total number of DFA transitions required during LL prediction for
|
||||
* this decision.
|
||||
|
|
|
@ -36,11 +36,11 @@ public final class EpsilonTransition extends Transition {
|
|||
|
||||
private final int outermostPrecedenceReturn;
|
||||
|
||||
public EpsilonTransition(@NotNull ATNState target) {
|
||||
public EpsilonTransition(ATNState target) {
|
||||
this(target, -1);
|
||||
}
|
||||
|
||||
public EpsilonTransition(@NotNull ATNState target, int outermostPrecedenceReturn) {
|
||||
public EpsilonTransition(ATNState target, int outermostPrecedenceReturn) {
|
||||
super(target);
|
||||
this.outermostPrecedenceReturn = outermostPrecedenceReturn;
|
||||
}
|
||||
|
@ -71,7 +71,7 @@ public final class EpsilonTransition extends Transition {
|
|||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
|
||||
public String toString() {
|
||||
return "epsilon";
|
||||
}
|
||||
|
|
|
@ -35,7 +35,6 @@ import org.antlr.v4.runtime.Parser;
|
|||
import org.antlr.v4.runtime.RecognitionException;
|
||||
import org.antlr.v4.runtime.Token;
|
||||
import org.antlr.v4.runtime.TokenStream;
|
||||
import org.antlr.v4.runtime.misc.NotNull;
|
||||
|
||||
/**
|
||||
* This class represents profiling event information for a syntax error
|
||||
|
@ -63,7 +62,7 @@ public class ErrorInfo extends DecisionEventInfo {
|
|||
* prediction; otherwise, {@code false} if the syntax error was identified
|
||||
* during SLL prediction
|
||||
*/
|
||||
public ErrorInfo(int decision, @NotNull ATNConfigSet configs, @NotNull TokenStream input,
|
||||
public ErrorInfo(int decision, ATNConfigSet configs, TokenStream input,
|
||||
int startIndex, int stopIndex, boolean fullCtx)
|
||||
{
|
||||
super(decision, configs, input, startIndex, stopIndex, fullCtx);
|
||||
|
|
|
@ -46,10 +46,9 @@ public class LL1Analyzer {
|
|||
*/
|
||||
public static final int HIT_PRED = Token.INVALID_TYPE;
|
||||
|
||||
@NotNull
|
||||
public final ATN atn;
|
||||
|
||||
public LL1Analyzer(@NotNull ATN atn) { this.atn = atn; }
|
||||
public LL1Analyzer(ATN atn) { this.atn = atn; }
|
||||
|
||||
/**
|
||||
* Calculates the SLL(1) expected lookahead set for each outgoing transition
|
||||
|
@ -61,8 +60,7 @@ public class LL1Analyzer {
|
|||
* @param s the ATN state
|
||||
* @return the expected symbols for each outgoing transition of {@code s}.
|
||||
*/
|
||||
@Nullable
|
||||
public IntervalSet[] getDecisionLookahead(@Nullable ATNState s) {
|
||||
public IntervalSet[] getDecisionLookahead(ATNState s) {
|
||||
// System.out.println("LOOK("+s.stateNumber+")");
|
||||
if ( s==null ) {
|
||||
return null;
|
||||
|
@ -100,8 +98,7 @@ public class LL1Analyzer {
|
|||
* @return The set of tokens that can follow {@code s} in the ATN in the
|
||||
* specified {@code ctx}.
|
||||
*/
|
||||
@NotNull
|
||||
public IntervalSet LOOK(@NotNull ATNState s, @Nullable RuleContext ctx) {
|
||||
public IntervalSet LOOK(ATNState s, RuleContext ctx) {
|
||||
return LOOK(s, null, ctx);
|
||||
}
|
||||
|
||||
|
@ -123,8 +120,8 @@ public class LL1Analyzer {
|
|||
* @return The set of tokens that can follow {@code s} in the ATN in the
|
||||
* specified {@code ctx}.
|
||||
*/
|
||||
@NotNull
|
||||
public IntervalSet LOOK(@NotNull ATNState s, @Nullable ATNState stopState, @Nullable RuleContext ctx) {
|
||||
|
||||
public IntervalSet LOOK(ATNState s, ATNState stopState, RuleContext ctx) {
|
||||
IntervalSet r = new IntervalSet();
|
||||
boolean seeThruPreds = true; // ignore preds; get all lookahead
|
||||
PredictionContext lookContext = ctx != null ? PredictionContext.fromRuleContext(s.atn, ctx) : null;
|
||||
|
@ -163,12 +160,12 @@ public class LL1Analyzer {
|
|||
* outermost context is reached. This parameter has no effect if {@code ctx}
|
||||
* is {@code null}.
|
||||
*/
|
||||
protected void _LOOK(@NotNull ATNState s,
|
||||
@Nullable ATNState stopState,
|
||||
@Nullable PredictionContext ctx,
|
||||
@NotNull IntervalSet look,
|
||||
@NotNull Set<ATNConfig> lookBusy,
|
||||
@NotNull BitSet calledRuleStack,
|
||||
protected void _LOOK(ATNState s,
|
||||
ATNState stopState,
|
||||
PredictionContext ctx,
|
||||
IntervalSet look,
|
||||
Set<ATNConfig> lookBusy,
|
||||
BitSet calledRuleStack,
|
||||
boolean seeThruPreds, boolean addEOF)
|
||||
{
|
||||
// System.out.println("_LOOK("+s.stateNumber+", ctx="+ctx);
|
||||
|
|
|
@ -31,7 +31,6 @@
|
|||
package org.antlr.v4.runtime.atn;
|
||||
|
||||
import org.antlr.v4.runtime.misc.MurmurHash;
|
||||
import org.antlr.v4.runtime.misc.NotNull;
|
||||
import org.antlr.v4.runtime.misc.Nullable;
|
||||
import org.antlr.v4.runtime.misc.ObjectEqualityComparator;
|
||||
|
||||
|
@ -39,46 +38,45 @@ public class LexerATNConfig extends ATNConfig {
|
|||
/**
|
||||
* This is the backing field for {@link #getLexerActionExecutor}.
|
||||
*/
|
||||
@Nullable
|
||||
private final LexerActionExecutor lexerActionExecutor;
|
||||
|
||||
private final boolean passedThroughNonGreedyDecision;
|
||||
|
||||
public LexerATNConfig(@NotNull ATNState state,
|
||||
public LexerATNConfig(ATNState state,
|
||||
int alt,
|
||||
@Nullable PredictionContext context)
|
||||
PredictionContext context)
|
||||
{
|
||||
super(state, alt, context, SemanticContext.NONE);
|
||||
this.passedThroughNonGreedyDecision = false;
|
||||
this.lexerActionExecutor = null;
|
||||
}
|
||||
|
||||
public LexerATNConfig(@NotNull ATNState state,
|
||||
public LexerATNConfig(ATNState state,
|
||||
int alt,
|
||||
@Nullable PredictionContext context,
|
||||
@Nullable LexerActionExecutor lexerActionExecutor)
|
||||
PredictionContext context,
|
||||
LexerActionExecutor lexerActionExecutor)
|
||||
{
|
||||
super(state, alt, context, SemanticContext.NONE);
|
||||
this.lexerActionExecutor = lexerActionExecutor;
|
||||
this.passedThroughNonGreedyDecision = false;
|
||||
}
|
||||
|
||||
public LexerATNConfig(@NotNull LexerATNConfig c, @NotNull ATNState state) {
|
||||
public LexerATNConfig(LexerATNConfig c, ATNState state) {
|
||||
super(c, state, c.context, c.semanticContext);
|
||||
this.lexerActionExecutor = c.lexerActionExecutor;
|
||||
this.passedThroughNonGreedyDecision = checkNonGreedyDecision(c, state);
|
||||
}
|
||||
|
||||
public LexerATNConfig(@NotNull LexerATNConfig c, @NotNull ATNState state,
|
||||
@Nullable LexerActionExecutor lexerActionExecutor)
|
||||
public LexerATNConfig(LexerATNConfig c, ATNState state,
|
||||
LexerActionExecutor lexerActionExecutor)
|
||||
{
|
||||
super(c, state, c.context, c.semanticContext);
|
||||
this.lexerActionExecutor = lexerActionExecutor;
|
||||
this.passedThroughNonGreedyDecision = checkNonGreedyDecision(c, state);
|
||||
}
|
||||
|
||||
public LexerATNConfig(@NotNull LexerATNConfig c, @NotNull ATNState state,
|
||||
@Nullable PredictionContext context) {
|
||||
public LexerATNConfig(LexerATNConfig c, ATNState state,
|
||||
PredictionContext context) {
|
||||
super(c, state, context, c.semanticContext);
|
||||
this.lexerActionExecutor = c.lexerActionExecutor;
|
||||
this.passedThroughNonGreedyDecision = checkNonGreedyDecision(c, state);
|
||||
|
@ -88,7 +86,6 @@ public class LexerATNConfig extends ATNConfig {
|
|||
* Gets the {@link LexerActionExecutor} capable of executing the embedded
|
||||
* action(s) for the current configuration.
|
||||
*/
|
||||
@Nullable
|
||||
public final LexerActionExecutor getLexerActionExecutor() {
|
||||
return lexerActionExecutor;
|
||||
}
|
||||
|
|
|
@ -80,7 +80,7 @@ public class LexerATNSimulator extends ATNSimulator {
|
|||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
protected final Lexer recog;
|
||||
|
||||
/** The current token's starting index into the character stream.
|
||||
|
@ -96,39 +96,39 @@ public class LexerATNSimulator extends ATNSimulator {
|
|||
/** The index of the character relative to the beginning of the line 0..n-1 */
|
||||
protected int charPositionInLine = 0;
|
||||
|
||||
@NotNull
|
||||
|
||||
public final DFA[] decisionToDFA;
|
||||
protected int mode = Lexer.DEFAULT_MODE;
|
||||
|
||||
/** Used during DFA/ATN exec to record the most recent accept configuration info */
|
||||
@NotNull
|
||||
|
||||
protected final SimState prevAccept = new SimState();
|
||||
|
||||
public static int match_calls = 0;
|
||||
|
||||
public LexerATNSimulator(@NotNull ATN atn, @NotNull DFA[] decisionToDFA,
|
||||
@NotNull PredictionContextCache sharedContextCache)
|
||||
public LexerATNSimulator(ATN atn, DFA[] decisionToDFA,
|
||||
PredictionContextCache sharedContextCache)
|
||||
{
|
||||
this(null, atn, decisionToDFA,sharedContextCache);
|
||||
}
|
||||
|
||||
public LexerATNSimulator(@Nullable Lexer recog, @NotNull ATN atn,
|
||||
@NotNull DFA[] decisionToDFA,
|
||||
@NotNull PredictionContextCache sharedContextCache)
|
||||
public LexerATNSimulator(Lexer recog, ATN atn,
|
||||
DFA[] decisionToDFA,
|
||||
PredictionContextCache sharedContextCache)
|
||||
{
|
||||
super(atn,sharedContextCache);
|
||||
this.decisionToDFA = decisionToDFA;
|
||||
this.recog = recog;
|
||||
}
|
||||
|
||||
public void copyState(@NotNull LexerATNSimulator simulator) {
|
||||
public void copyState(LexerATNSimulator simulator) {
|
||||
this.charPositionInLine = simulator.charPositionInLine;
|
||||
this.line = simulator.line;
|
||||
this.mode = simulator.mode;
|
||||
this.startIndex = simulator.startIndex;
|
||||
}
|
||||
|
||||
public int match(@NotNull CharStream input, int mode) {
|
||||
public int match(CharStream input, int mode) {
|
||||
match_calls++;
|
||||
this.mode = mode;
|
||||
int mark = input.mark();
|
||||
|
@ -164,7 +164,7 @@ public class LexerATNSimulator extends ATNSimulator {
|
|||
}
|
||||
}
|
||||
|
||||
protected int matchATN(@NotNull CharStream input) {
|
||||
protected int matchATN(CharStream input) {
|
||||
ATNState startState = atn.modeToStartState.get(mode);
|
||||
|
||||
if ( debug ) {
|
||||
|
@ -191,7 +191,7 @@ public class LexerATNSimulator extends ATNSimulator {
|
|||
return predict;
|
||||
}
|
||||
|
||||
protected int execATN(@NotNull CharStream input, @NotNull DFAState ds0) {
|
||||
protected int execATN(CharStream input, DFAState ds0) {
|
||||
//System.out.println("enter exec index "+input.index()+" from "+ds0.configs);
|
||||
if ( debug ) {
|
||||
System.out.format(Locale.getDefault(), "start state closure=%s\n", ds0.configs);
|
||||
|
@ -203,7 +203,7 @@ public class LexerATNSimulator extends ATNSimulator {
|
|||
}
|
||||
|
||||
int t = input.LA(1);
|
||||
@NotNull
|
||||
|
||||
DFAState s = ds0; // s is current/from DFA state
|
||||
|
||||
while ( true ) { // while more work
|
||||
|
@ -270,8 +270,8 @@ public class LexerATNSimulator extends ATNSimulator {
|
|||
* {@code t}, or {@code null} if the target state for this edge is not
|
||||
* already cached
|
||||
*/
|
||||
@Nullable
|
||||
protected DFAState getExistingTargetState(@NotNull DFAState s, int t) {
|
||||
|
||||
protected DFAState getExistingTargetState(DFAState s, int t) {
|
||||
if (s.edges == null || t < MIN_DFA_EDGE || t > MAX_DFA_EDGE) {
|
||||
return null;
|
||||
}
|
||||
|
@ -297,8 +297,8 @@ public class LexerATNSimulator extends ATNSimulator {
|
|||
* {@code t}. If {@code t} does not lead to a valid DFA state, this method
|
||||
* returns {@link #ERROR}.
|
||||
*/
|
||||
@NotNull
|
||||
protected DFAState computeTargetState(@NotNull CharStream input, @NotNull DFAState s, int t) {
|
||||
|
||||
protected DFAState computeTargetState(CharStream input, DFAState s, int t) {
|
||||
ATNConfigSet reach = new OrderedATNConfigSet();
|
||||
|
||||
// if we don't find an existing DFA state
|
||||
|
@ -343,7 +343,7 @@ public class LexerATNSimulator extends ATNSimulator {
|
|||
* we can reach upon input {@code t}. Parameter {@code reach} is a return
|
||||
* parameter.
|
||||
*/
|
||||
protected void getReachableConfigSet(@NotNull CharStream input, @NotNull ATNConfigSet closure, @NotNull ATNConfigSet reach, int t) {
|
||||
protected void getReachableConfigSet(CharStream input, ATNConfigSet closure, ATNConfigSet reach, int t) {
|
||||
// this is used to skip processing for configs which have a lower priority
|
||||
// than a config that already reached an accept state for the same rule
|
||||
int skipAlt = ATN.INVALID_ALT_NUMBER;
|
||||
|
@ -379,7 +379,7 @@ public class LexerATNSimulator extends ATNSimulator {
|
|||
}
|
||||
}
|
||||
|
||||
protected void accept(@NotNull CharStream input, LexerActionExecutor lexerActionExecutor,
|
||||
protected void accept(CharStream input, LexerActionExecutor lexerActionExecutor,
|
||||
int startIndex, int index, int line, int charPos)
|
||||
{
|
||||
if ( debug ) {
|
||||
|
@ -396,7 +396,7 @@ public class LexerATNSimulator extends ATNSimulator {
|
|||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
protected ATNState getReachableTarget(Transition trans, int t) {
|
||||
if (trans.matches(t, Character.MIN_VALUE, Character.MAX_VALUE)) {
|
||||
return trans.target;
|
||||
|
@ -405,9 +405,9 @@ public class LexerATNSimulator extends ATNSimulator {
|
|||
return null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
protected ATNConfigSet computeStartState(@NotNull CharStream input,
|
||||
@NotNull ATNState p)
|
||||
|
||||
protected ATNConfigSet computeStartState(CharStream input,
|
||||
ATNState p)
|
||||
{
|
||||
PredictionContext initialContext = PredictionContext.EMPTY;
|
||||
ATNConfigSet configs = new OrderedATNConfigSet();
|
||||
|
@ -429,7 +429,7 @@ public class LexerATNSimulator extends ATNSimulator {
|
|||
* @return {@code true} if an accept state is reached, otherwise
|
||||
* {@code false}.
|
||||
*/
|
||||
protected boolean closure(@NotNull CharStream input, @NotNull LexerATNConfig config, @NotNull ATNConfigSet configs, boolean currentAltReachedAcceptState, boolean speculative, boolean treatEofAsEpsilon) {
|
||||
protected boolean closure(CharStream input, LexerATNConfig config, ATNConfigSet configs, boolean currentAltReachedAcceptState, boolean speculative, boolean treatEofAsEpsilon) {
|
||||
if ( debug ) {
|
||||
System.out.println("closure("+config.toString(recog, true)+")");
|
||||
}
|
||||
|
@ -489,11 +489,11 @@ public class LexerATNSimulator extends ATNSimulator {
|
|||
}
|
||||
|
||||
// side-effect: can alter configs.hasSemanticContext
|
||||
@Nullable
|
||||
protected LexerATNConfig getEpsilonTarget(@NotNull CharStream input,
|
||||
@NotNull LexerATNConfig config,
|
||||
@NotNull Transition t,
|
||||
@NotNull ATNConfigSet configs,
|
||||
|
||||
protected LexerATNConfig getEpsilonTarget(CharStream input,
|
||||
LexerATNConfig config,
|
||||
Transition t,
|
||||
ATNConfigSet configs,
|
||||
boolean speculative,
|
||||
boolean treatEofAsEpsilon)
|
||||
{
|
||||
|
@ -603,7 +603,7 @@ public class LexerATNSimulator extends ATNSimulator {
|
|||
* @return {@code true} if the specified predicate evaluates to
|
||||
* {@code true}.
|
||||
*/
|
||||
protected boolean evaluatePredicate(@NotNull CharStream input, int ruleIndex, int predIndex, boolean speculative) {
|
||||
protected boolean evaluatePredicate(CharStream input, int ruleIndex, int predIndex, boolean speculative) {
|
||||
// assume true if no recognizer was provided
|
||||
if (recog == null) {
|
||||
return true;
|
||||
|
@ -629,9 +629,9 @@ public class LexerATNSimulator extends ATNSimulator {
|
|||
}
|
||||
}
|
||||
|
||||
protected void captureSimState(@NotNull SimState settings,
|
||||
@NotNull CharStream input,
|
||||
@NotNull DFAState dfaState)
|
||||
protected void captureSimState(SimState settings,
|
||||
CharStream input,
|
||||
DFAState dfaState)
|
||||
{
|
||||
settings.index = input.index();
|
||||
settings.line = line;
|
||||
|
@ -639,10 +639,10 @@ public class LexerATNSimulator extends ATNSimulator {
|
|||
settings.dfaState = dfaState;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
protected DFAState addDFAEdge(@NotNull DFAState from,
|
||||
|
||||
protected DFAState addDFAEdge(DFAState from,
|
||||
int t,
|
||||
@NotNull ATNConfigSet q)
|
||||
ATNConfigSet q)
|
||||
{
|
||||
/* leading to this call, ATNConfigSet.hasSemanticContext is used as a
|
||||
* marker indicating dynamic predicate evaluation makes this edge
|
||||
|
@ -658,7 +658,7 @@ public class LexerATNSimulator extends ATNSimulator {
|
|||
boolean suppressEdge = q.hasSemanticContext;
|
||||
q.hasSemanticContext = false;
|
||||
|
||||
@NotNull
|
||||
|
||||
DFAState to = addDFAState(q);
|
||||
|
||||
if (suppressEdge) {
|
||||
|
@ -669,7 +669,7 @@ public class LexerATNSimulator extends ATNSimulator {
|
|||
return to;
|
||||
}
|
||||
|
||||
protected void addDFAEdge(@NotNull DFAState p, int t, @NotNull DFAState q) {
|
||||
protected void addDFAEdge(DFAState p, int t, DFAState q) {
|
||||
if (t < MIN_DFA_EDGE || t > MAX_DFA_EDGE) {
|
||||
// Only track edges within the DFA bounds
|
||||
return;
|
||||
|
@ -693,8 +693,8 @@ public class LexerATNSimulator extends ATNSimulator {
|
|||
configuration containing an ATN rule stop state. Later, when
|
||||
traversing the DFA, we will know which rule to accept.
|
||||
*/
|
||||
@NotNull
|
||||
protected DFAState addDFAState(@NotNull ATNConfigSet configs) {
|
||||
|
||||
protected DFAState addDFAState(ATNConfigSet configs) {
|
||||
/* the lexer evaluates predicates on-the-fly; by this point configs
|
||||
* should not contain any configurations with unevaluated predicates.
|
||||
*/
|
||||
|
@ -730,15 +730,15 @@ public class LexerATNSimulator extends ATNSimulator {
|
|||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
public final DFA getDFA(int mode) {
|
||||
return decisionToDFA[mode];
|
||||
}
|
||||
|
||||
/** Get the text matched so far for the current token.
|
||||
*/
|
||||
@NotNull
|
||||
public String getText(@NotNull CharStream input) {
|
||||
|
||||
public String getText(CharStream input) {
|
||||
// index is first lookahead char, don't include.
|
||||
return input.getText(Interval.of(startIndex, input.index()-1));
|
||||
}
|
||||
|
@ -759,7 +759,7 @@ public class LexerATNSimulator extends ATNSimulator {
|
|||
this.charPositionInLine = charPositionInLine;
|
||||
}
|
||||
|
||||
public void consume(@NotNull CharStream input) {
|
||||
public void consume(CharStream input) {
|
||||
int curChar = input.LA(1);
|
||||
if ( curChar=='\n' ) {
|
||||
line++;
|
||||
|
@ -770,7 +770,7 @@ public class LexerATNSimulator extends ATNSimulator {
|
|||
input.consume();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
public String getTokenName(int t) {
|
||||
if ( t==-1 ) return "EOF";
|
||||
//if ( atn.g!=null ) return atn.g.getTokenDisplayName(t);
|
||||
|
|
|
@ -48,7 +48,6 @@ public interface LexerAction {
|
|||
*
|
||||
* @return The serialization type of the lexer action.
|
||||
*/
|
||||
@NotNull
|
||||
LexerActionType getActionType();
|
||||
|
||||
/**
|
||||
|
@ -75,5 +74,5 @@ public interface LexerAction {
|
|||
*
|
||||
* @param lexer The lexer instance.
|
||||
*/
|
||||
void execute(@NotNull Lexer lexer);
|
||||
void execute(Lexer lexer);
|
||||
}
|
||||
|
|
|
@ -36,7 +36,6 @@ import org.antlr.v4.runtime.Lexer;
|
|||
import org.antlr.v4.runtime.dfa.DFA;
|
||||
import org.antlr.v4.runtime.misc.MurmurHash;
|
||||
import org.antlr.v4.runtime.misc.NotNull;
|
||||
import org.antlr.v4.runtime.misc.Nullable;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
|
@ -52,7 +51,7 @@ import java.util.Arrays;
|
|||
* @since 4.2
|
||||
*/
|
||||
public class LexerActionExecutor {
|
||||
@NotNull
|
||||
|
||||
private final LexerAction[] lexerActions;
|
||||
/**
|
||||
* Caches the result of {@link #hashCode} since the hash code is an element
|
||||
|
@ -64,7 +63,7 @@ public class LexerActionExecutor {
|
|||
* Constructs an executor for a sequence of {@link LexerAction} actions.
|
||||
* @param lexerActions The lexer actions to execute.
|
||||
*/
|
||||
public LexerActionExecutor(@NotNull LexerAction[] lexerActions) {
|
||||
public LexerActionExecutor(LexerAction[] lexerActions) {
|
||||
this.lexerActions = lexerActions;
|
||||
|
||||
int hash = MurmurHash.initialize();
|
||||
|
@ -90,8 +89,7 @@ public class LexerActionExecutor {
|
|||
* @return A {@link LexerActionExecutor} for executing the combine actions
|
||||
* of {@code lexerActionExecutor} and {@code lexerAction}.
|
||||
*/
|
||||
@NotNull
|
||||
public static LexerActionExecutor append(@Nullable LexerActionExecutor lexerActionExecutor, @NotNull LexerAction lexerAction) {
|
||||
public static LexerActionExecutor append(LexerActionExecutor lexerActionExecutor, LexerAction lexerAction) {
|
||||
if (lexerActionExecutor == null) {
|
||||
return new LexerActionExecutor(new LexerAction[] { lexerAction });
|
||||
}
|
||||
|
@ -153,7 +151,6 @@ public class LexerActionExecutor {
|
|||
* Gets the lexer actions to be executed by this executor.
|
||||
* @return The lexer actions to be executed by this executor.
|
||||
*/
|
||||
@NotNull
|
||||
public LexerAction[] getLexerActions() {
|
||||
return lexerActions;
|
||||
}
|
||||
|
@ -177,7 +174,7 @@ public class LexerActionExecutor {
|
|||
* {@link IntStream#seek} to set the {@code input} position to the beginning
|
||||
* of the token.
|
||||
*/
|
||||
public void execute(@NotNull Lexer lexer, CharStream input, int startIndex) {
|
||||
public void execute(Lexer lexer, CharStream input, int startIndex) {
|
||||
boolean requiresSeek = false;
|
||||
int stopIndex = input.index();
|
||||
try {
|
||||
|
|
|
@ -33,7 +33,6 @@ package org.antlr.v4.runtime.atn;
|
|||
import org.antlr.v4.runtime.Lexer;
|
||||
import org.antlr.v4.runtime.Token;
|
||||
import org.antlr.v4.runtime.misc.MurmurHash;
|
||||
import org.antlr.v4.runtime.misc.NotNull;
|
||||
|
||||
/**
|
||||
* Implements the {@code channel} lexer action by calling
|
||||
|
@ -87,7 +86,7 @@ public final class LexerChannelAction implements LexerAction {
|
|||
* value provided by {@link #getChannel}.</p>
|
||||
*/
|
||||
@Override
|
||||
public void execute(@NotNull Lexer lexer) {
|
||||
public void execute(Lexer lexer) {
|
||||
lexer.setChannel(channel);
|
||||
}
|
||||
|
||||
|
|
|
@ -34,7 +34,6 @@ import org.antlr.v4.runtime.CharStream;
|
|||
import org.antlr.v4.runtime.Lexer;
|
||||
import org.antlr.v4.runtime.Recognizer;
|
||||
import org.antlr.v4.runtime.misc.MurmurHash;
|
||||
import org.antlr.v4.runtime.misc.NotNull;
|
||||
|
||||
/**
|
||||
* Executes a custom lexer action by calling {@link Recognizer#action} with the
|
||||
|
@ -118,7 +117,7 @@ public final class LexerCustomAction implements LexerAction {
|
|||
* appropriate rule and action indexes.</p>
|
||||
*/
|
||||
@Override
|
||||
public void execute(@NotNull Lexer lexer) {
|
||||
public void execute(Lexer lexer) {
|
||||
lexer.action(null, ruleIndex, actionIndex);
|
||||
}
|
||||
|
||||
|
|
|
@ -65,7 +65,7 @@ public final class LexerIndexedCustomAction implements LexerAction {
|
|||
* @param action The lexer action to execute at a particular offset in the
|
||||
* input {@link CharStream}.
|
||||
*/
|
||||
public LexerIndexedCustomAction(int offset, @NotNull LexerAction action) {
|
||||
public LexerIndexedCustomAction(int offset, LexerAction action) {
|
||||
this.offset = offset;
|
||||
this.action = action;
|
||||
}
|
||||
|
@ -87,7 +87,6 @@ public final class LexerIndexedCustomAction implements LexerAction {
|
|||
*
|
||||
* @return A {@link LexerAction} object which executes the lexer action.
|
||||
*/
|
||||
@NotNull
|
||||
public LexerAction getAction() {
|
||||
return action;
|
||||
}
|
||||
|
|
|
@ -32,7 +32,6 @@ package org.antlr.v4.runtime.atn;
|
|||
|
||||
import org.antlr.v4.runtime.Lexer;
|
||||
import org.antlr.v4.runtime.misc.MurmurHash;
|
||||
import org.antlr.v4.runtime.misc.NotNull;
|
||||
|
||||
/**
|
||||
* Implements the {@code mode} lexer action by calling {@link Lexer#mode} with
|
||||
|
@ -86,7 +85,7 @@ public final class LexerModeAction implements LexerAction {
|
|||
* value provided by {@link #getMode}.</p>
|
||||
*/
|
||||
@Override
|
||||
public void execute(@NotNull Lexer lexer) {
|
||||
public void execute(Lexer lexer) {
|
||||
lexer.mode(mode);
|
||||
}
|
||||
|
||||
|
|
|
@ -32,7 +32,6 @@ package org.antlr.v4.runtime.atn;
|
|||
|
||||
import org.antlr.v4.runtime.Lexer;
|
||||
import org.antlr.v4.runtime.misc.MurmurHash;
|
||||
import org.antlr.v4.runtime.misc.NotNull;
|
||||
|
||||
/**
|
||||
* Implements the {@code more} lexer action by calling {@link Lexer#more}.
|
||||
|
@ -79,7 +78,7 @@ public final class LexerMoreAction implements LexerAction {
|
|||
* <p>This action is implemented by calling {@link Lexer#more}.</p>
|
||||
*/
|
||||
@Override
|
||||
public void execute(@NotNull Lexer lexer) {
|
||||
public void execute(Lexer lexer) {
|
||||
lexer.more();
|
||||
}
|
||||
|
||||
|
|
|
@ -32,7 +32,6 @@ package org.antlr.v4.runtime.atn;
|
|||
|
||||
import org.antlr.v4.runtime.Lexer;
|
||||
import org.antlr.v4.runtime.misc.MurmurHash;
|
||||
import org.antlr.v4.runtime.misc.NotNull;
|
||||
|
||||
/**
|
||||
* Implements the {@code popMode} lexer action by calling {@link Lexer#popMode}.
|
||||
|
@ -79,7 +78,7 @@ public final class LexerPopModeAction implements LexerAction {
|
|||
* <p>This action is implemented by calling {@link Lexer#popMode}.</p>
|
||||
*/
|
||||
@Override
|
||||
public void execute(@NotNull Lexer lexer) {
|
||||
public void execute(Lexer lexer) {
|
||||
lexer.popMode();
|
||||
}
|
||||
|
||||
|
|
|
@ -32,7 +32,6 @@ package org.antlr.v4.runtime.atn;
|
|||
|
||||
import org.antlr.v4.runtime.Lexer;
|
||||
import org.antlr.v4.runtime.misc.MurmurHash;
|
||||
import org.antlr.v4.runtime.misc.NotNull;
|
||||
|
||||
/**
|
||||
* Implements the {@code pushMode} lexer action by calling
|
||||
|
@ -86,7 +85,7 @@ public final class LexerPushModeAction implements LexerAction {
|
|||
* value provided by {@link #getMode}.</p>
|
||||
*/
|
||||
@Override
|
||||
public void execute(@NotNull Lexer lexer) {
|
||||
public void execute(Lexer lexer) {
|
||||
lexer.pushMode(mode);
|
||||
}
|
||||
|
||||
|
|
|
@ -32,7 +32,6 @@ package org.antlr.v4.runtime.atn;
|
|||
|
||||
import org.antlr.v4.runtime.Lexer;
|
||||
import org.antlr.v4.runtime.misc.MurmurHash;
|
||||
import org.antlr.v4.runtime.misc.NotNull;
|
||||
|
||||
/**
|
||||
* Implements the {@code skip} lexer action by calling {@link Lexer#skip}.
|
||||
|
@ -79,7 +78,7 @@ public final class LexerSkipAction implements LexerAction {
|
|||
* <p>This action is implemented by calling {@link Lexer#skip}.</p>
|
||||
*/
|
||||
@Override
|
||||
public void execute(@NotNull Lexer lexer) {
|
||||
public void execute(Lexer lexer) {
|
||||
lexer.skip();
|
||||
}
|
||||
|
||||
|
|
|
@ -32,7 +32,6 @@ package org.antlr.v4.runtime.atn;
|
|||
|
||||
import org.antlr.v4.runtime.Lexer;
|
||||
import org.antlr.v4.runtime.misc.MurmurHash;
|
||||
import org.antlr.v4.runtime.misc.NotNull;
|
||||
|
||||
/**
|
||||
* Implements the {@code type} lexer action by calling {@link Lexer#setType}
|
||||
|
@ -85,7 +84,7 @@ public class LexerTypeAction implements LexerAction {
|
|||
* value provided by {@link #getType}.</p>
|
||||
*/
|
||||
@Override
|
||||
public void execute(@NotNull Lexer lexer) {
|
||||
public void execute(Lexer lexer) {
|
||||
lexer.setType(type);
|
||||
}
|
||||
|
||||
|
|
|
@ -31,8 +31,6 @@
|
|||
package org.antlr.v4.runtime.atn;
|
||||
|
||||
import org.antlr.v4.runtime.TokenStream;
|
||||
import org.antlr.v4.runtime.misc.NotNull;
|
||||
import org.antlr.v4.runtime.misc.Nullable;
|
||||
|
||||
/**
|
||||
* This class represents profiling event information for tracking the lookahead
|
||||
|
@ -56,8 +54,8 @@ public class LookaheadEventInfo extends DecisionEventInfo {
|
|||
* prediction; otherwise, {@code false} if the current lookahead is part of
|
||||
* an SLL prediction
|
||||
*/
|
||||
public LookaheadEventInfo(int decision, @Nullable ATNConfigSet configs,
|
||||
@NotNull TokenStream input, int startIndex, int stopIndex,
|
||||
public LookaheadEventInfo(int decision, ATNConfigSet configs,
|
||||
TokenStream input, int startIndex, int stopIndex,
|
||||
boolean fullCtx)
|
||||
{
|
||||
super(decision, configs, input, startIndex, stopIndex, fullCtx);
|
||||
|
|
|
@ -31,11 +31,9 @@
|
|||
package org.antlr.v4.runtime.atn;
|
||||
|
||||
import org.antlr.v4.runtime.misc.IntervalSet;
|
||||
import org.antlr.v4.runtime.misc.NotNull;
|
||||
import org.antlr.v4.runtime.misc.Nullable;
|
||||
|
||||
public final class NotSetTransition extends SetTransition {
|
||||
public NotSetTransition(@NotNull ATNState target, @Nullable IntervalSet set) {
|
||||
public NotSetTransition(ATNState target, IntervalSet set) {
|
||||
super(target, set);
|
||||
}
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ import java.util.List;
|
|||
public class ParseInfo {
|
||||
protected final ProfilingATNSimulator atnSimulator;
|
||||
|
||||
public ParseInfo(@NotNull ProfilingATNSimulator atnSimulator) {
|
||||
public ParseInfo(ProfilingATNSimulator atnSimulator) {
|
||||
this.atnSimulator = atnSimulator;
|
||||
}
|
||||
|
||||
|
@ -56,7 +56,6 @@ public class ParseInfo {
|
|||
* @return An array of {@link DecisionInfo} instances, indexed by decision
|
||||
* number.
|
||||
*/
|
||||
@NotNull
|
||||
public DecisionInfo[] getDecisionInfo() {
|
||||
return atnSimulator.getDecisionInfo();
|
||||
}
|
||||
|
@ -69,7 +68,6 @@ public class ParseInfo {
|
|||
* @return A list of decision numbers which required one or more
|
||||
* full-context predictions during parsing.
|
||||
*/
|
||||
@NotNull
|
||||
public List<Integer> getLLDecisions() {
|
||||
DecisionInfo[] decisions = atnSimulator.getDecisionInfo();
|
||||
List<Integer> LL = new ArrayList<Integer>();
|
||||
|
|
|
@ -293,14 +293,12 @@ public class ParserATNSimulator extends ATNSimulator {
|
|||
public static final boolean dfa_debug = false;
|
||||
public static final boolean retry_debug = false;
|
||||
|
||||
@Nullable
|
||||
protected final Parser parser;
|
||||
|
||||
@NotNull
|
||||
public final DFA[] decisionToDFA;
|
||||
|
||||
/** SLL, LL, or LL + exact ambig detection? */
|
||||
@NotNull
|
||||
|
||||
private PredictionMode mode = PredictionMode.LL;
|
||||
|
||||
/** Each prediction operation uses a cache for merge of prediction contexts.
|
||||
|
@ -320,15 +318,15 @@ public class ParserATNSimulator extends ATNSimulator {
|
|||
protected DFA _dfa;
|
||||
|
||||
/** Testing only! */
|
||||
public ParserATNSimulator(@NotNull ATN atn, @NotNull DFA[] decisionToDFA,
|
||||
@NotNull PredictionContextCache sharedContextCache)
|
||||
public ParserATNSimulator(ATN atn, DFA[] decisionToDFA,
|
||||
PredictionContextCache sharedContextCache)
|
||||
{
|
||||
this(null, atn, decisionToDFA, sharedContextCache);
|
||||
}
|
||||
|
||||
public ParserATNSimulator(@Nullable Parser parser, @NotNull ATN atn,
|
||||
@NotNull DFA[] decisionToDFA,
|
||||
@NotNull PredictionContextCache sharedContextCache)
|
||||
public ParserATNSimulator(Parser parser, ATN atn,
|
||||
DFA[] decisionToDFA,
|
||||
PredictionContextCache sharedContextCache)
|
||||
{
|
||||
super(atn, sharedContextCache);
|
||||
this.parser = parser;
|
||||
|
@ -349,8 +347,8 @@ public class ParserATNSimulator extends ATNSimulator {
|
|||
}
|
||||
}
|
||||
|
||||
public int adaptivePredict(@NotNull TokenStream input, int decision,
|
||||
@Nullable ParserRuleContext outerContext)
|
||||
public int adaptivePredict(TokenStream input, int decision,
|
||||
ParserRuleContext outerContext)
|
||||
{
|
||||
if ( debug || debug_list_atn_decisions ) {
|
||||
System.out.println("adaptivePredict decision "+decision+
|
||||
|
@ -465,8 +463,8 @@ public class ParserATNSimulator extends ATNSimulator {
|
|||
conflict
|
||||
conflict + preds
|
||||
*/
|
||||
protected int execATN(@NotNull DFA dfa, @NotNull DFAState s0,
|
||||
@NotNull TokenStream input, int startIndex,
|
||||
protected int execATN(DFA dfa, DFAState s0,
|
||||
TokenStream input, int startIndex,
|
||||
ParserRuleContext outerContext)
|
||||
{
|
||||
if ( debug || debug_list_atn_decisions) {
|
||||
|
@ -584,8 +582,7 @@ public class ParserATNSimulator extends ATNSimulator {
|
|||
* {@code t}, or {@code null} if the target state for this edge is not
|
||||
* already cached
|
||||
*/
|
||||
@Nullable
|
||||
protected DFAState getExistingTargetState(@NotNull DFAState previousD, int t) {
|
||||
protected DFAState getExistingTargetState(DFAState previousD, int t) {
|
||||
DFAState[] edges = previousD.edges;
|
||||
if (edges == null || t + 1 < 0 || t + 1 >= edges.length) {
|
||||
return null;
|
||||
|
@ -606,8 +603,7 @@ public class ParserATNSimulator extends ATNSimulator {
|
|||
* {@code t}. If {@code t} does not lead to a valid DFA state, this method
|
||||
* returns {@link #ERROR}.
|
||||
*/
|
||||
@NotNull
|
||||
protected DFAState computeTargetState(@NotNull DFA dfa, @NotNull DFAState previousD, int t) {
|
||||
protected DFAState computeTargetState(DFA dfa, DFAState previousD, int t) {
|
||||
ATNConfigSet reach = computeReachSet(previousD.configs, t, false);
|
||||
if ( reach==null ) {
|
||||
addDFAEdge(dfa, previousD, t, ERROR);
|
||||
|
@ -678,8 +674,8 @@ public class ParserATNSimulator extends ATNSimulator {
|
|||
// comes back with reach.uniqueAlt set to a valid alt
|
||||
protected int execATNWithFullContext(DFA dfa,
|
||||
DFAState D, // how far we got before failing over
|
||||
@NotNull ATNConfigSet s0,
|
||||
@NotNull TokenStream input, int startIndex,
|
||||
ATNConfigSet s0,
|
||||
TokenStream input, int startIndex,
|
||||
ParserRuleContext outerContext)
|
||||
{
|
||||
if ( debug || debug_list_atn_decisions ) {
|
||||
|
@ -949,8 +945,7 @@ public class ParserATNSimulator extends ATNSimulator {
|
|||
* rule stop state, otherwise return a new configuration set containing only
|
||||
* the configurations from {@code configs} which are in a rule stop state
|
||||
*/
|
||||
@NotNull
|
||||
protected ATNConfigSet removeAllConfigsNotInRuleStopState(@NotNull ATNConfigSet configs, boolean lookToEndOfRule) {
|
||||
protected ATNConfigSet removeAllConfigsNotInRuleStopState(ATNConfigSet configs, boolean lookToEndOfRule) {
|
||||
if (PredictionMode.allConfigsInRuleStopStates(configs)) {
|
||||
return configs;
|
||||
}
|
||||
|
@ -974,9 +969,9 @@ public class ParserATNSimulator extends ATNSimulator {
|
|||
return result;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
protected ATNConfigSet computeStartState(@NotNull ATNState p,
|
||||
@Nullable RuleContext ctx,
|
||||
|
||||
protected ATNConfigSet computeStartState(ATNState p,
|
||||
RuleContext ctx,
|
||||
boolean fullCtx)
|
||||
{
|
||||
// always at least the implicit call to start rule
|
||||
|
@ -1099,7 +1094,7 @@ public class ParserATNSimulator extends ATNSimulator {
|
|||
state p, corresponding to a rule invocation with precedence
|
||||
level 0"
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* This method transforms the start state computed by
|
||||
* {@link #computeStartState} to the special start state used by a
|
||||
|
@ -1160,8 +1155,7 @@ public class ParserATNSimulator extends ATNSimulator {
|
|||
* for a precedence DFA at a particular precedence level (determined by
|
||||
* calling {@link Parser#getPrecedence}).
|
||||
*/
|
||||
@NotNull
|
||||
protected ATNConfigSet applyPrecedenceFilter(@NotNull ATNConfigSet configs) {
|
||||
protected ATNConfigSet applyPrecedenceFilter(ATNConfigSet configs) {
|
||||
Map<Integer, PredictionContext> statesFromAlt1 = new HashMap<Integer, PredictionContext>();
|
||||
ATNConfigSet configSet = new ATNConfigSet(configs.fullCtx);
|
||||
for (ATNConfig config : configs) {
|
||||
|
@ -1209,8 +1203,7 @@ public class ParserATNSimulator extends ATNSimulator {
|
|||
return configSet;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected ATNState getReachableTarget(@NotNull Transition trans, int ttype) {
|
||||
protected ATNState getReachableTarget(Transition trans, int ttype) {
|
||||
if (trans.matches(ttype, 0, atn.maxTokenType)) {
|
||||
return trans.target;
|
||||
}
|
||||
|
@ -1218,8 +1211,8 @@ public class ParserATNSimulator extends ATNSimulator {
|
|||
return null;
|
||||
}
|
||||
|
||||
protected SemanticContext[] getPredsForAmbigAlts(@NotNull BitSet ambigAlts,
|
||||
@NotNull ATNConfigSet configs,
|
||||
protected SemanticContext[] getPredsForAmbigAlts(BitSet ambigAlts,
|
||||
ATNConfigSet configs,
|
||||
int nalts)
|
||||
{
|
||||
// REACH=[1|1|[]|0:0, 1|2|[]|0:1]
|
||||
|
@ -1403,7 +1396,7 @@ public class ParserATNSimulator extends ATNSimulator {
|
|||
* then we stop at the first predicate that evaluates to true. This
|
||||
* includes pairs with null predicates.
|
||||
*/
|
||||
protected BitSet evalSemanticContext(@NotNull DFAState.PredPrediction[] predPredictions,
|
||||
protected BitSet evalSemanticContext(DFAState.PredPrediction[] predPredictions,
|
||||
ParserRuleContext outerContext,
|
||||
boolean complete)
|
||||
{
|
||||
|
@ -1465,7 +1458,7 @@ public class ParserATNSimulator extends ATNSimulator {
|
|||
*
|
||||
* @since 4.3
|
||||
*/
|
||||
protected boolean evalSemanticContext(@NotNull SemanticContext pred, ParserRuleContext parserCallStack, int alt, boolean fullCtx) {
|
||||
protected boolean evalSemanticContext(SemanticContext pred, ParserRuleContext parserCallStack, int alt, boolean fullCtx) {
|
||||
return pred.eval(parser, parserCallStack);
|
||||
}
|
||||
|
||||
|
@ -1476,9 +1469,9 @@ public class ParserATNSimulator extends ATNSimulator {
|
|||
ambig detection thought :(
|
||||
*/
|
||||
|
||||
protected void closure(@NotNull ATNConfig config,
|
||||
@NotNull ATNConfigSet configs,
|
||||
@NotNull Set<ATNConfig> closureBusy,
|
||||
protected void closure(ATNConfig config,
|
||||
ATNConfigSet configs,
|
||||
Set<ATNConfig> closureBusy,
|
||||
boolean collectPredicates,
|
||||
boolean fullCtx,
|
||||
boolean treatEofAsEpsilon)
|
||||
|
@ -1490,9 +1483,9 @@ public class ParserATNSimulator extends ATNSimulator {
|
|||
assert !fullCtx || !configs.dipsIntoOuterContext;
|
||||
}
|
||||
|
||||
protected void closureCheckingStopState(@NotNull ATNConfig config,
|
||||
@NotNull ATNConfigSet configs,
|
||||
@NotNull Set<ATNConfig> closureBusy,
|
||||
protected void closureCheckingStopState(ATNConfig config,
|
||||
ATNConfigSet configs,
|
||||
Set<ATNConfig> closureBusy,
|
||||
boolean collectPredicates,
|
||||
boolean fullCtx,
|
||||
int depth,
|
||||
|
@ -1554,9 +1547,9 @@ public class ParserATNSimulator extends ATNSimulator {
|
|||
}
|
||||
|
||||
/** Do the actual work of walking epsilon edges */
|
||||
protected void closure_(@NotNull ATNConfig config,
|
||||
@NotNull ATNConfigSet configs,
|
||||
@NotNull Set<ATNConfig> closureBusy,
|
||||
protected void closure_(ATNConfig config,
|
||||
ATNConfigSet configs,
|
||||
Set<ATNConfig> closureBusy,
|
||||
boolean collectPredicates,
|
||||
boolean fullCtx,
|
||||
int depth,
|
||||
|
@ -1623,15 +1616,15 @@ public class ParserATNSimulator extends ATNSimulator {
|
|||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
public String getRuleName(int index) {
|
||||
if ( parser!=null && index>=0 ) return parser.getRuleNames()[index];
|
||||
return "<rule "+index+">";
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected ATNConfig getEpsilonTarget(@NotNull ATNConfig config,
|
||||
@NotNull Transition t,
|
||||
|
||||
protected ATNConfig getEpsilonTarget(ATNConfig config,
|
||||
Transition t,
|
||||
boolean collectPredicates,
|
||||
boolean inContext,
|
||||
boolean fullCtx,
|
||||
|
@ -1674,15 +1667,15 @@ public class ParserATNSimulator extends ATNSimulator {
|
|||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
protected ATNConfig actionTransition(@NotNull ATNConfig config, @NotNull ActionTransition t) {
|
||||
|
||||
protected ATNConfig actionTransition(ATNConfig config, ActionTransition t) {
|
||||
if ( debug ) System.out.println("ACTION edge "+t.ruleIndex+":"+t.actionIndex);
|
||||
return new ATNConfig(config, t.target);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public ATNConfig precedenceTransition(@NotNull ATNConfig config,
|
||||
@NotNull PrecedencePredicateTransition pt,
|
||||
|
||||
public ATNConfig precedenceTransition(ATNConfig config,
|
||||
PrecedencePredicateTransition pt,
|
||||
boolean collectPredicates,
|
||||
boolean inContext,
|
||||
boolean fullCtx)
|
||||
|
@ -1726,9 +1719,9 @@ public class ParserATNSimulator extends ATNSimulator {
|
|||
return c;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected ATNConfig predTransition(@NotNull ATNConfig config,
|
||||
@NotNull PredicateTransition pt,
|
||||
|
||||
protected ATNConfig predTransition(ATNConfig config,
|
||||
PredicateTransition pt,
|
||||
boolean collectPredicates,
|
||||
boolean inContext,
|
||||
boolean fullCtx)
|
||||
|
@ -1774,8 +1767,8 @@ public class ParserATNSimulator extends ATNSimulator {
|
|||
return c;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
protected ATNConfig ruleTransition(@NotNull ATNConfig config, @NotNull RuleTransition t) {
|
||||
|
||||
protected ATNConfig ruleTransition(ATNConfig config, RuleTransition t) {
|
||||
if ( debug ) {
|
||||
System.out.println("CALL rule "+getRuleName(t.target.ruleIndex)+
|
||||
", ctx="+config.context);
|
||||
|
@ -1796,8 +1789,7 @@ public class ParserATNSimulator extends ATNSimulator {
|
|||
* conflicting alternative subsets. If {@code configs} does not contain any
|
||||
* conflicting subsets, this method returns an empty {@link BitSet}.
|
||||
*/
|
||||
@NotNull
|
||||
protected BitSet getConflictingAlts(@NotNull ATNConfigSet configs) {
|
||||
protected BitSet getConflictingAlts(ATNConfigSet configs) {
|
||||
Collection<BitSet> altsets = PredictionMode.getConflictingAltSubsets(configs);
|
||||
return PredictionMode.getAlts(altsets);
|
||||
}
|
||||
|
@ -1838,7 +1830,6 @@ public class ParserATNSimulator extends ATNSimulator {
|
|||
ignore a set of conflicting alts when we have an alternative
|
||||
that we still need to pursue.
|
||||
*/
|
||||
|
||||
protected BitSet getConflictingAltsOrUniqueAlt(ATNConfigSet configs) {
|
||||
BitSet conflictingAlts;
|
||||
if ( configs.uniqueAlt!= ATN.INVALID_ALT_NUMBER ) {
|
||||
|
@ -1851,7 +1842,7 @@ public class ParserATNSimulator extends ATNSimulator {
|
|||
return conflictingAlts;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
public String getTokenName(int t) {
|
||||
if (t == Token.EOF) {
|
||||
return "EOF";
|
||||
|
@ -1874,7 +1865,7 @@ public class ParserATNSimulator extends ATNSimulator {
|
|||
* it out for clarity now that alg. works well. We can leave this
|
||||
* "dead" code for a bit.
|
||||
*/
|
||||
public void dumpDeadEndConfigs(@NotNull NoViableAltException nvae) {
|
||||
public void dumpDeadEndConfigs(NoViableAltException nvae) {
|
||||
System.err.println("dead end configs: ");
|
||||
for (ATNConfig c : nvae.getDeadEndConfigs()) {
|
||||
String trans = "no edges";
|
||||
|
@ -1894,10 +1885,10 @@ public class ParserATNSimulator extends ATNSimulator {
|
|||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
protected NoViableAltException noViableAlt(@NotNull TokenStream input,
|
||||
@NotNull ParserRuleContext outerContext,
|
||||
@NotNull ATNConfigSet configs,
|
||||
|
||||
protected NoViableAltException noViableAlt(TokenStream input,
|
||||
ParserRuleContext outerContext,
|
||||
ATNConfigSet configs,
|
||||
int startIndex)
|
||||
{
|
||||
return new NoViableAltException(parser, input,
|
||||
|
@ -1906,7 +1897,7 @@ public class ParserATNSimulator extends ATNSimulator {
|
|||
configs, outerContext);
|
||||
}
|
||||
|
||||
protected static int getUniqueAlt(@NotNull ATNConfigSet configs) {
|
||||
protected static int getUniqueAlt(ATNConfigSet configs) {
|
||||
int alt = ATN.INVALID_ALT_NUMBER;
|
||||
for (ATNConfig c : configs) {
|
||||
if ( alt == ATN.INVALID_ALT_NUMBER ) {
|
||||
|
@ -1939,10 +1930,10 @@ public class ParserATNSimulator extends ATNSimulator {
|
|||
* otherwise this method returns the result of calling {@link #addDFAState}
|
||||
* on {@code to}
|
||||
*/
|
||||
protected DFAState addDFAEdge(@NotNull DFA dfa,
|
||||
@Nullable DFAState from,
|
||||
protected DFAState addDFAEdge(DFA dfa,
|
||||
DFAState from,
|
||||
int t,
|
||||
@Nullable DFAState to)
|
||||
DFAState to)
|
||||
{
|
||||
if ( debug ) {
|
||||
System.out.println("EDGE "+from+" -> "+to+" upon "+getTokenName(t));
|
||||
|
@ -1987,8 +1978,7 @@ public class ParserATNSimulator extends ATNSimulator {
|
|||
* state if {@code D} is already in the DFA, or {@code D} itself if the
|
||||
* state was not already present.
|
||||
*/
|
||||
@NotNull
|
||||
protected DFAState addDFAState(@NotNull DFA dfa, @NotNull DFAState D) {
|
||||
protected DFAState addDFAState(DFA dfa, DFAState D) {
|
||||
if (D == ERROR) {
|
||||
return D;
|
||||
}
|
||||
|
@ -2008,7 +1998,7 @@ public class ParserATNSimulator extends ATNSimulator {
|
|||
}
|
||||
}
|
||||
|
||||
protected void reportAttemptingFullContext(@NotNull DFA dfa, @Nullable BitSet conflictingAlts, @NotNull ATNConfigSet configs, int startIndex, int stopIndex) {
|
||||
protected void reportAttemptingFullContext(DFA dfa, BitSet conflictingAlts, ATNConfigSet configs, int startIndex, int stopIndex) {
|
||||
if ( debug || retry_debug ) {
|
||||
Interval interval = Interval.of(startIndex, stopIndex);
|
||||
System.out.println("reportAttemptingFullContext decision="+dfa.decision+":"+configs+
|
||||
|
@ -2017,7 +2007,7 @@ public class ParserATNSimulator extends ATNSimulator {
|
|||
if ( parser!=null ) parser.getErrorListenerDispatch().reportAttemptingFullContext(parser, dfa, startIndex, stopIndex, conflictingAlts, configs);
|
||||
}
|
||||
|
||||
protected void reportContextSensitivity(@NotNull DFA dfa, int prediction, @NotNull ATNConfigSet configs, int startIndex, int stopIndex) {
|
||||
protected void reportContextSensitivity(DFA dfa, int prediction, ATNConfigSet configs, int startIndex, int stopIndex) {
|
||||
if ( debug || retry_debug ) {
|
||||
Interval interval = Interval.of(startIndex, stopIndex);
|
||||
System.out.println("reportContextSensitivity decision="+dfa.decision+":"+configs+
|
||||
|
@ -2027,10 +2017,10 @@ public class ParserATNSimulator extends ATNSimulator {
|
|||
}
|
||||
|
||||
/** If context sensitive parsing, we know it's ambiguity not conflict */
|
||||
protected void reportAmbiguity(@NotNull DFA dfa, DFAState D, int startIndex, int stopIndex,
|
||||
protected void reportAmbiguity(DFA dfa, DFAState D, int startIndex, int stopIndex,
|
||||
boolean exact,
|
||||
@Nullable BitSet ambigAlts,
|
||||
@NotNull ATNConfigSet configs)
|
||||
BitSet ambigAlts,
|
||||
ATNConfigSet configs)
|
||||
{
|
||||
if ( debug || retry_debug ) {
|
||||
Interval interval = Interval.of(startIndex, stopIndex);
|
||||
|
@ -2042,11 +2032,11 @@ public class ParserATNSimulator extends ATNSimulator {
|
|||
exact, ambigAlts, configs);
|
||||
}
|
||||
|
||||
public final void setPredictionMode(@NotNull PredictionMode mode) {
|
||||
public final void setPredictionMode(PredictionMode mode) {
|
||||
this.mode = mode;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
public final PredictionMode getPredictionMode() {
|
||||
return mode;
|
||||
}
|
||||
|
|
|
@ -30,8 +30,6 @@
|
|||
|
||||
package org.antlr.v4.runtime.atn;
|
||||
|
||||
import org.antlr.v4.runtime.misc.NotNull;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sam Harwell
|
||||
|
@ -39,7 +37,7 @@ import org.antlr.v4.runtime.misc.NotNull;
|
|||
public final class PrecedencePredicateTransition extends AbstractPredicateTransition {
|
||||
public final int precedence;
|
||||
|
||||
public PrecedencePredicateTransition(@NotNull ATNState target, int precedence) {
|
||||
public PrecedencePredicateTransition(ATNState target, int precedence) {
|
||||
super(target);
|
||||
this.precedence = precedence;
|
||||
}
|
||||
|
|
|
@ -34,7 +34,6 @@ import org.antlr.v4.runtime.ParserRuleContext;
|
|||
import org.antlr.v4.runtime.Recognizer;
|
||||
import org.antlr.v4.runtime.RuleContext;
|
||||
import org.antlr.v4.runtime.TokenStream;
|
||||
import org.antlr.v4.runtime.misc.NotNull;
|
||||
|
||||
/**
|
||||
* This class represents profiling event information for semantic predicate
|
||||
|
@ -84,8 +83,8 @@ public class PredicateEvalInfo extends DecisionEventInfo {
|
|||
* @see SemanticContext#eval(Recognizer, RuleContext)
|
||||
*/
|
||||
public PredicateEvalInfo(int decision,
|
||||
@NotNull TokenStream input, int startIndex, int stopIndex,
|
||||
@NotNull SemanticContext semctx,
|
||||
TokenStream input, int startIndex, int stopIndex,
|
||||
SemanticContext semctx,
|
||||
boolean evalResult,
|
||||
int predictedAlt,
|
||||
boolean fullCtx)
|
||||
|
|
|
@ -43,7 +43,7 @@ public final class PredicateTransition extends AbstractPredicateTransition {
|
|||
public final int predIndex;
|
||||
public final boolean isCtxDependent; // e.g., $i ref in pred
|
||||
|
||||
public PredicateTransition(@NotNull ATNState target, int ruleIndex, int predIndex, boolean isCtxDependent) {
|
||||
public PredicateTransition(ATNState target, int ruleIndex, int predIndex, boolean isCtxDependent) {
|
||||
super(target);
|
||||
this.ruleIndex = ruleIndex;
|
||||
this.predIndex = predIndex;
|
||||
|
@ -68,7 +68,6 @@ public final class PredicateTransition extends AbstractPredicateTransition {
|
|||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String toString() {
|
||||
return "pred_"+ruleIndex+":"+predIndex;
|
||||
}
|
||||
|
|
|
@ -34,8 +34,6 @@ import org.antlr.v4.runtime.Recognizer;
|
|||
import org.antlr.v4.runtime.RuleContext;
|
||||
import org.antlr.v4.runtime.misc.DoubleKeyMap;
|
||||
import org.antlr.v4.runtime.misc.MurmurHash;
|
||||
import org.antlr.v4.runtime.misc.NotNull;
|
||||
import org.antlr.v4.runtime.misc.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
@ -95,7 +93,7 @@ public abstract class PredictionContext {
|
|||
/** Convert a {@link RuleContext} tree to a {@link PredictionContext} graph.
|
||||
* Return {@link #EMPTY} if {@code outerContext} is empty or null.
|
||||
*/
|
||||
public static PredictionContext fromRuleContext(@NotNull ATN atn, RuleContext outerContext) {
|
||||
public static PredictionContext fromRuleContext(ATN atn, RuleContext outerContext) {
|
||||
if ( outerContext==null ) outerContext = RuleContext.EMPTY;
|
||||
|
||||
// if we are in RuleContext of start rule, s, then PredictionContext
|
||||
|
@ -565,9 +563,9 @@ public abstract class PredictionContext {
|
|||
|
||||
// From Sam
|
||||
public static PredictionContext getCachedContext(
|
||||
@NotNull PredictionContext context,
|
||||
@NotNull PredictionContextCache contextCache,
|
||||
@NotNull IdentityHashMap<PredictionContext, PredictionContext> visited)
|
||||
PredictionContext context,
|
||||
PredictionContextCache contextCache,
|
||||
IdentityHashMap<PredictionContext, PredictionContext> visited)
|
||||
{
|
||||
if (context.isEmpty()) {
|
||||
return context;
|
||||
|
@ -670,7 +668,7 @@ public abstract class PredictionContext {
|
|||
}
|
||||
}
|
||||
|
||||
public String toString(@Nullable Recognizer<?,?> recog) {
|
||||
public String toString(Recognizer<?,?> recog) {
|
||||
return toString();
|
||||
// return toString(recog, ParserRuleContext.EMPTY);
|
||||
}
|
||||
|
|
|
@ -234,7 +234,7 @@ public enum PredictionMode {
|
|||
* the configurations to strip out all of the predicates so that a standard
|
||||
* {@link ATNConfigSet} will merge everything ignoring predicates.</p>
|
||||
*/
|
||||
public static boolean hasSLLConflictTerminatingPrediction(PredictionMode mode, @NotNull ATNConfigSet configs) {
|
||||
public static boolean hasSLLConflictTerminatingPrediction(PredictionMode mode, ATNConfigSet configs) {
|
||||
/* Configs in rule stop states indicate reaching the end of the decision
|
||||
* rule (local context) or end of start rule (full context). If all
|
||||
* configs meet this condition, then none of the configurations is able
|
||||
|
@ -299,7 +299,7 @@ public enum PredictionMode {
|
|||
* @return {@code true} if all configurations in {@code configs} are in a
|
||||
* {@link RuleStopState}, otherwise {@code false}
|
||||
*/
|
||||
public static boolean allConfigsInRuleStopStates(@NotNull ATNConfigSet configs) {
|
||||
public static boolean allConfigsInRuleStopStates(ATNConfigSet configs) {
|
||||
for (ATNConfig config : configs) {
|
||||
if (!(config.state instanceof RuleStopState)) {
|
||||
return false;
|
||||
|
@ -450,7 +450,7 @@ public enum PredictionMode {
|
|||
* we need exact ambiguity detection when the sets look like
|
||||
* {@code A={{1,2}}} or {@code {{1,2},{1,2}}}, etc...</p>
|
||||
*/
|
||||
public static int resolvesToJustOneViableAlt(@NotNull Collection<BitSet> altsets) {
|
||||
public static int resolvesToJustOneViableAlt(Collection<BitSet> altsets) {
|
||||
return getSingleViableAlt(altsets);
|
||||
}
|
||||
|
||||
|
@ -462,7 +462,7 @@ public enum PredictionMode {
|
|||
* @return {@code true} if every {@link BitSet} in {@code altsets} has
|
||||
* {@link BitSet#cardinality cardinality} > 1, otherwise {@code false}
|
||||
*/
|
||||
public static boolean allSubsetsConflict(@NotNull Collection<BitSet> altsets) {
|
||||
public static boolean allSubsetsConflict(Collection<BitSet> altsets) {
|
||||
return !hasNonConflictingAltSet(altsets);
|
||||
}
|
||||
|
||||
|
@ -474,7 +474,7 @@ public enum PredictionMode {
|
|||
* @return {@code true} if {@code altsets} contains a {@link BitSet} with
|
||||
* {@link BitSet#cardinality cardinality} 1, otherwise {@code false}
|
||||
*/
|
||||
public static boolean hasNonConflictingAltSet(@NotNull Collection<BitSet> altsets) {
|
||||
public static boolean hasNonConflictingAltSet(Collection<BitSet> altsets) {
|
||||
for (BitSet alts : altsets) {
|
||||
if ( alts.cardinality()==1 ) {
|
||||
return true;
|
||||
|
@ -491,7 +491,7 @@ public enum PredictionMode {
|
|||
* @return {@code true} if {@code altsets} contains a {@link BitSet} with
|
||||
* {@link BitSet#cardinality cardinality} > 1, otherwise {@code false}
|
||||
*/
|
||||
public static boolean hasConflictingAltSet(@NotNull Collection<BitSet> altsets) {
|
||||
public static boolean hasConflictingAltSet(Collection<BitSet> altsets) {
|
||||
for (BitSet alts : altsets) {
|
||||
if ( alts.cardinality()>1 ) {
|
||||
return true;
|
||||
|
@ -507,7 +507,7 @@ public enum PredictionMode {
|
|||
* @return {@code true} if every member of {@code altsets} is equal to the
|
||||
* others, otherwise {@code false}
|
||||
*/
|
||||
public static boolean allSubsetsEqual(@NotNull Collection<BitSet> altsets) {
|
||||
public static boolean allSubsetsEqual(Collection<BitSet> altsets) {
|
||||
Iterator<BitSet> it = altsets.iterator();
|
||||
BitSet first = it.next();
|
||||
while ( it.hasNext() ) {
|
||||
|
@ -524,7 +524,7 @@ public enum PredictionMode {
|
|||
*
|
||||
* @param altsets a collection of alternative subsets
|
||||
*/
|
||||
public static int getUniqueAlt(@NotNull Collection<BitSet> altsets) {
|
||||
public static int getUniqueAlt(Collection<BitSet> altsets) {
|
||||
BitSet all = getAlts(altsets);
|
||||
if ( all.cardinality()==1 ) return all.nextSetBit(0);
|
||||
return ATN.INVALID_ALT_NUMBER;
|
||||
|
@ -538,7 +538,7 @@ public enum PredictionMode {
|
|||
* @param altsets a collection of alternative subsets
|
||||
* @return the set of represented alternatives in {@code altsets}
|
||||
*/
|
||||
public static BitSet getAlts(@NotNull Collection<BitSet> altsets) {
|
||||
public static BitSet getAlts(Collection<BitSet> altsets) {
|
||||
BitSet all = new BitSet();
|
||||
for (BitSet alts : altsets) {
|
||||
all.or(alts);
|
||||
|
@ -555,8 +555,7 @@ public enum PredictionMode {
|
|||
* alt and not pred
|
||||
* </pre>
|
||||
*/
|
||||
@NotNull
|
||||
public static Collection<BitSet> getConflictingAltSubsets(@NotNull ATNConfigSet configs) {
|
||||
public static Collection<BitSet> getConflictingAltSubsets(ATNConfigSet configs) {
|
||||
AltAndContextMap configToAlts = new AltAndContextMap();
|
||||
for (ATNConfig c : configs) {
|
||||
BitSet alts = configToAlts.get(c);
|
||||
|
@ -577,8 +576,7 @@ public enum PredictionMode {
|
|||
* map[c.{@link ATNConfig#state state}] U= c.{@link ATNConfig#alt alt}
|
||||
* </pre>
|
||||
*/
|
||||
@NotNull
|
||||
public static Map<ATNState, BitSet> getStateToAltMap(@NotNull ATNConfigSet configs) {
|
||||
public static Map<ATNState, BitSet> getStateToAltMap(ATNConfigSet configs) {
|
||||
Map<ATNState, BitSet> m = new HashMap<ATNState, BitSet>();
|
||||
for (ATNConfig c : configs) {
|
||||
BitSet alts = m.get(c.state);
|
||||
|
@ -591,7 +589,7 @@ public enum PredictionMode {
|
|||
return m;
|
||||
}
|
||||
|
||||
public static boolean hasStateAssociatedWithOneAlt(@NotNull ATNConfigSet configs) {
|
||||
public static boolean hasStateAssociatedWithOneAlt(ATNConfigSet configs) {
|
||||
Map<ATNState, BitSet> x = getStateToAltMap(configs);
|
||||
for (BitSet alts : x.values()) {
|
||||
if ( alts.cardinality()==1 ) return true;
|
||||
|
@ -599,7 +597,7 @@ public enum PredictionMode {
|
|||
return false;
|
||||
}
|
||||
|
||||
public static int getSingleViableAlt(@NotNull Collection<BitSet> altsets) {
|
||||
public static int getSingleViableAlt(Collection<BitSet> altsets) {
|
||||
BitSet viableAlts = new BitSet();
|
||||
for (BitSet alts : altsets) {
|
||||
int minAlt = alts.nextSetBit(0);
|
||||
|
|
|
@ -35,8 +35,6 @@ import org.antlr.v4.runtime.ParserRuleContext;
|
|||
import org.antlr.v4.runtime.TokenStream;
|
||||
import org.antlr.v4.runtime.dfa.DFA;
|
||||
import org.antlr.v4.runtime.dfa.DFAState;
|
||||
import org.antlr.v4.runtime.misc.NotNull;
|
||||
import org.antlr.v4.runtime.misc.Nullable;
|
||||
|
||||
import java.util.BitSet;
|
||||
|
||||
|
@ -192,7 +190,7 @@ public class ProfilingATNSimulator extends ParserATNSimulator {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void reportAttemptingFullContext(@NotNull DFA dfa, @Nullable BitSet conflictingAlts, @NotNull ATNConfigSet configs, int startIndex, int stopIndex) {
|
||||
protected void reportAttemptingFullContext(DFA dfa, BitSet conflictingAlts, ATNConfigSet configs, int startIndex, int stopIndex) {
|
||||
if ( conflictingAlts!=null ) {
|
||||
conflictingAltResolvedBySLL = conflictingAlts.nextSetBit(0);
|
||||
}
|
||||
|
@ -204,7 +202,7 @@ public class ProfilingATNSimulator extends ParserATNSimulator {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void reportContextSensitivity(@NotNull DFA dfa, int prediction, @NotNull ATNConfigSet configs, int startIndex, int stopIndex) {
|
||||
protected void reportContextSensitivity(DFA dfa, int prediction, ATNConfigSet configs, int startIndex, int stopIndex) {
|
||||
if ( prediction != conflictingAltResolvedBySLL ) {
|
||||
decisions[currentDecision].contextSensitivities.add(
|
||||
new ContextSensitivityInfo(currentDecision, configs, _input, startIndex, stopIndex)
|
||||
|
@ -214,8 +212,8 @@ public class ProfilingATNSimulator extends ParserATNSimulator {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void reportAmbiguity(@NotNull DFA dfa, DFAState D, int startIndex, int stopIndex, boolean exact,
|
||||
@Nullable BitSet ambigAlts, @NotNull ATNConfigSet configs)
|
||||
protected void reportAmbiguity(DFA dfa, DFAState D, int startIndex, int stopIndex, boolean exact,
|
||||
BitSet ambigAlts, ATNConfigSet configs)
|
||||
{
|
||||
int prediction;
|
||||
if ( ambigAlts!=null ) {
|
||||
|
|
|
@ -37,7 +37,7 @@ public final class RangeTransition extends Transition {
|
|||
public final int from;
|
||||
public final int to;
|
||||
|
||||
public RangeTransition(@NotNull ATNState target, int from, int to) {
|
||||
public RangeTransition(ATNState target, int from, int to) {
|
||||
super(target);
|
||||
this.from = from;
|
||||
this.to = to;
|
||||
|
@ -49,7 +49,7 @@ public final class RangeTransition extends Transition {
|
|||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
|
||||
public IntervalSet label() { return IntervalSet.of(from, to); }
|
||||
|
||||
@Override
|
||||
|
@ -58,7 +58,6 @@ public final class RangeTransition extends Transition {
|
|||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String toString() {
|
||||
return "'"+(char)from+"'..'"+(char)to+"'";
|
||||
}
|
||||
|
|
|
@ -40,7 +40,6 @@ public final class RuleTransition extends Transition {
|
|||
public final int precedence;
|
||||
|
||||
/** What node to begin computations following ref to rule */
|
||||
@NotNull
|
||||
public ATNState followState;
|
||||
|
||||
/**
|
||||
|
@ -48,17 +47,17 @@ public final class RuleTransition extends Transition {
|
|||
* {@link #RuleTransition(RuleStartState, int, int, ATNState)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public RuleTransition(@NotNull RuleStartState ruleStart,
|
||||
public RuleTransition(RuleStartState ruleStart,
|
||||
int ruleIndex,
|
||||
@NotNull ATNState followState)
|
||||
ATNState followState)
|
||||
{
|
||||
this(ruleStart, ruleIndex, 0, followState);
|
||||
}
|
||||
|
||||
public RuleTransition(@NotNull RuleStartState ruleStart,
|
||||
public RuleTransition(RuleStartState ruleStart,
|
||||
int ruleIndex,
|
||||
int precedence,
|
||||
@NotNull ATNState followState)
|
||||
ATNState followState)
|
||||
{
|
||||
super(ruleStart);
|
||||
this.ruleIndex = ruleIndex;
|
||||
|
|
|
@ -219,7 +219,7 @@ public abstract class SemanticContext {
|
|||
*
|
||||
* @since 4.3
|
||||
*/
|
||||
@NotNull
|
||||
|
||||
public abstract Collection<SemanticContext> getOperands();
|
||||
}
|
||||
|
||||
|
@ -228,9 +228,9 @@ public abstract class SemanticContext {
|
|||
* is false.
|
||||
*/
|
||||
public static class AND extends Operator {
|
||||
@NotNull public final SemanticContext[] opnds;
|
||||
public final SemanticContext[] opnds;
|
||||
|
||||
public AND(@NotNull SemanticContext a, @NotNull SemanticContext b) {
|
||||
public AND(SemanticContext a, SemanticContext b) {
|
||||
Set<SemanticContext> operands = new HashSet<SemanticContext>();
|
||||
if ( a instanceof AND ) operands.addAll(Arrays.asList(((AND)a).opnds));
|
||||
else operands.add(a);
|
||||
|
@ -325,9 +325,9 @@ public abstract class SemanticContext {
|
|||
* contexts is true.
|
||||
*/
|
||||
public static class OR extends Operator {
|
||||
@NotNull public final SemanticContext[] opnds;
|
||||
public final SemanticContext[] opnds;
|
||||
|
||||
public OR(@NotNull SemanticContext a, @NotNull SemanticContext b) {
|
||||
public OR(SemanticContext a, SemanticContext b) {
|
||||
Set<SemanticContext> operands = new HashSet<SemanticContext>();
|
||||
if ( a instanceof OR ) operands.addAll(Arrays.asList(((OR)a).opnds));
|
||||
else operands.add(a);
|
||||
|
|
|
@ -33,15 +33,13 @@ package org.antlr.v4.runtime.atn;
|
|||
import org.antlr.v4.runtime.Token;
|
||||
import org.antlr.v4.runtime.misc.IntervalSet;
|
||||
import org.antlr.v4.runtime.misc.NotNull;
|
||||
import org.antlr.v4.runtime.misc.Nullable;
|
||||
|
||||
/** A transition containing a set of values. */
|
||||
public class SetTransition extends Transition {
|
||||
@NotNull
|
||||
public final IntervalSet set;
|
||||
|
||||
// TODO (sam): should we really allow null here?
|
||||
public SetTransition(@NotNull ATNState target, @Nullable IntervalSet set) {
|
||||
public SetTransition(ATNState target, IntervalSet set) {
|
||||
super(target);
|
||||
if ( set == null ) set = IntervalSet.of(Token.INVALID_TYPE);
|
||||
this.set = set;
|
||||
|
@ -53,7 +51,7 @@ public class SetTransition extends Transition {
|
|||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
|
||||
public IntervalSet label() { return set; }
|
||||
|
||||
@Override
|
||||
|
@ -62,7 +60,7 @@ public class SetTransition extends Transition {
|
|||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
|
||||
public String toString() {
|
||||
return set.toString();
|
||||
}
|
||||
|
|
|
@ -96,10 +96,10 @@ public abstract class Transition {
|
|||
}});
|
||||
|
||||
/** The target of this transition. */
|
||||
@NotNull
|
||||
|
||||
public ATNState target;
|
||||
|
||||
protected Transition(@NotNull ATNState target) {
|
||||
protected Transition(ATNState target) {
|
||||
if (target == null) {
|
||||
throw new NullPointerException("target cannot be null.");
|
||||
}
|
||||
|
@ -122,7 +122,7 @@ public abstract class Transition {
|
|||
return false;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
public IntervalSet label() { return null; }
|
||||
|
||||
public abstract boolean matches(int symbol, int minVocabSymbol, int maxVocabSymbol);
|
||||
|
|
|
@ -33,7 +33,7 @@ package org.antlr.v4.runtime.atn;
|
|||
import org.antlr.v4.runtime.misc.NotNull;
|
||||
|
||||
public final class WildcardTransition extends Transition {
|
||||
public WildcardTransition(@NotNull ATNState target) { super(target); }
|
||||
public WildcardTransition(ATNState target) { super(target); }
|
||||
|
||||
@Override
|
||||
public int getSerializationType() {
|
||||
|
@ -46,7 +46,6 @@ public final class WildcardTransition extends Transition {
|
|||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String toString() {
|
||||
return ".";
|
||||
}
|
||||
|
|
|
@ -50,15 +50,15 @@ public class DFA {
|
|||
/** A set of all DFA states. Use {@link Map} so we can get old state back
|
||||
* ({@link Set} only allows you to see if it's there).
|
||||
*/
|
||||
@NotNull
|
||||
|
||||
public final Map<DFAState, DFAState> states = new HashMap<DFAState, DFAState>();
|
||||
@Nullable
|
||||
|
||||
public volatile DFAState s0;
|
||||
|
||||
public final int decision;
|
||||
|
||||
/** From which ATN state did we create this DFA? */
|
||||
@NotNull
|
||||
|
||||
public final DecisionState atnStartState;
|
||||
|
||||
/**
|
||||
|
@ -68,11 +68,11 @@ public class DFA {
|
|||
*/
|
||||
private volatile boolean precedenceDfa;
|
||||
|
||||
public DFA(@NotNull DecisionState atnStartState) {
|
||||
public DFA(DecisionState atnStartState) {
|
||||
this(atnStartState, 0);
|
||||
}
|
||||
|
||||
public DFA(@NotNull DecisionState atnStartState, int decision) {
|
||||
public DFA(DecisionState atnStartState, int decision) {
|
||||
this.atnStartState = atnStartState;
|
||||
this.decision = decision;
|
||||
}
|
||||
|
@ -186,7 +186,7 @@ public class DFA {
|
|||
/**
|
||||
* Return a list of all states in this DFA, ordered by state number.
|
||||
*/
|
||||
@NotNull
|
||||
|
||||
public List<DFAState> getStates() {
|
||||
List<DFAState> result = new ArrayList<DFAState>(states.keySet());
|
||||
Collections.sort(result, new Comparator<DFAState>() {
|
||||
|
@ -206,13 +206,13 @@ public class DFA {
|
|||
* @deprecated Use {@link #toString(Vocabulary)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public String toString(@Nullable String[] tokenNames) {
|
||||
public String toString(String[] tokenNames) {
|
||||
if ( s0==null ) return "";
|
||||
DFASerializer serializer = new DFASerializer(this,tokenNames);
|
||||
return serializer.toString();
|
||||
}
|
||||
|
||||
public String toString(@NotNull Vocabulary vocabulary) {
|
||||
public String toString(Vocabulary vocabulary) {
|
||||
if (s0 == null) {
|
||||
return "";
|
||||
}
|
||||
|
|
|
@ -33,27 +33,26 @@ package org.antlr.v4.runtime.dfa;
|
|||
import org.antlr.v4.runtime.Vocabulary;
|
||||
import org.antlr.v4.runtime.VocabularyImpl;
|
||||
import org.antlr.v4.runtime.misc.NotNull;
|
||||
import org.antlr.v4.runtime.misc.Nullable;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/** A DFA walker that knows how to dump them to serialized strings. */
|
||||
public class DFASerializer {
|
||||
@NotNull
|
||||
|
||||
private final DFA dfa;
|
||||
@NotNull
|
||||
|
||||
private final Vocabulary vocabulary;
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #DFASerializer(DFA, Vocabulary)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public DFASerializer(@NotNull DFA dfa, @Nullable String[] tokenNames) {
|
||||
public DFASerializer(DFA dfa, String[] tokenNames) {
|
||||
this(dfa, VocabularyImpl.fromTokenNames(tokenNames));
|
||||
}
|
||||
|
||||
public DFASerializer(@NotNull DFA dfa, @NotNull Vocabulary vocabulary) {
|
||||
public DFASerializer(DFA dfa, Vocabulary vocabulary) {
|
||||
this.dfa = dfa;
|
||||
this.vocabulary = vocabulary;
|
||||
}
|
||||
|
@ -86,8 +85,8 @@ public class DFASerializer {
|
|||
return vocabulary.getDisplayName(i - 1);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
protected String getStateString(@NotNull DFAState s) {
|
||||
|
||||
protected String getStateString(DFAState s) {
|
||||
int n = s.stateNumber;
|
||||
final String baseStateStr = (s.isAcceptState ? ":" : "") + "s" + n + (s.requiresFullContext ? "^" : "");
|
||||
if ( s.isAcceptState ) {
|
||||
|
|
|
@ -72,13 +72,13 @@ import java.util.Set;
|
|||
public class DFAState {
|
||||
public int stateNumber = -1;
|
||||
|
||||
@NotNull
|
||||
|
||||
public ATNConfigSet configs = new ATNConfigSet();
|
||||
|
||||
/** {@code edges[symbol]} points to target of symbol. Shift up by 1 so (-1)
|
||||
* {@link Token#EOF} maps to {@code edges[0]}.
|
||||
*/
|
||||
@Nullable
|
||||
|
||||
public DFAState[] edges;
|
||||
|
||||
public boolean isAcceptState = false;
|
||||
|
@ -111,12 +111,12 @@ public class DFAState {
|
|||
*
|
||||
* <p>This list is computed by {@link ParserATNSimulator#predicateDFAState}.</p>
|
||||
*/
|
||||
@Nullable
|
||||
|
||||
public PredPrediction[] predicates;
|
||||
|
||||
/** Map a predicate to a predicted alternative. */
|
||||
public static class PredPrediction {
|
||||
@NotNull
|
||||
|
||||
public SemanticContext pred; // never null; at least SemanticContext.NONE
|
||||
public int alt;
|
||||
public PredPrediction(SemanticContext pred, int alt) {
|
||||
|
@ -133,7 +133,7 @@ public class DFAState {
|
|||
|
||||
public DFAState(int stateNumber) { this.stateNumber = stateNumber; }
|
||||
|
||||
public DFAState(@NotNull ATNConfigSet configs) { this.configs = configs; }
|
||||
public DFAState(ATNConfigSet configs) { this.configs = configs; }
|
||||
|
||||
/** Get the set of all alts mentioned by all ATN configurations in this
|
||||
* DFA state.
|
||||
|
|
|
@ -34,12 +34,12 @@ import org.antlr.v4.runtime.VocabularyImpl;
|
|||
import org.antlr.v4.runtime.misc.NotNull;
|
||||
|
||||
public class LexerDFASerializer extends DFASerializer {
|
||||
public LexerDFASerializer(@NotNull DFA dfa) {
|
||||
public LexerDFASerializer(DFA dfa) {
|
||||
super(dfa, VocabularyImpl.EMPTY_VOCABULARY);
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
|
||||
protected String getEdgeLabel(int i) {
|
||||
return "'"+(char)i+"'";
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ public class Array2DHashSet<T> implements Set<T> {
|
|||
public static final int INITAL_BUCKET_CAPACITY = 8;
|
||||
public static final double LOAD_FACTOR = 0.75;
|
||||
|
||||
@NotNull
|
||||
|
||||
protected final AbstractEqualityComparator<? super T> comparator;
|
||||
|
||||
protected T[][] buckets;
|
||||
|
@ -59,11 +59,11 @@ public class Array2DHashSet<T> implements Set<T> {
|
|||
this(null, INITAL_CAPACITY, INITAL_BUCKET_CAPACITY);
|
||||
}
|
||||
|
||||
public Array2DHashSet(@Nullable AbstractEqualityComparator<? super T> comparator) {
|
||||
public Array2DHashSet(AbstractEqualityComparator<? super T> comparator) {
|
||||
this(comparator, INITAL_CAPACITY, INITAL_BUCKET_CAPACITY);
|
||||
}
|
||||
|
||||
public Array2DHashSet(@Nullable AbstractEqualityComparator<? super T> comparator, int initialCapacity, int initialBucketCapacity) {
|
||||
public Array2DHashSet(AbstractEqualityComparator<? super T> comparator, int initialCapacity, int initialBucketCapacity) {
|
||||
if (comparator == null) {
|
||||
comparator = ObjectEqualityComparator.INSTANCE;
|
||||
}
|
||||
|
@ -226,7 +226,7 @@ public class Array2DHashSet<T> implements Set<T> {
|
|||
return containsFast(asElementType(o));
|
||||
}
|
||||
|
||||
public boolean containsFast(@Nullable T obj) {
|
||||
public boolean containsFast(T obj) {
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
|
@ -290,7 +290,7 @@ public class Array2DHashSet<T> implements Set<T> {
|
|||
return removeFast(asElementType(o));
|
||||
}
|
||||
|
||||
public boolean removeFast(@Nullable T obj) {
|
||||
public boolean removeFast(T obj) {
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -57,7 +57,7 @@ public class FlexibleHashMap<K,V> implements Map<K, V> {
|
|||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
protected final AbstractEqualityComparator<? super K> comparator;
|
||||
|
||||
protected LinkedList<Entry<K, V>>[] buckets;
|
||||
|
@ -74,11 +74,11 @@ public class FlexibleHashMap<K,V> implements Map<K, V> {
|
|||
this(null, INITAL_CAPACITY, INITAL_BUCKET_CAPACITY);
|
||||
}
|
||||
|
||||
public FlexibleHashMap(@Nullable AbstractEqualityComparator<? super K> comparator) {
|
||||
public FlexibleHashMap(AbstractEqualityComparator<? super K> comparator) {
|
||||
this(comparator, INITAL_CAPACITY, INITAL_BUCKET_CAPACITY);
|
||||
}
|
||||
|
||||
public FlexibleHashMap(@Nullable AbstractEqualityComparator<? super K> comparator, int initialCapacity, int initialBucketCapacity) {
|
||||
public FlexibleHashMap(AbstractEqualityComparator<? super K> comparator, int initialCapacity, int initialBucketCapacity) {
|
||||
if (comparator == null) {
|
||||
comparator = ObjectEqualityComparator.INSTANCE;
|
||||
}
|
||||
|
|
|
@ -59,8 +59,8 @@ public interface IntSet {
|
|||
*
|
||||
* @exception IllegalStateException if the current set is read-only
|
||||
*/
|
||||
@NotNull
|
||||
IntSet addAll(@Nullable IntSet set);
|
||||
|
||||
IntSet addAll(IntSet set);
|
||||
|
||||
/**
|
||||
* Return a new {@link IntSet} object containing all elements that are
|
||||
|
@ -72,8 +72,8 @@ public interface IntSet {
|
|||
* current set and {@code a}. The value {@code null} may be returned in
|
||||
* place of an empty result set.
|
||||
*/
|
||||
@Nullable
|
||||
IntSet and(@Nullable IntSet a);
|
||||
|
||||
IntSet and(IntSet a);
|
||||
|
||||
/**
|
||||
* Return a new {@link IntSet} object containing all elements that are
|
||||
|
@ -92,8 +92,8 @@ public interface IntSet {
|
|||
* {@code elements} but not present in the current set. The value
|
||||
* {@code null} may be returned in place of an empty result set.
|
||||
*/
|
||||
@Nullable
|
||||
IntSet complement(@Nullable IntSet elements);
|
||||
|
||||
IntSet complement(IntSet elements);
|
||||
|
||||
/**
|
||||
* Return a new {@link IntSet} object containing all elements that are
|
||||
|
@ -109,8 +109,8 @@ public interface IntSet {
|
|||
* set and {@code a}. The value {@code null} may be returned in place of an
|
||||
* empty result set.
|
||||
*/
|
||||
@Nullable
|
||||
IntSet or(@Nullable IntSet a);
|
||||
|
||||
IntSet or(IntSet a);
|
||||
|
||||
/**
|
||||
* Return a new {@link IntSet} object containing all elements that are
|
||||
|
@ -129,8 +129,8 @@ public interface IntSet {
|
|||
* {@code elements} but not present in the current set. The value
|
||||
* {@code null} may be returned in place of an empty result set.
|
||||
*/
|
||||
@Nullable
|
||||
IntSet subtract(@Nullable IntSet a);
|
||||
|
||||
IntSet subtract(IntSet a);
|
||||
|
||||
/**
|
||||
* Return the total number of elements represented by the current set.
|
||||
|
@ -188,7 +188,7 @@ public interface IntSet {
|
|||
* @return A list containing all element present in the current set, sorted
|
||||
* in ascending numerical order.
|
||||
*/
|
||||
@NotNull
|
||||
|
||||
List<Integer> toList();
|
||||
|
||||
/**
|
||||
|
|
|
@ -44,7 +44,7 @@ public class IntegerList {
|
|||
private static final int INITIAL_SIZE = 4;
|
||||
private static final int MAX_ARRAY_SIZE = Integer.MAX_VALUE - 8;
|
||||
|
||||
@NotNull
|
||||
|
||||
private int[] _data;
|
||||
|
||||
private int _size;
|
||||
|
@ -65,12 +65,12 @@ public class IntegerList {
|
|||
}
|
||||
}
|
||||
|
||||
public IntegerList(@NotNull IntegerList list) {
|
||||
public IntegerList(IntegerList list) {
|
||||
_data = list._data.clone();
|
||||
_size = list._size;
|
||||
}
|
||||
|
||||
public IntegerList(@NotNull Collection<Integer> list) {
|
||||
public IntegerList(Collection<Integer> list) {
|
||||
this(list.size());
|
||||
for (Integer value : list) {
|
||||
add(value);
|
||||
|
|
|
@ -42,7 +42,7 @@ public class IntegerStack extends IntegerList {
|
|||
super(capacity);
|
||||
}
|
||||
|
||||
public IntegerStack(@NotNull IntegerStack list) {
|
||||
public IntegerStack(IntegerStack list) {
|
||||
super(list);
|
||||
}
|
||||
|
||||
|
|
|
@ -89,7 +89,7 @@ public class IntervalSet implements IntSet {
|
|||
}
|
||||
|
||||
/** Create a set with a single element, el. */
|
||||
@NotNull
|
||||
|
||||
public static IntervalSet of(int a) {
|
||||
IntervalSet s = new IntervalSet();
|
||||
s.add(a);
|
||||
|
@ -249,8 +249,8 @@ public class IntervalSet implements IntSet {
|
|||
* operation is {@code left - right}. If either of the input sets is
|
||||
* {@code null}, it is treated as though it was an empty set.
|
||||
*/
|
||||
@NotNull
|
||||
public static IntervalSet subtract(@Nullable IntervalSet left, @Nullable IntervalSet right) {
|
||||
|
||||
public static IntervalSet subtract(IntervalSet left, IntervalSet right) {
|
||||
if (left == null || left.isNil()) {
|
||||
return new IntervalSet();
|
||||
}
|
||||
|
@ -554,7 +554,7 @@ public class IntervalSet implements IntSet {
|
|||
return toString(VocabularyImpl.fromTokenNames(tokenNames));
|
||||
}
|
||||
|
||||
public String toString(@NotNull Vocabulary vocabulary) {
|
||||
public String toString(Vocabulary vocabulary) {
|
||||
StringBuilder buf = new StringBuilder();
|
||||
if ( this.intervals==null || this.intervals.isEmpty() ) {
|
||||
return "{}";
|
||||
|
@ -594,8 +594,8 @@ public class IntervalSet implements IntSet {
|
|||
return elementName(VocabularyImpl.fromTokenNames(tokenNames), a);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
protected String elementName(@NotNull Vocabulary vocabulary, int a) {
|
||||
|
||||
protected String elementName(Vocabulary vocabulary, int a) {
|
||||
if (a == Token.EOF) {
|
||||
return "<EOF>";
|
||||
}
|
||||
|
|
|
@ -29,9 +29,7 @@
|
|||
*/
|
||||
package org.antlr.v4.runtime.misc;
|
||||
|
||||
import javax.swing.JFileChooser;
|
||||
import javax.swing.JOptionPane;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
|
|
|
@ -67,7 +67,7 @@ public class LogManager {
|
|||
|
||||
protected List<Record> records;
|
||||
|
||||
public void log(@Nullable String component, String msg) {
|
||||
public void log(String component, String msg) {
|
||||
Record r = new Record();
|
||||
r.component = component;
|
||||
r.msg = msg;
|
||||
|
|
|
@ -45,7 +45,6 @@ import javax.lang.model.type.PrimitiveType;
|
|||
import javax.lang.model.type.TypeKind;
|
||||
import javax.lang.model.type.TypeMirror;
|
||||
import javax.tools.Diagnostic;
|
||||
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Deque;
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
|
||||
package org.antlr.v4.runtime.misc;
|
||||
|
||||
import java.awt.Window;
|
||||
import java.awt.*;
|
||||
import java.awt.event.WindowAdapter;
|
||||
import java.awt.event.WindowEvent;
|
||||
import java.io.File;
|
||||
|
@ -96,11 +96,11 @@ public class Utils {
|
|||
return buf.toString();
|
||||
}
|
||||
|
||||
public static void writeFile(@NotNull String fileName, @NotNull String content) throws IOException {
|
||||
public static void writeFile(String fileName, String content) throws IOException {
|
||||
writeFile(fileName, content, null);
|
||||
}
|
||||
|
||||
public static void writeFile(@NotNull String fileName, @NotNull String content, @Nullable String encoding) throws IOException {
|
||||
public static void writeFile(String fileName, String content, String encoding) throws IOException {
|
||||
File f = new File(fileName);
|
||||
FileOutputStream fos = new FileOutputStream(f);
|
||||
OutputStreamWriter osw;
|
||||
|
@ -119,13 +119,13 @@ public class Utils {
|
|||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static char[] readFile(@NotNull String fileName) throws IOException {
|
||||
|
||||
public static char[] readFile(String fileName) throws IOException {
|
||||
return readFile(fileName, null);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static char[] readFile(@NotNull String fileName, @Nullable String encoding) throws IOException {
|
||||
|
||||
public static char[] readFile(String fileName, String encoding) throws IOException {
|
||||
File f = new File(fileName);
|
||||
int size = (int)f.length();
|
||||
InputStreamReader isr;
|
||||
|
|
|
@ -30,8 +30,6 @@
|
|||
|
||||
package org.antlr.v4.runtime.tree;
|
||||
|
||||
import org.antlr.v4.runtime.misc.NotNull;
|
||||
|
||||
public abstract class AbstractParseTreeVisitor<T> implements ParseTreeVisitor<T> {
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
|
@ -40,7 +38,7 @@ public abstract class AbstractParseTreeVisitor<T> implements ParseTreeVisitor<T>
|
|||
* specified tree.</p>
|
||||
*/
|
||||
@Override
|
||||
public T visit(@NotNull ParseTree tree) {
|
||||
public T visit(ParseTree tree) {
|
||||
return tree.accept(this);
|
||||
}
|
||||
|
||||
|
@ -60,7 +58,7 @@ public abstract class AbstractParseTreeVisitor<T> implements ParseTreeVisitor<T>
|
|||
* method to behave properly in respect to the specific algorithm in use.</p>
|
||||
*/
|
||||
@Override
|
||||
public T visitChildren(@NotNull RuleNode node) {
|
||||
public T visitChildren(RuleNode node) {
|
||||
T result = defaultResult();
|
||||
int n = node.getChildCount();
|
||||
for (int i=0; i<n; i++) {
|
||||
|
@ -83,7 +81,7 @@ public abstract class AbstractParseTreeVisitor<T> implements ParseTreeVisitor<T>
|
|||
* {@link #defaultResult defaultResult}.</p>
|
||||
*/
|
||||
@Override
|
||||
public T visitTerminal(@NotNull TerminalNode node) {
|
||||
public T visitTerminal(TerminalNode node) {
|
||||
return defaultResult();
|
||||
}
|
||||
|
||||
|
@ -94,7 +92,7 @@ public abstract class AbstractParseTreeVisitor<T> implements ParseTreeVisitor<T>
|
|||
* {@link #defaultResult defaultResult}.</p>
|
||||
*/
|
||||
@Override
|
||||
public T visitErrorNode(@NotNull ErrorNode node) {
|
||||
public T visitErrorNode(ErrorNode node) {
|
||||
return defaultResult();
|
||||
}
|
||||
|
||||
|
@ -160,7 +158,7 @@ public abstract class AbstractParseTreeVisitor<T> implements ParseTreeVisitor<T>
|
|||
* {@code false} to stop visiting children and immediately return the
|
||||
* current aggregate result from {@link #visitChildren}.
|
||||
*/
|
||||
protected boolean shouldVisitNextChild(@NotNull RuleNode node, T currentResult) {
|
||||
protected boolean shouldVisitNextChild(RuleNode node, T currentResult) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -31,11 +31,10 @@
|
|||
package org.antlr.v4.runtime.tree;
|
||||
|
||||
import org.antlr.v4.runtime.ParserRuleContext;
|
||||
import org.antlr.v4.runtime.misc.NotNull;
|
||||
|
||||
public interface ParseTreeListener {
|
||||
void visitTerminal(@NotNull TerminalNode node);
|
||||
void visitErrorNode(@NotNull ErrorNode node);
|
||||
void enterEveryRule(@NotNull ParserRuleContext ctx);
|
||||
void exitEveryRule(@NotNull ParserRuleContext ctx);
|
||||
void visitTerminal(TerminalNode node);
|
||||
void visitErrorNode(ErrorNode node);
|
||||
void enterEveryRule(ParserRuleContext ctx);
|
||||
void exitEveryRule(ParserRuleContext ctx);
|
||||
}
|
||||
|
|
|
@ -30,8 +30,6 @@
|
|||
|
||||
package org.antlr.v4.runtime.tree;
|
||||
|
||||
import org.antlr.v4.runtime.misc.NotNull;
|
||||
|
||||
/**
|
||||
* This interface defines the basic notion of a parse tree visitor. Generated
|
||||
* visitors implement this interface and the {@code XVisitor} interface for
|
||||
|
@ -48,7 +46,7 @@ public interface ParseTreeVisitor<T> {
|
|||
* @param tree The {@link ParseTree} to visit.
|
||||
* @return The result of visiting the parse tree.
|
||||
*/
|
||||
T visit(@NotNull ParseTree tree);
|
||||
T visit(ParseTree tree);
|
||||
|
||||
/**
|
||||
* Visit the children of a node, and return a user-defined result of the
|
||||
|
@ -57,7 +55,7 @@ public interface ParseTreeVisitor<T> {
|
|||
* @param node The {@link RuleNode} whose children should be visited.
|
||||
* @return The result of visiting the children of the node.
|
||||
*/
|
||||
T visitChildren(@NotNull RuleNode node);
|
||||
T visitChildren(RuleNode node);
|
||||
|
||||
/**
|
||||
* Visit a terminal node, and return a user-defined result of the operation.
|
||||
|
@ -65,7 +63,7 @@ public interface ParseTreeVisitor<T> {
|
|||
* @param node The {@link TerminalNode} to visit.
|
||||
* @return The result of visiting the node.
|
||||
*/
|
||||
T visitTerminal(@NotNull TerminalNode node);
|
||||
T visitTerminal(TerminalNode node);
|
||||
|
||||
/**
|
||||
* Visit an error node, and return a user-defined result of the operation.
|
||||
|
@ -73,6 +71,6 @@ public interface ParseTreeVisitor<T> {
|
|||
* @param node The {@link ErrorNode} to visit.
|
||||
* @return The result of visiting the node.
|
||||
*/
|
||||
T visitErrorNode(@NotNull ErrorNode node);
|
||||
T visitErrorNode(ErrorNode node);
|
||||
|
||||
}
|
||||
|
|
|
@ -47,6 +47,6 @@ public interface SyntaxTree extends Tree {
|
|||
*
|
||||
* <p>If source interval is unknown, this returns {@link Interval#INVALID}.</p>
|
||||
*/
|
||||
@NotNull
|
||||
|
||||
Interval getSourceInterval();
|
||||
}
|
||||
|
|
|
@ -34,8 +34,6 @@ import org.antlr.v4.runtime.Parser;
|
|||
import org.antlr.v4.runtime.Token;
|
||||
import org.antlr.v4.runtime.misc.Interval;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class TerminalNodeImpl implements TerminalNode {
|
||||
public Token symbol;
|
||||
public ParseTree parent;
|
||||
|
|
|
@ -33,9 +33,6 @@ package org.antlr.v4.runtime.tree;
|
|||
import org.antlr.v4.runtime.RuleContext;
|
||||
import org.antlr.v4.runtime.Token;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/** The basic notion of a tree has a parent, a payload, and a list of children.
|
||||
* It is the most abstract interface for all the trees used by ANTLR.
|
||||
*/
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue