summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author Aaron Giles <aaron@aarongiles.com>2008-08-07 06:48:04 +0000
committer Aaron Giles <aaron@aarongiles.com>2008-08-07 06:48:04 +0000
commitce00409cce24d6c2fd46e744db51910b86a9b554 (patch)
treee1a02a0136065564881af47ebc3057e296924e3a
parent315369330637aa030d52850a91b6c997789e435d (diff)
Added word alternates for operators in expressions:
+ plus - minus * times or mul / div % mod ! not ~ bnot && and & band || or | bor ^ bxor lt < le <= gt > ge >= eq == ne != Changed cheat escaping to automatically escape && & < and <= to and band lt and le.
-rw-r--r--src/emu/cheat.c34
-rw-r--r--src/emu/debug/express.c42
2 files changed, 61 insertions, 15 deletions
diff --git a/src/emu/cheat.c b/src/emu/cheat.c
index 030febae428..d5a67ae26f1 100644
--- a/src/emu/cheat.c
+++ b/src/emu/cheat.c
@@ -1383,19 +1383,26 @@ static void script_entry_free(script_entry *entry)
static astring *quote_astring_expression(astring *string, int isattribute)
{
- if (isattribute)
- {
- astring_replacec(string, 0, "&", "&amp;");
- astring_replacec(string, 0, "<", "&lt;");
- }
- else
- {
- if (astring_chr(string, 0, '&') != -1 || astring_chr(string, 0, '<') != -1)
- {
- astring_insc(string, 0, "<![CDATA[ ");
- astring_catc(string, " ]]>");
- }
- }
+ astring_replacec(string, 0, " && ", " and ");
+ astring_replacec(string, 0, " &&", " and ");
+ astring_replacec(string, 0, "&& ", " and ");
+ astring_replacec(string, 0, "&&", " and ");
+
+ astring_replacec(string, 0, " & ", " band ");
+ astring_replacec(string, 0, " &", " band ");
+ astring_replacec(string, 0, "& ", " band ");
+ astring_replacec(string, 0, "&", " band ");
+
+ astring_replacec(string, 0, " <= ", " le ");
+ astring_replacec(string, 0, " <=", " le ");
+ astring_replacec(string, 0, "<= ", " le ");
+ astring_replacec(string, 0, "<=", " le ");
+
+ astring_replacec(string, 0, " < ", " lt ");
+ astring_replacec(string, 0, " <", " lt ");
+ astring_replacec(string, 0, "< ", " lt ");
+ astring_replacec(string, 0, "<", " lt ");
+
return string;
}
@@ -1474,4 +1481,3 @@ static void cheat_variable_set(void *ref, UINT64 value)
{
*(UINT64 *)ref = value;
}
-
diff --git a/src/emu/debug/express.c b/src/emu/debug/express.c
index 735964d1580..f61edda8407 100644
--- a/src/emu/debug/express.c
+++ b/src/emu/debug/express.c
@@ -832,10 +832,50 @@ static EXPRERR parse_string_into_tokens(const char *stringstart, parsed_expressi
break;
}
}
-
+
/* empty string is automatically invalid */
if (buffer[0] == 0)
return MAKE_EXPRERR_INVALID_TOKEN(token->offset);
+
+ /* check for wordy variants on standard operators */
+ else if (strcmp(buffer, "bnot") == 0)
+ SET_TOKEN_INFO(0, TOK_OPERATOR, TVL_NOT, TIN_PRECEDENCE_2);
+ else if (strcmp(buffer, "plus") == 0)
+ SET_TOKEN_INFO(0, TOK_OPERATOR, TVL_ADD, TIN_PRECEDENCE_4);
+ else if (strcmp(buffer, "minus") == 0)
+ SET_TOKEN_INFO(0, TOK_OPERATOR, TVL_SUBTRACT, TIN_PRECEDENCE_4);
+ else if (strcmp(buffer, "times") == 0 || strcmp(buffer, "mul") == 0)
+ SET_TOKEN_INFO(0, TOK_OPERATOR, TVL_MULTIPLY, TIN_PRECEDENCE_3);
+ else if (strcmp(buffer, "div") == 0)
+ SET_TOKEN_INFO(0, TOK_OPERATOR, TVL_DIVIDE, TIN_PRECEDENCE_3);
+ else if (strcmp(buffer, "mod") == 0)
+ SET_TOKEN_INFO(0, TOK_OPERATOR, TVL_MODULO, TIN_PRECEDENCE_3);
+ else if (strcmp(buffer, "lt") == 0)
+ SET_TOKEN_INFO(0, TOK_OPERATOR, TVL_LESS, TIN_PRECEDENCE_6);
+ else if (strcmp(buffer, "le") == 0)
+ SET_TOKEN_INFO(0, TOK_OPERATOR, TVL_LESSOREQUAL, TIN_PRECEDENCE_6);
+ else if (strcmp(buffer, "gt") == 0)
+ SET_TOKEN_INFO(0, TOK_OPERATOR, TVL_GREATER, TIN_PRECEDENCE_6);
+ else if (strcmp(buffer, "ge") == 0)
+ SET_TOKEN_INFO(0, TOK_OPERATOR, TVL_GREATEROREQUAL, TIN_PRECEDENCE_6);
+ else if (strcmp(buffer, "eq") == 0)
+ SET_TOKEN_INFO(0, TOK_OPERATOR, TVL_EQUAL, TIN_PRECEDENCE_7);
+ else if (strcmp(buffer, "ne") == 0)
+ SET_TOKEN_INFO(0, TOK_OPERATOR, TVL_NOTEQUAL, TIN_PRECEDENCE_7);
+ else if (strcmp(buffer, "not") == 0)
+ SET_TOKEN_INFO(0, TOK_OPERATOR, TVL_COMPLEMENT, TIN_PRECEDENCE_2);
+ else if (strcmp(buffer, "and") == 0)
+ SET_TOKEN_INFO(0, TOK_OPERATOR, TVL_LAND, TIN_PRECEDENCE_8);
+ else if (strcmp(buffer, "band") == 0)
+ SET_TOKEN_INFO(0, TOK_OPERATOR, TVL_BAND, TIN_PRECEDENCE_8);
+ else if (strcmp(buffer, "or") == 0)
+ SET_TOKEN_INFO(0, TOK_OPERATOR, TVL_LOR, TIN_PRECEDENCE_12);
+ else if (strcmp(buffer, "bor") == 0)
+ SET_TOKEN_INFO(0, TOK_OPERATOR, TVL_BOR, TIN_PRECEDENCE_10);
+ else if (strcmp(buffer, "bxor") == 0)
+ SET_TOKEN_INFO(0, TOK_OPERATOR, TVL_BXOR, TIN_PRECEDENCE_9);
+
+ /* process anything else as a number or string */
else
{
/* if we have a number prefix, assume it is a number */