NFA parser for mbe matcher

This commit is contained in:
Edwin Cheng 2021-02-02 04:42:37 +08:00
parent 7f57a01b3d
commit cff2201c30
9 changed files with 592 additions and 175 deletions

View file

@ -456,6 +456,17 @@ fn test_match_group_with_multichar_sep() {
.assert_expand_items("foo! (fn baz {true true} );", "fn baz () -> bool {true &&true}");
}
#[test]
fn test_match_group_with_multichar_sep2() {
parse_macro(
r#"
macro_rules! foo {
(fn $name:ident {$($i:literal)&&*} ) => ( fn $name() -> bool { $($i)&&*} );
}"#,
)
.assert_expand_items("foo! (fn baz {true && true} );", "fn baz () -> bool {true &&true}");
}
#[test]
fn test_match_group_zero_match() {
parse_macro(
@ -1267,6 +1278,18 @@ macro_rules! m {
.is_some());
}
#[test]
fn test_match_is_not_greedy() {
parse_macro(
r#"
macro_rules! foo {
($($i:ident $(,)*),*) => {};
}
"#,
)
.assert_expand_items(r#"foo!(a,b);"#, r#""#);
}
// The following tests are based on real world situations
#[test]
fn test_vec() {