E4216#
Compiler diagnostic name: lexscan_catchall_binder_not_supported.
A lexscan catch-all case uses a binder pattern.
lexscan consumes input only when a regex matches. The final catch-all also
handles end of input, so it does not bind a matched substring. Use _ for that
case and bind text with as on the regex cases that need it. This also applies
when the target is an in-memory @lexbuf.StringScanner.
Erroneous example#
///|
pub fn next_token(lexbuf : @lexbuf.Lexbuf) -> String {
lexscan lexbuf {
(re"^[a-z]+" as word) => word.to_owned()
rest => rest.to_owned()
}
}
Suggestion#
Replace the catch-all binder with _.
///|
pub fn next_token(lexbuf : @lexbuf.Lexbuf) -> String {
lexscan lexbuf {
(re"^[a-z]+" as word) => word.to_owned()
_ => "end"
}
}