From c478e26281ffa9bae28a4c84a95bad1a75787246 Mon Sep 17 00:00:00 2001 From: Bazaah Date: Wed, 16 Jun 2021 20:50:31 +0000 Subject: [PATCH] scanner/macros: isLineBreak! -> isBreak, add isBlank!, isBlankZ! - isBlank checks for spaces or tabs - isBlankZ = isBreak! || isBlank! || empty names need some work --- src/scanner/macros.rs | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/src/scanner/macros.rs b/src/scanner/macros.rs index 4f21d18..c066e60 100644 --- a/src/scanner/macros.rs +++ b/src/scanner/macros.rs @@ -79,9 +79,10 @@ macro_rules! check { }; } -macro_rules! isLineBreak { +/// Check if the char (@offset) is a line break +macro_rules! isBreak { (~ $buffer:expr $(, $offset:expr )? ) => { - isLineBreak!($buffer.as_bytes() $(, $offset )? ) + isBreak!($buffer.as_bytes() $(, $offset )? ) }; ($buffer:expr $(, $offset:expr )? ) => { check!($buffer $(, $offset)? => @@ -93,3 +94,26 @@ macro_rules! isLineBreak { ) }; } + +/// Check if the char (@offset) is a space or tab +macro_rules! isBlank { + (~ $buffer:expr $(, $offset:expr )? ) => { + isBlank!($buffer.as_bytes() $(, $offset )? ) + }; + ($buffer:expr $(, $offset:expr )? ) => { + check!($buffer $(, $offset)? => b' ' | b'\t') + }; +} + +/// Check if the char (@offset) is a space, tab or line +/// break +macro_rules! isBlankZ { + (~ $buffer:expr $(, $offset:expr )? ) => { + isBlankZ!($buffer.as_bytes() $(, $offset )? ) + }; + ($buffer:expr $(, $offset:expr )? ) => { + isBlank!($buffer $(, $offset)?) + || isBreak!($buffer $(, $offset)?) + || check!($buffer $(, $offset)? => []) + }; +}