Java 类org.antlr.v4.runtime.misc.IntegerList 实例源码
项目:goworks
文件:AbstractForestParser.java
@Override
public Map<RuleContext, CaretReachedException> getParseTrees(TParser parser) {
List<MultipleDecisionData> potentialAlternatives = new ArrayList<>();
IntegerList currentPath = new IntegerList();
Map<RuleContext, CaretReachedException> results = new IdentityHashMap<>();
// make sure the token stream is initialized before getting the index
parser.getInputStream().LA(1);
int initialToken = parser.getInputStream().index();
while (true) {
parser.getInputStream().seek(initialToken);
tryParse(parser, potentialAlternatives, currentPath, results);
if (!incrementCurrentPath(potentialAlternatives, currentPath)) {
break;
}
}
LOGGER.log(Level.FINE, "Forest parser constructed {0} parse trees.", results.size());
if (LOGGER.isLoggable(Level.FINEST)) {
for (Map.Entry<RuleContext, CaretReachedException> entry : results.entrySet()) {
LOGGER.log(Level.FINEST, entry.getKey().toStringTree(parser instanceof Parser ? (Parser)parser : null));
}
}
return results;
}
项目:antlrworks2
文件:AbstractForestParser.java
@Override
public Map<RuleContext, CaretReachedException> getParseTrees(TParser parser) {
List<MultipleDecisionData> potentialAlternatives = new ArrayList<>();
IntegerList currentPath = new IntegerList();
Map<RuleContext, CaretReachedException> results = new IdentityHashMap<>();
// make sure the token stream is initialized before getting the index
parser.getInputStream().LA(1);
int initialToken = parser.getInputStream().index();
while (true) {
parser.getInputStream().seek(initialToken);
tryParse(parser, potentialAlternatives, currentPath, results);
if (!incrementCurrentPath(potentialAlternatives, currentPath)) {
break;
}
}
LOGGER.log(Level.FINE, "Forest parser constructed {0} parse trees.", results.size());
if (LOGGER.isLoggable(Level.FINEST)) {
for (Map.Entry<RuleContext, CaretReachedException> entry : results.entrySet()) {
LOGGER.log(Level.FINEST, entry.getKey().toStringTree(parser instanceof Parser ? (Parser)parser : null));
}
}
return results;
}
项目:codebuff
文件:SerializedATN.java
public SerializedATN(OutputModelFactory factory, ATN atn) {
super(factory);
IntegerList data = ATNSerializer.getSerialized(atn);
serialized = new ArrayList<String>(data.size());
for (int c : data.toArray()) {
String encoded = factory.getGenerator().getTarget().encodeIntAsCharEscape(c == -1 ? Character.MAX_VALUE : c);
serialized.add(encoded);
}
// System.out.println(ATNSerializer.getDecoded(factory.getGrammar(), atn));
}
项目:goworks
文件:TreeCorrectionParserATNSimulator.java
@Override
protected DFAState addDFAEdge(DFA dfa, DFAState fromState, int t, IntegerList contextTransitions, ATNConfigSet toConfigs, PredictionContextCache contextCache) {
if (!getSuppressedSet(startIndex).isNil()) {
DFAState to = addDFAState(dfa, toConfigs, contextCache);
return to;
}
return super.addDFAEdge(dfa, fromState, t, contextTransitions, toConfigs, contextCache);
}
项目:goworks
文件:AbstractForestParser.java
protected boolean incrementCurrentPath(List<MultipleDecisionData> potentialAlternatives, IntegerList currentPath) {
for (int i = currentPath.size() - 1; i >= 0; i--) {
if (currentPath.get(i) < potentialAlternatives.get(i).alternatives.length - 1) {
currentPath.set(i, currentPath.get(i) + 1);
return true;
}
potentialAlternatives.remove(i);
currentPath.removeAt(i);
}
return false;
}
项目:goworks
文件:AbstractCompletionParserATNSimulator.java
public void setFixedDecisions(List<MultipleDecisionData> decisionPoints, IntegerList selections) {
Parameters.notNull("decisionPoints", decisionPoints);
Parameters.notNull("selections", selections);
this.decisionPoints = decisionPoints;
this.selections = selections;
this.caretTransitions = null;
if (decisionPoints != null && !decisionPoints.isEmpty()) {
_firstDecisionIndex = decisionPoints.get(0).inputIndex;
} else {
_firstDecisionIndex = Integer.MAX_VALUE;
}
}
项目:antlrworks2
文件:AbstractForestParser.java
protected boolean incrementCurrentPath(List<MultipleDecisionData> potentialAlternatives, IntegerList currentPath) {
for (int i = currentPath.size() - 1; i >= 0; i--) {
if (currentPath.get(i) < potentialAlternatives.get(i).alternatives.length - 1) {
currentPath.set(i, currentPath.get(i) + 1);
return true;
}
potentialAlternatives.remove(i);
currentPath.removeAt(i);
}
return false;
}
项目:antlrworks2
文件:AbstractCompletionParserATNSimulator.java
public void setFixedDecisions(List<MultipleDecisionData> decisionPoints, IntegerList selections) {
Parameters.notNull("decisionPoints", decisionPoints);
Parameters.notNull("selections", selections);
this.decisionPoints = decisionPoints;
this.selections = selections;
this.caretTransitions = null;
if (decisionPoints != null && !decisionPoints.isEmpty()) {
_firstDecisionIndex = decisionPoints.get(0).inputIndex;
} else {
_firstDecisionIndex = Integer.MAX_VALUE;
}
}
项目:stpnb
文件:SilverstripeLexer.java
public SilverstripeLexerState(int mode, IntegerList modeStack) {
this.mode = mode;
this.modeStack = new IntegerList();
this.modeStack.addAll(modeStack);
}
项目:goworks
文件:LineTextCache.java
public @NonNull IntegerList getBlockOffsets() {
return _blockOffsets;
}
项目:goworks
文件:LineTextCache.java
public @NonNull IntegerList getBlockLineOffsets() {
return _blockLineOffsets;
}
项目:goworks
文件:LineTextCache.java
public @NonNull ArrayList<IntegerList> getLineOffsets() {
return _lineOffsets;
}
项目:Scratch-ApuC
文件:ATNSerializer.java
public static IntegerList getSerialized(ATN atn) {
return new ATNSerializer(atn).serialize();
}
项目:Scratch-ApuC
文件:ATNSerializer.java
public static String getDecoded(ATN atn, List<String> tokenNames) {
IntegerList serialized = getSerialized(atn);
char[] data = Utils.toCharArray(serialized);
return new ATNSerializer(atn, tokenNames).decode(data);
}
项目:Scratch-ApuC
文件:ATNSerializer.java
private void serializeUUID(IntegerList data, UUID uuid) {
serializeLong(data, uuid.getLeastSignificantBits());
serializeLong(data, uuid.getMostSignificantBits());
}
项目:Scratch-ApuC
文件:ATNSerializer.java
private void serializeLong(IntegerList data, long value) {
serializeInt(data, (int)value);
serializeInt(data, (int)(value >> 32));
}
项目:Scratch-ApuC
文件:ATNSerializer.java
private void serializeInt(IntegerList data, int value) {
data.add((char)value);
data.add((char)(value >> 16));
}
项目:antlrworks2
文件:LineTextCache.java
public @NonNull IntegerList getBlockOffsets() {
return _blockOffsets;
}
项目:antlrworks2
文件:LineTextCache.java
public @NonNull IntegerList getBlockLineOffsets() {
return _blockLineOffsets;
}
项目:antlrworks2
文件:LineTextCache.java
public @NonNull ArrayList<IntegerList> getLineOffsets() {
return _lineOffsets;
}