public Expression next ( int precedence ) throws ParseException { ParserToken token ; Expression result ; do { token = tokenStream . consume ( ) ; if ( token == null ) { return null ; } result = grammar . parse ( this , token ) ; } while ( result == null ) ; //Consume things that will be skipped while ( grammar . skip ( tokenStream . lookAhead ( 0 ) ) ) { tokenStream . consume ( ) ; } while ( precedence < grammar . precedence ( tokenStream . lookAhead ( 0 ) ) ) { token = tokenStream . consume ( ) ; result = grammar . parse ( this , result , token ) ; } return result ; }
Parses the token stream to get the next expression