From e9a88e7abd9b9f398626266c5ef23a926171ff7e Mon Sep 17 00:00:00 2001 From: Thibaut Vandervelden Date: Thu, 28 Apr 2022 17:20:29 +0200 Subject: [PATCH] Fix parsing --- src/ir.rs | 2 +- src/ir/define.rs | 1 + src/ir/item.rs | 5 +++++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/ir.rs b/src/ir.rs index 123dc1c..24893ee 100644 --- a/src/ir.rs +++ b/src/ir.rs @@ -242,7 +242,7 @@ fn getelementptr(i: &str) -> IResult<&str, GetElementPtr> { } fn name(i: &str) -> IResult<&str, &str> { - alt((map(string, |s| s.0), map(ident, |i| i.0)))(i) + alt((map(string, |s| s.0), map(ident, |i| i.0), digit1))(i) } #[derive(Clone, Copy, Debug, PartialEq)] diff --git a/src/ir/define.rs b/src/ir/define.rs index 62463bf..6d2b6ee 100644 --- a/src/ir/define.rs +++ b/src/ir/define.rs @@ -161,6 +161,7 @@ fn argument(i: &str) -> IResult<&str, Argument> { map(super::bitcast, drop), map(super::getelementptr, drop), map(super::local, drop), + map(super::function, drop), map(digit1, drop), ))(i)? .0; diff --git a/src/ir/item.rs b/src/ir/item.rs index 61048ae..f63fde9 100644 --- a/src/ir/item.rs +++ b/src/ir/item.rs @@ -268,6 +268,11 @@ mod tests { #[test] fn type_() { + assert_eq!( + super::type_("%0 = type { i32, { i8*, i8* } }"), + Ok(("", Item::Type)) + ); + assert_eq!( super::type_("%\"blue_pill::ItmLogger\" = type {}"), Ok(("", Item::Type))