Macros can use strings

This commit is contained in:
Carl-Henrik Skårstedt 2021-12-12 20:13:05 +01:00
parent 842b68b342
commit 9e542033b8
2 changed files with 22 additions and 3 deletions

View File

@ -590,6 +590,7 @@ public:
strref split_token_trim(char c);
strref split_token_any_trim(const strref chars);
strref split_token_track_parens(char c);
strref split_token_track_parens_quote(char c);
strref split_token_trim_track_parens(char c);
strref split_range(const strref range, strl_t pos=0);
strref split_range_trim(const strref range, strl_t pos=0);
@ -4162,6 +4163,24 @@ strref strref::split_token_track_parens(char c)
return r;
}
strref strref::split_token_track_parens_quote(char c)
{
if (length>=2 && string[0] == '"') {
strl_t o = 1;
while (o < length && string[o] != '"') { ++o; }
if (o < length) {
strref r = strref(string, o + 1);
*this += o + 1;
return r;
}
}
int t = find_skip_parens(c);
if (t < 0) t = (int)length;
strref r = strref(string, strl_t(t));
*this += t + 1;
return r;
}
strref strref::split_token_any( const strref chars )
{
strref r; int t = find_any_char_of( chars );

View File

@ -3421,8 +3421,8 @@ StatusCode Asm::BuildMacro(Macro &m, strref arg_list) {
strref pchk = params;
strref arg = arg_list;
int dSize = 0;
char token = arg_list.find(',')>=0 ? ',' : ' ';
char token_macro = m.params_first_line && params.find(',') < 0 ? ' ' : ',';
char token = ',';// arg_list.find(',') >= 0 ? ',' : ' ';
char token_macro = ',';// m.params_first_line&& params.find(',') < 0 ? ' ' : ',';
while (strref param = pchk.split_token_trim(token_macro)) {
strref a = arg.split_token_trim(token);
if (param.get_len() < a.get_len()) {
@ -3436,7 +3436,7 @@ StatusCode Asm::BuildMacro(Macro &m, strref arg_list) {
strovl macexp(buffer, mac_size);
macexp.copy(macro_src);
while (strref param = params.split_token_trim(token_macro)) {
strref a = arg_list.split_token_trim(token);
strref a = arg_list.split_token_track_parens_quote(token);
macexp.replace_bookend(param, a, macro_arg_bookend);
}
PushContext(m.source_name, macexp.get_strref(), macexp.get_strref());