Skip to content

Commit

Permalink
FIX: asm match label like "main.1:".
Browse files Browse the repository at this point in the history
  • Loading branch information
Softcloud88 committed Feb 7, 2024
1 parent 10e334d commit c409cac
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion assembler/src/asm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ impl FromStr for AsmRow {
type Err = String;

fn from_str(s: &str) -> Result<Self, Self::Err> {
let regex_label_call = Regex::new(r"^(?P<label_call>[[:word:]]+):$").unwrap();
let regex_label_call = Regex::new(r"^(?P<label_call>\w+(\.\d+)?):$").unwrap();
let caps_call = regex_label_call.captures(s);
if caps_call.is_some() {
let caps = caps_call.unwrap();
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit c409cac

Please sign in to comment.