scanner/macros: fix error path syntax

This commit is contained in:
Paul Stemmet 2021-06-26 07:24:57 +00:00
parent c4e514f6c2
commit b7575fa0da
Signed by: Paul Stemmet
GPG Key ID: EDEA539F594E7E75
1 changed files with 5 additions and 5 deletions

View File

@ -70,7 +70,7 @@ macro_rules! check {
(@priv $buffer:expr, $offset:expr => $( $match:tt )|+) => {
match $buffer.get($offset..) {
Some(buffer) => check!(@priv buffer => $( $match )|+),
None => check!(@eofck $( $match )|+ )
None => check!(@eofck $( $match )|+ ),
}
};
(@priv $buffer:expr => $( $match:tt )|+) => {
@ -81,16 +81,16 @@ macro_rules! check {
};
(@priv $buffer:expr, $offset:expr => $( $match:tt )|+, else $error:expr) => {
match $buffer.get($offset..) {
Some(buffer) => check!(@priv buffer => $( $match )|+ else $error),
None if check!(@eofck $( $match )|+ ) => Ok(())
_ => Err($crate::scanner::error::ScanError::UnexpectedEOF)
Some(buffer) => check!(@priv buffer => $( $match )|+, else $error),
None if check!(@eofck $( $match )|+ ) => Ok(()),
_ => Err($crate::scanner::error::ScanError::UnexpectedEOF),
}
};
(@priv $buffer:expr => $( $match:tt )|+, else $error:expr) => {
match $buffer {
$( check!(@ptn $match) )|+ => Ok(()),
[] => Err($crate::scanner::error::ScanError::UnexpectedEOF),
_ => Err($error)
_ => Err($error),
}
};