Skip to content

Commit

Permalink
fix: update/fix regex parser
Browse files Browse the repository at this point in the history
  • Loading branch information
desbma-s1n committed May 29, 2024
1 parent 09d4735 commit 1a5972b
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/strace/parser/regex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -338,19 +338,21 @@ fn parse_argument(caps: &regex::Captures) -> anyhow::Result<Expression> {
} 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::<Result<_, _>>()?;
Ok(Expression::Integer(IntegerExpression {
value: IntegerExpressionValue::BinaryOr(int_tokens),
metadata: None,
Expand Down

0 comments on commit 1a5972b

Please sign in to comment.