Don't parse _123 as a decimal number

Instead require that decimal numbers start with a digit.

This fixes the detection of things like _L4 and _4 as labels.
This commit is contained in:
jn 2023-02-03 14:56:07 +01:00
parent 3453727735
commit 99438e5997
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 } immediate_hex = ${ "0x" ~ body_hex }
body_hex = @{ (ASCII_HEX_DIGIT | "_")+ } body_hex = @{ (ASCII_HEX_DIGIT | "_")+ }
immediate_dec = ${ body_dec } immediate_dec = ${ ASCII_DIGIT ~ body_dec }
body_dec = @{ (ASCII_DIGIT | "_")+ } body_dec = @{ (ASCII_DIGIT | "_")* }
immediate_char = ${ "'" ~ body_char ~ "'" } immediate_char = ${ "'" ~ body_char ~ "'" }
body_char = @{ '\x00'..'\x7F' } 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) immediate_to_astnode(immediate, size, is_pointer)
} }
Rule::immediate_dec => { Rule::immediate_dec => {
let body_dec_str = operand_value_pair.into_inner().next().unwrap().as_str(); let dec_str = operand_value_pair.as_span().as_str();
let immediate = remove_underscores(body_dec_str).parse::<u32>().unwrap(); let immediate = remove_underscores(dec_str).parse::<u32>().unwrap();
immediate_to_astnode(immediate, size, is_pointer) immediate_to_astnode(immediate, size, is_pointer)
} }
Rule::immediate_char => { Rule::immediate_char => {