Skip to content

Commit

Permalink
Merge pull request #130 from wezm/parse-const
Browse files Browse the repository at this point in the history
Fix handling of multi-word constants
  • Loading branch information
kaj committed Jul 16, 2023
2 parents 8c279d5 + efd42b5 commit 508f26e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/expression.rs
Expand Up @@ -55,7 +55,7 @@ pub fn rust_name(input: &[u8]) -> PResult<&str> {
map_res(
recognize(pair(
alt((tag("_"), alpha1)),
opt(is_a("_0123456789abcdefghijklmnopqrstuvwxyz")),
opt(is_a("_0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")),
)),
input_to_str,
)(input)
Expand Down
5 changes: 5 additions & 0 deletions src/template.rs
Expand Up @@ -241,6 +241,11 @@ mod test {
check_type_expr("SomeTypeWithRef<'_>");
}

#[test]
fn multiword_constant() {
check_type_expr("ONE_TWO_THREE");
}

fn check_type_expr(expr: &str) {
assert_eq!(type_expression(expr.as_bytes()), Ok((&b""[..], ())));
}
Expand Down

0 comments on commit 508f26e

Please sign in to comment.