Refine search
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;
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;}
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;
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); } }
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);
/** 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; }
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; }
/** 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; }
/** 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(); }
/** 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); } }
/** 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++; } }
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;}
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;
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); } }
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);
/** 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; }