1
0
Fork 0

Special handling for format strings in the command parser

This allows: log "jmp {streq(dis.mnemonic(cip), "jmp")}" to work as you would expect

Closes #2930
This commit is contained in:
Duncan Ogilvie 2022-09-04 22:16:54 +02:00
parent 974b93432e
commit 7a5226a182
2 changed files with 36 additions and 1 deletions

View File

@ -60,6 +60,10 @@ Command::Command(const String & command)
case '\"':
state = Default;
break;
case '{':
state = StringFormat;
dataAppend(ch);
break;
default:
dataAppend(ch);
break;
@ -71,6 +75,9 @@ Command::Command(const String & command)
case '\"':
dataAppend(ch);
break;
case '{':
dataAppend(ch);
break;
default:
dataAppend('\\');
dataAppend(ch);
@ -78,6 +85,33 @@ Command::Command(const String & command)
}
state = Text;
break;
case StringFormat:
{
dataAppend(ch);
auto nextch = i + 1 < len ? command[i + 1] : '\0';
switch(ch)
{
case '{':
if(nextch == '{')
{
dataAppend(nextch);
i++;
}
break;
case '}':
if(nextch == '}')
{
dataAppend(nextch);
i++;
}
else
{
state = Text;
}
break;
}
}
break;
}
}
if(state == Escaped || state == TextEscaped)

View File

@ -20,7 +20,8 @@ private:
Default,
Escaped,
Text,
TextEscaped
TextEscaped,
StringFormat,
};
void dataFinish();