From 1a5972bebb393f4cfc72200fd8ca49e2af91f748 Mon Sep 17 00:00:00 2001 From: desbma-s1n Date: Wed, 29 May 2024 18:01:17 +0200 Subject: [PATCH] fix: update/fix regex parser --- src/strace/parser/regex.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/strace/parser/regex.rs b/src/strace/parser/regex.rs index 84b893f..88dc157 100644 --- a/src/strace/parser/regex.rs +++ b/src/strace/parser/regex.rs @@ -338,19 +338,21 @@ fn parse_argument(caps: ®ex::Captures) -> anyhow::Result { } else { let int_tokens = tokens .into_iter() - .map(|t| { + .map(|t| -> anyhow::Result<_> { if let Some(one_shift) = t.strip_prefix("1<<") { - IntegerExpressionValue::LeftBitShift { + Ok(IntegerExpressionValue::LeftBitShift { bits: Box::new(IntegerExpressionValue::Literal(1)), shift: Box::new(IntegerExpressionValue::NamedConst( one_shift.to_owned(), )), - } + }) + } else if t.starts_with("0") { + Ok(IntegerExpressionValue::Literal(i128::from_str_radix(t, 8)?)) } else { - IntegerExpressionValue::NamedConst(t.to_owned()) + Ok(IntegerExpressionValue::NamedConst(t.to_owned())) } }) - .collect(); + .collect::>()?; Ok(Expression::Integer(IntegerExpression { value: IntegerExpressionValue::BinaryOr(int_tokens), metadata: None,