本文整理了Java中org.antlr.runtime.IntStream
类的一些代码示例,展示了IntStream
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。IntStream
类的具体详情如下:
包路径:org.antlr.runtime.IntStream
类名称:IntStream
[英]A simple stream of integers used when all I care about is the char or token type sequence (such as interpretation).
[中]当我只关心字符或令牌类型序列(如解释)时使用的一个简单的整数流。
代码示例来源:origin: apache/hive
switch ( s ) {
case 0 :
int LA29_5 = input.LA(1);
int index29_5 = input.index();
input.rewind();
s = -1;
if ( ((allowQuotedId())) ) {s = 3;}
else if ( (true) ) {s = 6;}
input.seek(index29_5);
if ( s>=0 ) return s;
break;
int LA29_2 = input.LA(1);
s = -1;
if ( ((LA29_2 >= '\u0000' && LA29_2 <= ' ')||(LA29_2 >= '\"' && LA29_2 <= '#')||(LA29_2 >= '%' && LA29_2 <= '\'')||LA29_2==','||LA29_2=='/'||(LA29_2 >= ':' && LA29_2 <= '>')||LA29_2=='@'||LA29_2=='\\'||LA29_2=='`'||(LA29_2 >= '~' && LA29_2 <= '\uFFFF')) ) {s = 3;}
int LA29_4 = input.LA(1);
s = -1;
if ( (LA29_4=='`') ) {s = 5;}
new NoViableAltException(getDescription(), 29, _s, input);
error(nvae);
throw nvae;
代码示例来源:origin: apache/hive
switch ( s ) {
case 0 :
int LA34_192 = input.LA(1);
s = -1;
if ( ((LA34_192 >= '\u0000' && LA34_192 <= '\uFFFF')) ) {s = 431;}
int LA34_195 = input.LA(1);
s = -1;
if ( ((LA34_195 >= '\u0000' && LA34_195 <= '\uFFFF')) ) {s = 433;}
int LA34_191 = input.LA(1);
s = -1;
if ( (LA34_191=='\'') ) {s = 193;}
int LA34_431 = input.LA(1);
s = -1;
if ( (LA34_431=='\'') ) {s = 193;}
int LA34_194 = input.LA(1);
s = -1;
if ( (LA34_194=='\"') ) {s = 196;}
int LA34_433 = input.LA(1);
s = -1;
if ( (LA34_433=='\"') ) {s = 196;}
int LA34_51 = input.LA(1);
s = -1;
if ( ((LA34_51 >= '\u0000' && LA34_51 <= '&')||(LA34_51 >= '(' && LA34_51 <= '[')||(LA34_51 >= ']' && LA34_51 <= '\uFFFF')) ) {s = 191;}
代码示例来源:origin: antlr/antlr3
int t = input.LA(1);
while ( s!=stop ) {
if ( visitedStates!=null ) {
int m = input.mark();
int predictedAlt = predict(dfa);
if ( predictedAlt == NFA.INVALID_ALT_NUMBER ) {
String description = dfa.getNFADecisionStartState().getDescription();
NoViableAltException nvae =
new NoViableAltException(description,
dfa.getDecisionNumber(),
s.stateNumber,
input.consume(); // recover
throw nvae;
input.rewind(m);
int parseAlt =
s.translateDisplayAltToWalkAlt(predictedAlt);
input.consume();
t = input.LA(1);
input.consume(); // recover
throw mte;
input.consume(); // recover
throw mse;
代码示例来源:origin: com.impetus.fabric/fabric-jdbc-driver-shaded
public RecognitionException(IntStream input) {
this.input = input;
this.index = input.index();
if ( input instanceof TokenStream ) {
this.token = ((TokenStream)input).LT(1);
this.line = token.getLine();
this.charPositionInLine = token.getCharPositionInLine();
}
if ( input instanceof TreeNodeStream ) {
extractInformationFromTreeNodeStream(input);
}
else if ( input instanceof CharStream ) {
this.c = input.LA(1);
this.line = ((CharStream)input).getLine();
this.charPositionInLine = ((CharStream)input).getCharPositionInLine();
}
else {
this.c = input.LA(1);
}
}
代码示例来源:origin: io.virtdata/virtdata-lib-realer
public Object getInputSymbol(int k) {
if ( input instanceof TokenStream ) {
return ((TokenStream)input).LT(k);
}
return (char) input.LA(k);
}
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.antlr-runtime
int mark = input.mark(); // remember where decision started in input
int s = 0; // we always start at s0
try {
while ( true ) {
if ( debug ) System.err.println("DFA "+decisionNumber+" state "+s+" LA(1)="+(char)input.LA(1)+"("+input.LA(1)+
"), index="+input.index());
int specialState = special[s];
input.consume();
continue;
char c = (char)input.LA(1); // -1 == \uFFFF, all tokens fit in 65000 space
if (c>=min[s] && c<=max[s]) {
int snext = transition[s][c-min[s]]; // move to next state
if ( debug ) System.err.println("EOT transition");
s = eot[s];
input.consume();
input.consume();
continue;
if ( debug ) System.err.println("EOT transition");
s = eot[s];
input.consume();
continue;
input.rewind(mark);
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.antlr-runtime
public void consumeUntil(IntStream input, int tokenType) {
//System.out.println("consumeUntil "+tokenType);
int ttype = input.LA(1);
while (ttype != Token.EOF && ttype != tokenType) {
input.consume();
ttype = input.LA(1);
}
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-analytics
/** Match current input symbol against ttype. Attempt
* single token insertion or deletion error recovery. If
* that fails, throw MismatchedTokenException.
*
* To turn off single token insertion or deletion error
* recovery, override recoverFromMismatchedToken() and have it
* throw an exception. See TreeParser.recoverFromMismatchedToken().
* This way any error in a rule will cause an exception and
* immediate exit from rule. Rule would recover by resynchronizing
* to the set of symbols that can follow rule ref.
*/
public Object match(IntStream input, int ttype, BitSet follow)
throws RecognitionException
{
//System.out.println("match "+((TokenStream)input).LT(1));
Object matchedSymbol = getCurrentInputSymbol(input);
if ( input.LA(1)==ttype ) {
input.consume();
state.errorRecovery = false;
state.failed = false;
return matchedSymbol;
}
if ( state.backtracking>0 ) {
state.failed = true;
return matchedSymbol;
}
matchedSymbol = recoverFromMismatchedToken(input, ttype, follow);
return matchedSymbol;
}
代码示例来源:origin: antlr/antlr3
public boolean mismatchIsMissingToken(IntStream input, BitSet follow) {
if ( follow==null ) {
// we have no information about the follow; we can only consume
// a single token and hope for the best
return false;
}
// compute what can follow this grammar element reference
if ( follow.member(Token.EOR_TOKEN_TYPE) ) {
BitSet viableTokensFollowingThisRule = computeContextSensitiveRuleFOLLOW();
follow = follow.or(viableTokensFollowingThisRule);
if ( state._fsp>=0 ) { // remove EOR if we're not the start symbol
follow.remove(Token.EOR_TOKEN_TYPE);
}
}
// if current token is consistent with what could come after set
// then we know we're missing a token; error recovery is free to
// "insert" the missing token
//System.out.println("viable tokens="+follow.toString(getTokenNames()));
//System.out.println("LT(1)="+((TokenStream)input).LT(1));
// BitSet cannot handle negative numbers like -1 (EOF) so I leave EOR
// in follow set to indicate that the fall of the start symbol is
// in the set (EOF can follow).
if ( follow.member(input.LA(1)) || follow.member(Token.EOR_TOKEN_TYPE) ) {
//System.out.println("LT(1)=="+((TokenStream)input).LT(1)+" is consistent with what follows; inserting...");
return true;
}
return false;
}
代码示例来源:origin: antlr/antlr3
/** Has this rule already parsed input at the current index in the
* input stream? Return the stop token index or MEMO_RULE_UNKNOWN.
* If we attempted but failed to parse properly before, return
* MEMO_RULE_FAILED.
*
* This method has a side-effect: if we have seen this input for
* this rule and successfully parsed before, then seek ahead to
* 1 past the stop token matched for this rule last time.
*/
public boolean alreadyParsedRule(IntStream input, int ruleIndex) {
int stopIndex = getRuleMemoization(ruleIndex, input.index());
if ( stopIndex==MEMO_RULE_UNKNOWN ) {
return false;
}
if ( stopIndex==MEMO_RULE_FAILED ) {
//System.out.println("rule "+ruleIndex+" will never succeed");
state.failed=true;
}
else {
//System.out.println("seen rule "+ruleIndex+" before; skipping ahead to @"+(stopIndex+1)+" failed="+state.failed);
input.seek(stopIndex+1); // jump to one past stop token
}
return true;
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-analytics
/** Recover from an error found on the input stream. This is
* for NoViableAlt and mismatched symbol exceptions. If you enable
* single token insertion and deletion, this will usually not
* handle mismatched symbol exceptions but there could be a mismatched
* token that the match() routine could not recover from.
*/
public void recover(IntStream input, RecognitionException re) {
if ( state.lastErrorIndex==input.index() ) {
// uh oh, another error at same token index; must be a case
// where LT(1) is in the recovery token set so nothing is
// consumed; consume a single token so at least to prevent
// an infinite loop; this is a failsafe.
input.consume();
}
state.lastErrorIndex = input.index();
BitSet followSet = computeErrorRecoverySet();
beginResync();
consumeUntil(input, followSet);
endResync();
}
代码示例来源:origin: antlr/antlr3
/** Record whether or not this rule parsed the input at this position
* successfully. Use a standard java hashtable for now.
*/
public void memoize(IntStream input,
int ruleIndex,
int ruleStartIndex)
{
int stopTokenIndex = state.failed?MEMO_RULE_FAILED:input.index()-1;
if ( state.ruleMemo==null ) {
System.err.println("!!!!!!!!! memo array is null for "+ getGrammarFileName());
}
if ( ruleIndex >= state.ruleMemo.length ) {
System.err.println("!!!!!!!!! memo size is "+state.ruleMemo.length+", but rule index is "+ruleIndex);
}
if ( state.ruleMemo[ruleIndex]!=null ) {
state.ruleMemo[ruleIndex].put(ruleStartIndex, stopTokenIndex);
}
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-analytics
/** Track memoization; this is not part of standard debug interface
* but is triggered by profiling. Code gen inserts an override
* for this method in the recognizer, which triggers this method.
* Called from alreadyParsedRule().
*/
public void examineRuleMemoization(IntStream input,
int ruleIndex,
int stopIndex, // index or MEMO_RULE_UNKNOWN...
String ruleName)
{
if (dump) System.out.println("examine memo "+ruleName+" at "+input.index()+": "+stopIndex);
if ( stopIndex==BaseRecognizer.MEMO_RULE_UNKNOWN ) {
//System.out.println("rule "+ruleIndex+" missed @ "+input.index());
stats.numMemoizationCacheMisses++;
stats.numGuessingRuleInvocations++; // we'll have to enter
currentDecision().numMemoizationCacheMisses++;
}
else {
// regardless of rule success/failure, if in cache, we have a cache hit
//System.out.println("rule "+ruleIndex+" hit @ "+input.index());
stats.numMemoizationCacheHits++;
currentDecision().numMemoizationCacheHits++;
}
}
代码示例来源:origin: apache/drill
switch ( s ) {
case 0 :
int LA33_183 = input.LA(1);
s = -1;
if ( (LA33_183=='\'') ) {s = 185;}
int LA33_401 = input.LA(1);
s = -1;
if ( (LA33_401=='\'') ) {s = 185;}
int LA33_186 = input.LA(1);
s = -1;
if ( (LA33_186=='\"') ) {s = 188;}
int LA33_403 = input.LA(1);
s = -1;
if ( (LA33_403=='\"') ) {s = 188;}
int LA33_184 = input.LA(1);
s = -1;
if ( ((LA33_184 >= '\u0000' && LA33_184 <= '\uFFFF')) ) {s = 401;}
int LA33_187 = input.LA(1);
s = -1;
if ( ((LA33_187 >= '\u0000' && LA33_187 <= '\uFFFF')) ) {s = 403;}
int LA33_50 = input.LA(1);
s = -1;
if ( ((LA33_50 >= '\u0000' && LA33_50 <= '&')||(LA33_50 >= '(' && LA33_50 <= '[')||(LA33_50 >= ']' && LA33_50 <= '\uFFFF')) ) {s = 183;}
代码示例来源:origin: org.xtext/antlr-generator
int t = input.LA(1);
while ( s!=stop ) {
if ( visitedStates!=null ) {
int m = input.mark();
int predictedAlt = predict(dfa);
if ( predictedAlt == NFA.INVALID_ALT_NUMBER ) {
String description = dfa.getNFADecisionStartState().getDescription();
NoViableAltException nvae =
new NoViableAltException(description,
dfa.getDecisionNumber(),
s.stateNumber,
input.consume(); // recover
throw nvae;
input.rewind(m);
int parseAlt =
s.translateDisplayAltToWalkAlt(predictedAlt);
input.consume();
t = input.LA(1);
input.consume(); // recover
throw mte;
input.consume(); // recover
throw mse;
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-analytics
public RecognitionException(IntStream input) {
this.input = input;
this.index = input.index();
if ( input instanceof TokenStream ) {
this.token = ((TokenStream)input).LT(1);
this.line = token.getLine();
this.charPositionInLine = token.getCharPositionInLine();
}
if ( input instanceof TreeNodeStream ) {
extractInformationFromTreeNodeStream(input);
}
else if ( input instanceof CharStream ) {
this.c = input.LA(1);
this.line = ((CharStream)input).getLine();
this.charPositionInLine = ((CharStream)input).getCharPositionInLine();
}
else {
this.c = input.LA(1);
}
}
代码示例来源:origin: com.impetus.fabric/fabric-jdbc-driver-shaded
public Object getInputSymbol(int k) {
if ( input instanceof TokenStream ) {
return ((TokenStream)input).LT(k);
}
return (char) input.LA(k);
}
}
代码示例来源:origin: antlr/antlr3
int mark = input.mark(); // remember where decision started in input
int s = 0; // we always start at s0
try {
while ( true ) {
if ( debug ) System.err.println("DFA "+decisionNumber+" state "+s+" LA(1)="+(char)input.LA(1)+"("+input.LA(1)+
"), index="+input.index());
int specialState = special[s];
input.consume();
continue;
char c = (char)input.LA(1); // -1 == \uFFFF, all tokens fit in 65000 space
if (c>=min[s] && c<=max[s]) {
int snext = transition[s][c-min[s]]; // move to next state
if ( debug ) System.err.println("EOT transition");
s = eot[s];
input.consume();
input.consume();
continue;
if ( debug ) System.err.println("EOT transition");
s = eot[s];
input.consume();
continue;
input.rewind(mark);
代码示例来源:origin: io.virtdata/virtdata-lib-realer
public void consumeUntil(IntStream input, int tokenType) {
//System.out.println("consumeUntil "+tokenType);
int ttype = input.LA(1);
while (ttype != Token.EOF && ttype != tokenType) {
input.consume();
ttype = input.LA(1);
}
}
代码示例来源:origin: com.impetus.fabric/fabric-jdbc-driver-shaded
/** Match current input symbol against ttype. Attempt
* single token insertion or deletion error recovery. If
* that fails, throw MismatchedTokenException.
*
* To turn off single token insertion or deletion error
* recovery, override recoverFromMismatchedToken() and have it
* throw an exception. See TreeParser.recoverFromMismatchedToken().
* This way any error in a rule will cause an exception and
* immediate exit from rule. Rule would recover by resynchronizing
* to the set of symbols that can follow rule ref.
*/
public Object match(IntStream input, int ttype, BitSet follow)
throws RecognitionException
{
//System.out.println("match "+((TokenStream)input).LT(1));
Object matchedSymbol = getCurrentInputSymbol(input);
if ( input.LA(1)==ttype ) {
input.consume();
state.errorRecovery = false;
state.failed = false;
return matchedSymbol;
}
if ( state.backtracking>0 ) {
state.failed = true;
return matchedSymbol;
}
matchedSymbol = recoverFromMismatchedToken(input, ttype, follow);
return matchedSymbol;
}
内容来源于网络,如有侵权,请联系作者删除!