diff options
| author | Jasper St. Pierre <jstpierre@mecheye.net> | 2013-06-14 03:10:27 -0400 |
|---|---|---|
| committer | Jasper St. Pierre <jstpierre@mecheye.net> | 2013-06-25 00:58:30 -0400 |
| commit | a42388d06108154fe424dc94cf1ed9f4842c5f2b (patch) | |
| tree | 4423723c1e845558c35b07694e407d8053b8d78a /Source/Core/InputCommon/Src/ControllerInterface/ExpressionParser.cpp | |
| parent | d2753cce6617ea053c233289ec4213419913ed6b (diff) | |
ExpressionParser: Support bare words for simple control names
Using backticks for all control names can get a bit grating,
so support "A & B" instead of requiring "`A` & `B`".
Diffstat (limited to 'Source/Core/InputCommon/Src/ControllerInterface/ExpressionParser.cpp')
| -rw-r--r-- | Source/Core/InputCommon/Src/ControllerInterface/ExpressionParser.cpp | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/Source/Core/InputCommon/Src/ControllerInterface/ExpressionParser.cpp b/Source/Core/InputCommon/Src/ControllerInterface/ExpressionParser.cpp index 2cd7a59bf2..2023debd56 100644 --- a/Source/Core/InputCommon/Src/ControllerInterface/ExpressionParser.cpp +++ b/Source/Core/InputCommon/Src/ControllerInterface/ExpressionParser.cpp @@ -108,7 +108,7 @@ public: return false; } - Token GetControlQualifier() + Token GetFullyQualifiedControl() { ControlQualifier qualifier; std::string value; @@ -126,6 +126,24 @@ public: return Token(TOK_CONTROL, qualifier); } + Token GetBarewordsControl(char c) + { + std::string name; + name += c; + + while (it != expr.end()) { + c = *it; + if (!isalpha(c)) + break; + name += c; + it++; + } + + ControlQualifier qualifier; + qualifier.control_name = name; + return Token(TOK_CONTROL, qualifier); + } + Token NextToken() { if (it == expr.end()) @@ -152,9 +170,12 @@ public: case '+': return Token(TOK_ADD); case '`': - return GetControlQualifier(); + return GetFullyQualifiedControl(); default: - return Token(TOK_INVALID); + if (isalpha(c)) + return GetBarewordsControl(c); + else + return Token(TOK_INVALID); } } |
