Make macros private

This commit is contained in:
bakaq
2024-09-06 16:51:10 -03:00
parent 806e980cca
commit ada9ba98cc
15 changed files with 20 additions and 86 deletions

View File

@@ -139,7 +139,6 @@ pub const BTERM: u32 = 0x11000;
pub const NEGATIVE_SIGN: u32 = 0x0200;
#[macro_export]
macro_rules! fixnum {
($wrapper:tt, $n:expr, $arena:expr) => {
Fixnum::build_with_checked($n)
@@ -180,21 +179,18 @@ macro_rules! is_negate {
};
}
#[macro_export]
macro_rules! is_prefix {
($x:expr) => {
$x as u32 & ($crate::parser::ast::FX as u32 | $crate::parser::ast::FY as u32) != 0
};
}
#[macro_export]
macro_rules! is_postfix {
($x:expr) => {
$x as u32 & ($crate::parser::ast::XF as u32 | $crate::parser::ast::YF as u32) != 0
};
}
#[macro_export]
macro_rules! is_infix {
($x:expr) => {
($x as u32
@@ -205,48 +201,41 @@ macro_rules! is_infix {
};
}
#[macro_export]
macro_rules! is_xfx {
($x:expr) => {
($x as u32 & $crate::parser::ast::XFX as u32) != 0
};
}
#[macro_export]
macro_rules! is_xfy {
($x:expr) => {
($x as u32 & $crate::parser::ast::XFY as u32) != 0
};
}
#[macro_export]
macro_rules! is_yfx {
($x:expr) => {
($x as u32 & $crate::parser::ast::YFX as u32) != 0
};
}
#[macro_export]
macro_rules! is_yf {
($x:expr) => {
($x as u32 & $crate::parser::ast::YF as u32) != 0
};
}
#[macro_export]
macro_rules! is_xf {
($x:expr) => {
($x as u32 & $crate::parser::ast::XF as u32) != 0
};
}
#[macro_export]
macro_rules! is_fx {
($x:expr) => {
($x as u32 & $crate::parser::ast::FX as u32) != 0
};
}
#[macro_export]
macro_rules! is_fy {
($x:expr) => {
($x as u32 & $crate::parser::ast::FY as u32) != 0
@@ -317,14 +306,12 @@ impl Default for VarReg {
}
}
#[macro_export]
macro_rules! temp_v {
($x:expr) => {
$crate::parser::ast::RegType::Temp($x)
};
}
#[macro_export]
macro_rules! perm_v {
($x:expr) => {
$crate::parser::ast::RegType::Perm($x)

View File

@@ -1,237 +1,204 @@
#[macro_export]
macro_rules! char_class {
($c: expr, [$head:expr]) => ($c == $head);
($c: expr, [$head:expr $(, $cs:expr)+]) => ($c == $head || $crate::char_class!($c, [$($cs),*]));
($c: expr, [$head:expr $(, $cs:expr)+]) => ($c == $head || char_class!($c, [$($cs),*]));
}
#[macro_export]
macro_rules! alpha_char {
($c: expr) => {
(!$c.is_numeric()
&& !$c.is_whitespace()
&& !$c.is_control()
&& !$crate::graphic_token_char!($c)
&& !$crate::layout_char!($c)
&& !$crate::meta_char!($c)
&& !$crate::solo_char!($c))
&& !graphic_token_char!($c)
&& !layout_char!($c)
&& !meta_char!($c)
&& !solo_char!($c))
|| $c == '_'
};
}
#[macro_export]
macro_rules! alpha_numeric_char {
($c: expr) => {
$crate::alpha_char!($c) || $c.is_numeric()
alpha_char!($c) || $c.is_numeric()
};
}
#[macro_export]
macro_rules! backslash_char {
($c: expr) => {
$c == '\\'
};
}
#[macro_export]
macro_rules! back_quote_char {
($c: expr) => {
$c == '`'
};
}
#[macro_export]
macro_rules! octet_char {
($c: expr) => {
('\u{0000}'..='\u{00FF}').contains(&$c)
};
}
#[macro_export]
macro_rules! capital_letter_char {
($c: expr) => {
$c.is_uppercase()
};
}
#[macro_export]
macro_rules! comment_1_char {
($c: expr) => {
$c == '/'
};
}
#[macro_export]
macro_rules! comment_2_char {
($c: expr) => {
$c == '*'
};
}
#[macro_export]
macro_rules! cut_char {
($c: expr) => {
$c == '!'
};
}
#[macro_export]
macro_rules! decimal_digit_char {
($c: expr) => {
$c.is_ascii_digit()
};
}
#[macro_export]
macro_rules! decimal_point_char {
($c: expr) => {
$c == '.'
};
}
#[macro_export]
macro_rules! double_quote_char {
($c: expr) => {
$c == '"'
};
}
#[macro_export]
macro_rules! end_line_comment_char {
($c: expr) => {
$c == '%'
};
}
#[macro_export]
macro_rules! exponent_char {
($c: expr) => {
$c == 'e' || $c == 'E'
};
}
#[macro_export]
macro_rules! graphic_char {
($c: expr) => ($crate::char_class!($c, ['#', '$', '&', '*', '+', '-', '.', '/', ':',
($c: expr) => (char_class!($c, ['#', '$', '&', '*', '+', '-', '.', '/', ':',
'<', '=', '>', '?', '@', '^', '~']))
}
#[macro_export]
macro_rules! graphic_token_char {
($c: expr) => {
$crate::graphic_char!($c) || $crate::backslash_char!($c)
graphic_char!($c) || backslash_char!($c)
};
}
#[macro_export]
macro_rules! hexadecimal_digit_char {
($c: expr) => {
$c.is_ascii_digit() || ('A'..='F').contains(&$c) || ('a'..='f').contains(&$c)
};
}
#[macro_export]
macro_rules! layout_char {
($c: expr) => {
$crate::char_class!($c, [' ', '\r', '\n', '\t', '\u{0B}', '\u{0C}'])
char_class!($c, [' ', '\r', '\n', '\t', '\u{0B}', '\u{0C}'])
};
}
#[macro_export]
macro_rules! meta_char {
($c: expr) => {
$crate::char_class!($c, ['\\', '\'', '"', '`'])
char_class!($c, ['\\', '\'', '"', '`'])
};
}
#[macro_export]
macro_rules! new_line_char {
($c: expr) => {
$c == '\n'
};
}
#[macro_export]
macro_rules! octal_digit_char {
($c: expr) => {
('0'..='7').contains(&$c)
};
}
#[macro_export]
macro_rules! binary_digit_char {
($c: expr) => {
$c == '0' || $c == '1'
};
}
#[macro_export]
macro_rules! prolog_char {
($c: expr) => {
$crate::graphic_char!($c)
|| $crate::alpha_numeric_char!($c)
|| $crate::solo_char!($c)
|| $crate::layout_char!($c)
|| $crate::meta_char!($c)
graphic_char!($c)
|| alpha_numeric_char!($c)
|| solo_char!($c)
|| layout_char!($c)
|| meta_char!($c)
};
}
#[macro_export]
macro_rules! semicolon_char {
($c: expr) => {
$c == ';'
};
}
#[macro_export]
macro_rules! sign_char {
($c: expr) => {
$c == '-' || $c == '+'
};
}
#[macro_export]
macro_rules! single_quote_char {
($c: expr) => {
$c == '\''
};
}
#[macro_export]
macro_rules! small_letter_char {
($c: expr) => {
$c.is_alphabetic() && !$c.is_uppercase()
};
}
#[macro_export]
macro_rules! solo_char {
($c: expr) => {
$crate::char_class!($c, ['!', '(', ')', ',', ';', '[', ']', '{', '}', '|', '%'])
char_class!($c, ['!', '(', ')', ',', ';', '[', ']', '{', '}', '|', '%'])
};
}
#[macro_export]
macro_rules! space_char {
($c: expr) => {
$c == ' '
};
}
#[macro_export]
macro_rules! symbolic_control_char {
($c: expr) => {
$crate::char_class!($c, ['a', 'b', 'f', 'n', 'r', 't', 'v', '0'])
char_class!($c, ['a', 'b', 'f', 'n', 'r', 't', 'v', '0'])
};
}
#[macro_export]
macro_rules! symbolic_hexadecimal_char {
($c: expr) => {
$c == 'x'
};
}
#[macro_export]
macro_rules! variable_indicator_char {
($c: expr) => {
$c == '_'