mirror of
https://github.com/MorizzG/rlox.git
synced 2025-12-06 04:12:42 +00:00
34 lines
666 B
Rust
34 lines
666 B
Rust
#[macro_export]
|
|
macro_rules! debug_println {
|
|
($($arg:tt)*) => {
|
|
if cfg!(debug_assertions) {
|
|
println!($($arg)*);
|
|
}
|
|
};
|
|
}
|
|
|
|
#[macro_export]
|
|
macro_rules! single_rule {
|
|
( $token_type:tt, ( $prefix:tt, $infix:tt, $prec:ident ) ) => {
|
|
ParseRule {
|
|
token_type: rlox2_frontend::lexer::TokenType::$token_type,
|
|
prefix: Compiler::$prefix,
|
|
infix: Compiler::$infix,
|
|
precedence: Precedence::$prec,
|
|
}
|
|
};
|
|
}
|
|
|
|
#[macro_export]
|
|
macro_rules! gen_rules_table {
|
|
( $( $token_type:tt => $args:tt ),* ) => {
|
|
{
|
|
[
|
|
$(
|
|
single_rule!($token_type, $args),
|
|
)*
|
|
]
|
|
}
|
|
|
|
};
|
|
}
|