/** 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; }
/** 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; }
/** 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; }
/** 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; }
/** 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; }
/** 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; }