specmc_base/lib.rs
1//! A library with common code for parsing Minecraft specification.
2
3pub mod parse;
4pub mod tokenize;
5
6/// Ensure that the given condition is true, otherwise return the given value.
7#[macro_export]
8macro_rules! ensure {
9 ($cond:expr, $ret:expr) => {
10 if !$cond {
11 return Err($ret);
12 }
13 };
14}
15
16#[cfg(test)]
17mod tests {
18 #[macro_export]
19 macro_rules! test_parse {
20 ($tokens:ident, $ty:ty, $value:expr) => {
21 assert_eq!(<$ty>::parse(&mut $tokens), $value);
22 };
23 }
24}