Merge pull request #12 from neuschaefer/dev

Don't parse _123 as a decimal number
This commit is contained in:
Ry 2023-02-03 15:27:49 -08:00 committed by GitHub
commit 007caeb23f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

View File

@ -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' }

View File

@ -805,8 +805,8 @@ fn parse_operand(mut pair: pest::iterators::Pair<Rule>, 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::<u32>().unwrap();
let dec_str = operand_value_pair.as_span().as_str();
let immediate = remove_underscores(dec_str).parse::<u32>().unwrap();
immediate_to_astnode(immediate, size, is_pointer)
}
Rule::immediate_char => {