From c409cac20229120b20c8553e740bee21d6761691 Mon Sep 17 00:00:00 2001 From: Softcloud Date: Wed, 7 Feb 2024 20:47:30 +0800 Subject: [PATCH] FIX: asm match label like "main.1:". --- assembler/src/asm.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/assembler/src/asm.rs b/assembler/src/asm.rs index caad63dc..ea5d01a2 100644 --- a/assembler/src/asm.rs +++ b/assembler/src/asm.rs @@ -230,7 +230,7 @@ impl FromStr for AsmRow { type Err = String; fn from_str(s: &str) -> Result { - let regex_label_call = Regex::new(r"^(?P[[:word:]]+):$").unwrap(); + let regex_label_call = Regex::new(r"^(?P\w+(\.\d+)?):$").unwrap(); let caps_call = regex_label_call.captures(s); if caps_call.is_some() { let caps = caps_call.unwrap(); @@ -363,6 +363,12 @@ mod tests { let row_label_call_str = "bar:"; let row_label_call = AsmRow::from_str(row_label_call_str).unwrap(); assert_eq!(row_label_call, AsmRow::LabelCall(String::from("bar"))); + let row_label_call_with_num_str = "main.1:"; + let row_label_call_with_num = AsmRow::from_str(row_label_call_with_num_str).unwrap(); + assert_eq!( + row_label_call_with_num, + AsmRow::LabelCall(String::from("main.1")) + ); let row_label_jmp_str = ".LBL0_0:"; let row_label_jmp = AsmRow::from_str(row_label_jmp_str).unwrap();