Skip to content

Commit

Permalink
allow underscore
Browse files Browse the repository at this point in the history
  • Loading branch information
rleungx committed Mar 27, 2018
1 parent 53ecaba commit bf3bf8c
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/macros.rs
Expand Up @@ -460,7 +460,7 @@ fn replace_names(input: &str) -> Option<(String, HashMap<String, String>)> {
} else if c == '(' && cur_name.is_empty() {
// FIXME: Support macro def with repeat.
return None;
} else if c.is_alphanumeric() {
} else if c.is_alphanumeric() || c == '_' {
cur_name.push(c);
}
}
Expand Down
20 changes: 20 additions & 0 deletions tests/source/macro_rules.rs
Expand Up @@ -168,3 +168,23 @@ macro_rules! add_message_to_notes {
}
}}
}

// #2560
macro_rules! binary {
($_self:ident,$expr:expr, $lhs:expr,$func:ident) => {
while $_self.matched($expr) {
let op = $_self.get_binary_op()?;

let rhs = Box::new($_self.$func()?);

$lhs = Spanned {
span: $lhs.get_span().to(rhs.get_span()),
value: Expression::Binary {
lhs: Box::new($lhs),
op,
rhs,
},
}
}
};
}
20 changes: 20 additions & 0 deletions tests/target/macro_rules.rs
Expand Up @@ -200,3 +200,23 @@ macro_rules! add_message_to_notes {
}
}};
}

// #2560
macro_rules! binary {
($_self:ident, $expr:expr, $lhs:expr, $func:ident) => {
while $_self.matched($expr) {
let op = $_self.get_binary_op()?;

let rhs = Box::new($_self.$func()?);

$lhs = Spanned {
span: $lhs.get_span().to(rhs.get_span()),
value: Expression::Binary {
lhs: Box::new($lhs),
op,
rhs,
},
}
}
};
}

0 comments on commit bf3bf8c

Please sign in to comment.