Parser(a, None)

    Throws an exception if any tokens are left in the input unparsed.
8918
def finished(tokens, s):
    
    if s.pos >= len(tokens):
        return None, s
    else:
        raise NoParseError(u'should have reached <EOF>', s)
186187
public final void literal() throws RecognitionException {
		int literal_StartIndex = input.index();

		try {
			if ( state.backtracking>0 && alreadyParsedRule(input, 61) ) { return; }

			// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:587:5: ( integerLiteral | FloatingPointLiteral | CharacterLiteral | StringLiteral | booleanLiteral | 'null' )
			int alt84=6;
			switch ( input.LA(1) ) {
			case DecimalLiteral:
			case HexLiteral:
			case OctalLiteral:
				{
				alt84=1;
				}
				break;
			case FloatingPointLiteral:
				{
				alt84=2;
				}
				break;
			case CharacterLiteral:
				{
				alt84=3;
				}
				break;
			case StringLiteral:
				{
				alt84=4;
				}
				break;
			case 82:
			case 115:
				{
				alt84=5;
				}
				break;
			case 98:
				{
				alt84=6;
				}
				break;
			default:
				if (state.backtracking>0) {state.failed=true; return;}
				NoViableAltException nvae =
					new NoViableAltException("", 84, 0, input);
				throw nvae;
			}
			switch (alt84) {
				case 1 :
					// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:587:9: integerLiteral
					{
					pushFollow(FOLLOW_integerLiteral_in_literal2150);
					integerLiteral();
					state._fsp--;
					if (state.failed) return;
					}
					break;
				case 2 :
					// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:588:9: FloatingPointLiteral
					{
					match(input,FloatingPointLiteral,FOLLOW_FloatingPointLiteral_in_literal2160); if (state.failed) return;
					}
					break;
				case 3 :
					// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:589:9: CharacterLiteral
					{
					match(input,CharacterLiteral,FOLLOW_CharacterLiteral_in_literal2170); if (state.failed) return;
					}
					break;
				case 4 :
					// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:590:9: StringLiteral
					{
					match(input,StringLiteral,FOLLOW_StringLiteral_in_literal2180); if (state.failed) return;
					}
					break;
				case 5 :
					// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:591:9: booleanLiteral
					{
					pushFollow(FOLLOW_booleanLiteral_in_literal2190);
					booleanLiteral();
					state._fsp--;
					if (state.failed) return;
					}
					break;
				case 6 :
					// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:592:9: 'null'
					{
					match(input,98,FOLLOW_98_in_literal2200); if (state.failed) return;
					}
					break;

			}
		}
		catch (RecognitionException re) {
			reportError(re);
			recover(input,re);
		}
		finally {
			// do for sure before leaving
			if ( state.backtracking>0 ) { memoize(input, 61, literal_StartIndex); }

		}
	}
1198040
public final void mLEFTPAREN() throws RecognitionException {
        try {
            int _type = LEFTPAREN;
            int _channel = DEFAULT_TOKEN_CHANNEL;
            // com/dyuproject/protostuff/parser/ProtoLexer.g:51:5: ( '(' )
            // com/dyuproject/protostuff/parser/ProtoLexer.g:51:9: '('
            {
            match('('); 

            }

            state.type = _type;
            state.channel = _channel;
        }
        finally {
        }
    }
949063
public void assertToken(final String token, final boolean ignoreCase) throws ParseException {
    // ensure next token is a word token..
    assertWord();

    if (ignoreCase) {
      if (!token.equalsIgnoreCase(sval)) {
        throw new ParseException("Expected [" + token + "], read [" +
                                  sval + "] at " + lineno());
      }
    } else if (!token.equals(sval)) {
      throw new ParseException( "Expected [" + token + "], read [" +
                                sval + "] at " + lineno());
    }

    if (debug()) {
      debug("[" + token + "]");
    }
  }
