Last active
February 1, 2023 20:21
-
-
Save progval/a00aebd84bfd3e653b1cb0fa81659cd7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#![recursion_limit="1024"] | |
macro_rules! rule90 { | |
// Initialization | |
( ($($fuel:tt)*) | $($cells:tt,)* ) => { | |
rule90!( __cont ($($fuel)*) | ($($cells,)*) | (($($cells,)*)) ); | |
}; | |
// Initialize the line | |
( __cont (f $($fuel:tt)*) | ($($cells:tt,)*) | ($(($($history:tt,)*))* ) ) => { | |
rule90!( __inline ($($fuel)*) | (.,) ($($cells,)*) | ( $(($($history,)*))* ) ); | |
}; | |
// The rule itself | |
( __inline ($($fuel:tt)*) | ($($lcells:tt,)*) (., $mid:tt, ., $($rcells:tt,)*) | ($(($($history:tt,)*))* ) ) => { | |
rule90!( __inline ($($fuel)*) | ($($lcells,)* ., ) ($mid, ., $($rcells,)*) | ($(($($history,)*))* ) ); | |
}; | |
( __inline ($($fuel:tt)*) | ($($lcells:tt,)*) (W, $mid:tt, ., $($rcells:tt,)*) | ($(($($history:tt,)*))* ) ) => { | |
rule90!( __inline ($($fuel)*) | ($($lcells,)* W, ) ($mid, ., $($rcells,)*) | ($(($($history,)*))* ) ); | |
}; | |
( __inline ($($fuel:tt)*) | ($($lcells:tt,)*) (., $mid:tt, W, $($rcells:tt,)*) | ($(($($history:tt,)*))* ) ) => { | |
rule90!( __inline ($($fuel)*) | ($($lcells,)* W, ) ($mid, W, $($rcells,)*) | ($(($($history,)*))* ) ); | |
}; | |
( __inline ($($fuel:tt)*) | ($($lcells:tt,)*) (W, $mid:tt, W, $($rcells:tt,)*) | ($(($($history:tt,)*))* ) ) => { | |
rule90!( __inline ($($fuel)*) | ($($lcells,)* ., ) ($mid, W, $($rcells,)*) | ($(($($history,)*))* ) ); | |
}; | |
// Ending the line | |
( __inline ($($fuel:tt)*) | ($($lcells:tt,)*) (., .,) | ($(($($history:tt,)*))* ) ) => { | |
rule90!( __inline ($($fuel)*) | ($($lcells,)* ., ) () | ($(($($history,)*))* ) ); | |
}; | |
( __inline ($($fuel:tt)*) | ($($lcells:tt,)*) (W, .,) | ($(($($history:tt,)*))* ) ) => { | |
rule90!( __inline ($($fuel)*) | ($($lcells,)* W, ) () | ($(($($history,)*))* ) ); | |
}; | |
( __inline ($($fuel:tt)*) | ($($lcells:tt,)*) (., W,) | ($(($($history:tt,)*))* ) ) => { | |
rule90!( __inline ($($fuel)*) | ($($lcells,)* ., ) () | ($(($($history,)*))* ) ); | |
}; | |
// ( __inline ($($fuel:tt)*) | ($($lcells:tt,)*) (W, .,) | ($(($($history:tt,)*))* ) ) => { | |
// rule90!( __inline ($($fuel)*) | ($($lcells,)* W, ) () | ($(($($history,)*))* ) ); | |
// }; | |
( __inline ($($fuel:tt)*) | ($($lcells:tt,)*) () | ($(($($history:tt,)*))* ) ) => { | |
rule90!( __cont ($($fuel)*) | ($($lcells,)*) | ( ($($lcells,)*) $(($($history,)*))* ) ); | |
}; | |
// End of execution | |
( __cont () | ($($cells:tt,)*) | ( $( ( $($cell:tt,)* ) )*) ) => { | |
compile_error!(concat!("\n", $($(stringify!($cell),)* "\n", )*)); | |
}; | |
} | |
rule90!((f f f f f f f f f f f f f f f f f ) | W, ., ., ., ., ., ., ., ., ., ., ., ., ., ., ., ., ., ., ., ., ., ., .,); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment