bjorn3 opened PR #5693 from isle_cleanup1
to main
:
This uses a couple of functions in the ISLE lexer than significantly simply the code.
In addition it introduces a token eating api which tries to eat a specific token but returns
None
rather than an error if this fails and it renames take to expect. This brings it a bit more in line with the names used in rustc's parser and IMHO it is a bit nicer.
jameysharp submitted PR review.
jameysharp submitted PR review.
jameysharp created PR review comment:
This can just be
let infallible = self.eat_sym_str("infallible")?;
now, in yet another demonstration of why your suggested change is a good idea.
jameysharp created PR review comment:
Does Rust allow using the following syntax instead, and would you agree it's easier to read?
c @ (b'0'..=b'9' | b'-') => {
jameysharp created PR review comment:
I would have expected
eat
to returnSome(token)
if there is a next token and it matches the predicate, and on the other hand, returnNone
if there's no more tokens or the next token doesn't match. I'm not convinced that returning aResult
in order to distinguish the EOF case makes sense here.It doesn't exactly matter since everywhere this is used we expect more tokens to follow anyway, so it's okay to detect the EOF here, but I think this is simpler to use and its behavior is easier to explain if it simply returns
None
at EOF.
bjorn3 updated PR #5693 from isle_cleanup1
to main
.
bjorn3 submitted PR review.
bjorn3 created PR review comment:
Indeed. Fixed a couple of other cases like this too.
bjorn3 submitted PR review.
bjorn3 created PR review comment:
It does. Changed it.
bjorn3 submitted PR review.
bjorn3 created PR review comment:
Changed to return
Ok(None)
on EOF.
bjorn3 updated PR #5693 from isle_cleanup1
to main
.
jameysharp submitted PR review.
jameysharp merged PR #5693.
Last updated: Nov 22 2024 at 17:03 UTC