412640
private final void error() throws ParserException {
	Integer currentState = stateStack.peek();
	parserErrors.addError(currentState);
	if (backtrackEnabled && !backtrackStack.isEmpty()) {
	    trackBack();
	    return;
	}
	if (!backtrackEnabled) {
	    logger.trace("No valid action available and back tracking is disabled. Aborting near '"
		    + getTokenStream().getCodeSample(maxPosition) + "'...");
	} else {
	    logger.trace("No valid action available and back tracking stack is empty. Aborting near '"
		    + getTokenStream().getCodeSample(maxPosition) + "'...");
	}
	throw new ParserException(
		"Error! Could not parse the token stream near '" + getTokenStream().getCodeSample(maxPosition) + "'!");
    }
973104
def check_input(self, token):
        
        if token is None:
            raise Exception(self.full_name + ": No token provided!")
        if isinstance(token.payload, str):
            return
        raise Exception(self.full_name + ": Unhandled class: " + classes.get_classname(token.payload))
1198380
def _parse_tokens(tokens):
    

    index = 0
    parsed_tokens = []

    num_tokens = len(tokens)
    while index < num_tokens:
        tok = Token(*tokens[index])

        assert tok.token_type != token.INDENT
        if tok.token_type == tokenize.NEWLINE:
            # There's only one newline and it's at the end.
            break

        if tok.token_string in '([{':
            (container, index) = _parse_container(tokens, index)
            if not container:
                return None
            parsed_tokens.append(container)
        else:
            parsed_tokens.append(Atom(tok))

        index += 1

    return parsed_tokens
1023994
def _parse(self):
        
        try:
            # parse token stream into abstract syntax tree (AST)
            self._ast = self._rule_container()

        except ParseError:
            raise

        except Exception as exc:
            raise ParseError(u'Unexpected error: {0}'.format(unicode(exc)))
7427
Token parseTerm() throws ParseException {
		int ch = this.read();
		Token tok = null;
		if (ch == T_OR || ch == T_RPAREN || ch == T_EOF) {
			tok = Token.createEmpty();
		} else {
			tok = this.parseFactor();
			Token concat = null;
			while ((ch = this.read()) != T_OR && ch != T_RPAREN && ch != T_EOF) {
				if (concat == null) {
					concat = Token.createConcat();
					concat.addChild(tok);
					tok = concat;
				}
				concat.addChild(this.parseFactor());
				// tok = Token.createConcat(tok, this.parseFactor());
			}
		}
		if (ch == T_RPAREN) {
			parenCount--;
		}
		return tok;
	}
337462
function processNonSpecifier() {
                    const secondToken = sourceCode.getFirstToken(node, 1)
                    if (isLeftBrace(secondToken)) {
                        setOffsetToToken(
                            [
                                secondToken,
                                sourceCode.getTokenAfter(secondToken),
                            ],
                            0,
                            importToken
                        )
                        tokens.push(
                            sourceCode.getLastToken(node, hasSemi ? 2 : 1), // from
                            sourceCode.getLastToken(node, hasSemi ? 1 : 0) // "foo"
                        )
                    } else {
                        tokens.push(
                            sourceCode.getLastToken(node, hasSemi ? 1 : 0)
                        )
                    }
                }
479105
private void parse(TokenStream tokenStream) throws ParserException {
	try {
	    Parser parser = new SLR1Parser(uhuraGrammar);
	    parserTree = parser.parse(tokenStream);
	} catch (GrammarException e) {
	    logger.error(e.getMessage(), e);
	    throw new RuntimeException("UhuraGrammar is broken!!!");
	}
    }
477948
def check_input(self, token):
        
        if isinstance(token.payload, Instance):
            return
        raise Exception(self.full_name + ": Unhandled data type: " + str(token.payload.__class__.__name__))
1263644
function ( tokenizer, expected ) {
	var remaining = tokenizer.remaining().substr( 0, 40 );
	if ( remaining.length === 40 ) {
		remaining += '...';
	}
	throw new Error( 'Tokenizer failed: unexpected string "' + remaining + '" (expected ' + expected + ')' );
}
150053
private void checkToken(String token) {
        for (int i = 0; i < token.length(); i++) {
            char ch = token.charAt(i);
            if (!TOKEN.get(ch)) {
                throw new IllegalArgumentException("Invalid token character '" + ch + "' in token \"" + token + "\"");
            }
        }
    }
685322
def handle_unset_evidence(self, line: str, position: int, tokens: ParseResults) -> ParseResults:
        
        if self.evidence is None:
            raise MissingAnnotationKeyWarning(self.get_line_number(), line, position, tokens[EVIDENCE])
        self.evidence = None
        return tokens
