public ParseTreeNode parse ( SourceCode sourceCode , String production ) throws ParserException { try { initialize ( sourceCode ) ; MemoEntry progress = applyRule ( production , 0 , 1 ) ; if ( progress . getDeltaPosition ( ) != text . length ( ) ) { throw new ParserException ( getParserErrorMessage ( ) ) ; } Object answer = progress . getAnswer ( ) ; if ( answer instanceof Status ) { Status status = ( Status ) answer ; switch ( status ) { case FAILED : throw new ParserException ( "Parser returned status 'FAILED'." ) ; default : throw new RuntimeException ( "A status '" + status . toString ( ) + "' is not expected here." ) ; } } ParseTreeNode parserTree = ( ParseTreeNode ) answer ; normalizeParents ( parserTree ) ; return parserTree ; } catch ( TreeException e ) { throw new ParserException ( e ) ; } }
This is the actual parser start . After running the parse a check is applied to check for full parsing or partial parsing . If partial parsing is found an exception is thrown .