E4216#
Compiler diagnostic name: lexscan_catchall_binder_not_supported.
A streaming lexscan catch-all case uses a binder pattern.
Streaming cases consume 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.
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"
}
}