From dfa10002f3e8962ac90139dd55c5d3052aeb83c9 Mon Sep 17 00:00:00 2001 From: Michael Baikov Date: Mon, 14 Oct 2024 17:53:41 -0400 Subject: [PATCH] Use smarter regexp to detect data declarations --- src/asm/statements.rs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/asm/statements.rs b/src/asm/statements.rs index 5cb6d29..496b1e3 100644 --- a/src/asm/statements.rs +++ b/src/asm/statements.rs @@ -61,13 +61,11 @@ fn parse_data_dec(input: &str) -> IResult<&str, Directive> { // .dc // .inst .insn let reg = DATA_DEC.get_or_init(|| { + // regexp is inspired by the compiler explorer Regex::new( - "^[\\s\\t]*\\.(long|short|octa|quad|word|\ - single|double|float|\ - ascii|asciz|string|string8|string16|string32|string64|\ - byte|2byte|4byte|8byte|dc|\ - inst|insn\ - )[\\s\\t]+([^\\n]+)", + "^\\s*\\.(ascii|asciz|[1248]?byte|dc(?:\\.[abdlswx])?|dcb(?:\\.[bdlswx])?\ + |ds(?:\\.[bdlpswx])?|double|dword|fill|float|half|hword|int|long|octa|quad|\ + short|single|skip|space|string(?:8|16|32|64)?|value|word|xword|zero)\\s+([^\\n]+)", ) .expect("regexp should be valid") });