diff --git a/src/fox32.pest b/src/fox32.pest index 47022cc..8a9ca4f 100644 --- a/src/fox32.pest +++ b/src/fox32.pest @@ -148,8 +148,8 @@ body_bin = @{ (ASCII_BIN_DIGIT | "_")+ } immediate_hex = ${ "0x" ~ body_hex } body_hex = @{ (ASCII_HEX_DIGIT | "_")+ } -immediate_dec = ${ body_dec } -body_dec = @{ (ASCII_DIGIT | "_")+ } +immediate_dec = ${ ASCII_DIGIT ~ body_dec } +body_dec = @{ (ASCII_DIGIT | "_")* } immediate_char = ${ "'" ~ body_char ~ "'" } body_char = @{ '\x00'..'\x7F' } diff --git a/src/main.rs b/src/main.rs index 31418ea..f6fd1b5 100644 --- a/src/main.rs +++ b/src/main.rs @@ -805,8 +805,8 @@ fn parse_operand(mut pair: pest::iterators::Pair, is_pointer: bool) -> Ast immediate_to_astnode(immediate, size, is_pointer) } Rule::immediate_dec => { - let body_dec_str = operand_value_pair.into_inner().next().unwrap().as_str(); - let immediate = remove_underscores(body_dec_str).parse::().unwrap(); + let dec_str = operand_value_pair.as_span().as_str(); + let immediate = remove_underscores(dec_str).parse::().unwrap(); immediate_to_astnode(immediate, size, is_pointer) } Rule::immediate_char => {