From c9170f9e8a4d9c907c79589ffbcb634c56391299 Mon Sep 17 00:00:00 2001 From: Shawn Quick Date: Sat, 18 Feb 2023 17:44:34 -0800 Subject: [PATCH] some minor modes, pretty broken in rewriting regex expressions for parsing operands --- asm.cpp | 11 ++- asm.h | 257 ++++++++++++++++++++++++------------------------ src/tomerlin.sh | 2 +- test.s | 6 +- 4 files changed, 144 insertions(+), 132 deletions(-) diff --git a/asm.cpp b/asm.cpp index 40cb7a0..b651d00 100644 --- a/asm.cpp +++ b/asm.cpp @@ -2003,7 +2003,7 @@ void CLASS::complete(void) int CLASS::split_params(string param_string, std::vector ¶ms) { int res=-1; - printf("split: |%s|\n",param_string.c_str()); + //printf("split: |%s|\n",param_string.c_str()); TOperParam p(param_string); return(res); @@ -2107,6 +2107,10 @@ int CLASS::getAddrMode(MerlinLine & line) std::vector groups; shiftStruct shift(line.operand); + printf("evaloper\n"); + TOperParam p(line.operand); + printf("evaloper exit\n"); + oper=line.operand; int l=oper.length(); int ol=line.opcode.length(); @@ -2127,6 +2131,11 @@ int CLASS::getAddrMode(MerlinLine & line) //printf("shiftstring: |%s|\n",oper.c_str()); line.shiftchar=shift.shiftchar; + //printf("evaloper\n"); + //TOperParam p(line.operand); + //printf("evaloper exit\n"); + + idx = 0; RegularExpression valEx(valExpression, 0, true); diff --git a/asm.h b/asm.h index a30f460..ac7f70a 100644 --- a/asm.h +++ b/asm.h @@ -4,6 +4,7 @@ #include "qasm.h" // //extern ConfigOptions qoptions; +using Poco::RegularExpression; #define OPHANDLER(ACB) std::bind(ACB, this, std::placeholders::_1, std::placeholders::_2) @@ -117,132 +118,20 @@ class TOperParam { public: std::string splitString; - //const string splitHex="^[$]?(?'hex'[A-Za-z0-9]+)(?'sep'[[:blank:],;]*)$"; - //const string splitNum="^(?'number'[0-9]+)(?'sep'[[:blank:],;]*)$"; - //const string splitBin="^[%]?(?'binary'[01]+)(?'sep'[[:blank:],;]*)$"; - //const string splitLabel="^[#|<>^]?(?'label'[A-Za-z:]?[A-Za-z0-9_]*)[:]?(?'sep'[[:blank:],;]*)$"; - //const string splitVariable="^[#|<>\\^]?[\\]]{1}(?'variable'[A-Za-z:]?[A-Za-z0-9_]*)[:]?(?'sep'[[:blank:],;]*)$"; - //Poco::RegularExpression splitStringRegEx; - //Poco::RegularExpression splitStringRegEx(&splitString,0,true); - -#if 0 -/(?x) # ignore pattern whitespace -(?(DEFINE) - (? (?'open'[!0-9\\,]{1})(?'str'.*?)(?'close'\k'open')) - (? \d+ ) - (? - \s* (?: - (?&dstring) - | (?&number) - | (?&list) - ) \s* - ) - (? \\ (?&value) (?: [,;]* (?&value) )* \\ ) -) -^(?&value)$/gm - ----- - -/[;,[:space:]]*(?'dstring'(?'delim'[^0-9,\\[:space:]])(?'str'.*?(?=\2))(?'close'\2)(?>[;,[:space:]]+))/gm // merlin delimited string -/[;,[:space:]]*(?'binarystr'(?'delim'[%])(?'val'[0-1+?)(?'close'\2)(?>[;,[:space:]]+))/gm // binary value %01001 -/[;,[:space:]]*(?'decimalstr'(?'val'[0-9*?)(?'close'\2)(?>[;,[:space:]]+))/gm // integer -/[;,[:space:]]*(?'delim'[\$])(?'hexval'[0-9a-zA-Z]+?)(?'end'[;,[:space:]]+)/gm // hex -/[;,[:space:]]*(?'delim'[\%])(?'binval'[0-9a-zA-Z]+?)(?'end'[;,[:space:]]+)/gm // binary %1001 - -(?'stringval'[;,[:space:]]*(?'dstring'(?'delim'[^0-9,\\[:space:]])(?'str'.*?(?=(?P=delim)))(?'close'(?P=delim)(?>[;,[:space:]]+)))) - -/(?x) # ignore pattern whitespace -(?(DEFINE) - (?(?'s_delim'[^0-9\/[:space:]])(?'strout'.*?(?=(?P=s_delim)))(?'e_delim'(?P=s_delim))) - (? (?'numout'[\#]?[<>|\^]?\d+ )) - (?([\#]?[<>|\^]?%[01]+)) - (?(?'hexout'[\#]?[<>|\^]?\$[A-Fa-f0-9]+)) - (?(?'hexlist'[A-Fa-f0-9]+)) - (?