1019751
private void parseToken(String token) {
        int len = token.length();

        for (int i = 0; i < len; i++) {
            int chr = sr.read();
            if (chr == -1) {
                throw new IllegalArgumentException("EOF reached while reading token: " + token);
            }
            chr = Character.toLowerCase((char)chr);
            int loTokenChar = token.charAt(i);

            if (loTokenChar != chr) {
                throw new IllegalArgumentException("Expected token: " + token + " at position " + sr.getPosition());
            }
        }
    }
204919
public final void mJavaLetter() throws RecognitionException {
		try {
			// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:1379:2: ( ( 'a' .. 'z' | 'A' .. 'Z' | '$' | '_' ) |{...}?~ ( '\\u0000' .. '\\u007F' | '\\uD800' .. '\\uDBFF' ) |{...}? ( '\\uD800' .. '\\uDBFF' ) ( '\\uDC00' .. '\\uDFFF' ) )
			int alt27=3;
			int LA27_0 = input.LA(1);
			if ( (LA27_0=='$'||(LA27_0 >= 'A' && LA27_0 <= 'Z')||LA27_0=='_'||(LA27_0 >= 'a' && LA27_0 <= 'z')) ) {
				alt27=1;
			}
			else if ( ((LA27_0 >= '\u0080' && LA27_0 <= '\uD7FF')||(LA27_0 >= '\uDC00' && LA27_0 <= '\uFFFF')) ) {
				alt27=2;
			}
			else if ( ((LA27_0 >= '\uD800' && LA27_0 <= '\uDBFF')) ) {
				alt27=3;
			}

			else {
				NoViableAltException nvae =
					new NoViableAltException("", 27, 0, input);
				throw nvae;
			}

			switch (alt27) {
				case 1 :
					// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:1379:4: ( 'a' .. 'z' | 'A' .. 'Z' | '$' | '_' )
					{
					if ( input.LA(1)=='$'||(input.LA(1) >= 'A' && input.LA(1) <= 'Z')||input.LA(1)=='_'||(input.LA(1) >= 'a' && input.LA(1) <= 'z') ) {
						input.consume();
					}
					else {
						MismatchedSetException mse = new MismatchedSetException(null,input);
						recover(mse);
						throw mse;
					}
					}
					break;
				case 2 :
					// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:1380:6: {...}?~ ( '\\u0000' .. '\\u007F' | '\\uD800' .. '\\uDBFF' )
					{
					if ( !((Character.isJavaIdentifierStart(input.LA(1)))) ) {
						throw new FailedPredicateException(input, "JavaLetter", "Character.isJavaIdentifierStart(input.LA(1))");
					}
					if ( (input.LA(1) >= '\u0080' && input.LA(1) <= '\uD7FF')||(input.LA(1) >= '\uDC00' && input.LA(1) <= '\uFFFF') ) {
						input.consume();
					}
					else {
						MismatchedSetException mse = new MismatchedSetException(null,input);
						recover(mse);
						throw mse;
					}
					}
					break;
				case 3 :
					// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:1382:9: {...}? ( '\\uD800' .. '\\uDBFF' ) ( '\\uDC00' .. '\\uDFFF' )
					{
					if ( !((Character.isJavaIdentifierStart(Character.toCodePoint((char)input.LA(-1), (char)input.LA(1))))) ) {
						throw new FailedPredicateException(input, "JavaLetter", "Character.isJavaIdentifierStart(Character.toCodePoint((char)input.LA(-1), (char)input.LA(1)))");
					}
					if ( (input.LA(1) >= '\uD800' && input.LA(1) <= '\uDBFF') ) {
						input.consume();
					}
					else {
						MismatchedSetException mse = new MismatchedSetException(null,input);
						recover(mse);
						throw mse;
					}
					if ( (input.LA(1) >= '\uDC00' && input.LA(1) <= '\uDFFF') ) {
						input.consume();
					}
					else {
						MismatchedSetException mse = new MismatchedSetException(null,input);
						recover(mse);
						throw mse;
					}
					}
					break;

			}
		}
		finally {
			// do for sure before leaving
		}
	}