Allowing back WML variables to contain spaces.

Not that I like it, but it did break too much stuff.
This commit is contained in:
Philippe Plantier 2005-03-28 12:29:10 +00:00
parent 0e25bf2c69
commit ba438e512f
3 changed files with 22 additions and 9 deletions

View File

@ -15,7 +15,6 @@
#define MAP_H_INCLUDED
class config;
class vconfig;
#include "terrain.hpp"

View File

@ -203,16 +203,28 @@ void parser::parse_variable()
{
config& cfg = *elements.top().cfg;
std::vector<std::string> variables;
variables.push_back(tok_.current_token().value);
tok_.next_token();
variables.push_back("");
while (tok_.current_token().type != '=') {
if (tok_.current_token().type != ',')
switch(tok_.current_token().type) {
case token::STRING:
if(!variables.back().empty())
variables.back() += ' ';
variables.back() += tok_.current_token().value;
break;
case ',':
if(variables.back().empty()) {
// FIXME: this error message is not really
// appropriate, although a proper one should
// wait after string freeze.
error(_("Unexpected characters after variable name (expected , or =)"));
variables.push_back("");
}
break;
default:
error(_("Unexpected characters after variable name (expected , or =)"));
tok_.next_token();
if (tok_.current_token().type != token::STRING)
error(_("Invalid variable name"));
variables.push_back(tok_.current_token().value);
break;
}
tok_.next_token();
}

View File

@ -84,7 +84,7 @@ const token& tokenizer::next_token()
token_.value += current_;
};
break;
case '[': case ']': case '/': case '\n': case '=': case ',': case '+': case '_':
case '[': case ']': case '/': case '\n': case '=': case ',': case '+':
token_.type = token::token_type(current_);
token_.value = current_;
break;
@ -100,6 +100,8 @@ const token& tokenizer::next_token()
token_.type = token::MISC;
token_.value += current_;
}
if(token_.value == "_")
token_.type = token::token_type('_');
}
if(current_ != EOF)