softdevteam / lrpar

Rust LR parser
Other
1 stars 0 forks source link

Fix the new_lexeme API #43

Closed ltratt closed 6 years ago

ltratt commented 6 years ago

This is a simple, almost entirely mechanical, PR. The next_lexeme function turned into an accidental behemoth: it does two different things depending on the input, and returns two different things. Of its many call-sites, only one needs this full functionality.

These two commits thus split this function:

fn next_lexeme(&self, lexemes_prefix: Option<Lexeme<TokId>>, la_idx: usize) -> (Lexeme<TokId>, TIdx)

into two:

fn next_lexeme(&self, la_idx: usize) -> Lexeme<TokId> {... }
fn next_tidx(&self, la_idx: usize) -> TIdx { ... }

This makes a lot of the code a little bit easier to understand.

ltratt commented 6 years ago

OK, fixed (and, inevitably, squashed at the same time).

ptersilie commented 6 years ago

Very nice! I think the commits make much more sense like this. Merged!