suport old-style engine.cfg colors in VariantParser, fixes #3176

This commit is contained in:
Juan Linietsky 2015-12-31 14:30:50 -03:00
parent ff1763e38f
commit bc2b1696e6
2 changed files with 29 additions and 0 deletions

View file

@ -49,6 +49,7 @@ const char * VariantParser::tk_name[TK_MAX] = {
"identifier",
"string",
"number",
"color",
"':'",
"','",
"'='",
@ -144,6 +145,29 @@ Error VariantParser::get_token(Stream *p_stream, Token& r_token, int &line, Stri
r_token.type=TK_EQUAL;
return OK;
};
case '#': {
String color_str="#";
while(true) {
CharType ch=p_stream->get_char();
if (p_stream->is_eof()) {
r_token.type=TK_EOF;
return OK;
} else if ( (ch>='0' && ch<='9') || (ch>='a' && ch<='f') || (ch>='A' && ch<='F') ) {
color_str+=String::chr(ch);
} else {
p_stream->saved=ch;
break;
}
}
r_token.value=Color::html(color_str);
r_token.type=TK_COLOR;
return OK;
};
case '"': {
@ -1369,6 +1393,10 @@ Error VariantParser::parse_value(Token& token,Variant &value,Stream *p_stream,in
return OK;
} else if (token.type==TK_STRING) {
value=token.value;
return OK;
} else if (token.type==TK_COLOR) {
value=token.value;
return OK;
} else {

View file

@ -66,6 +66,7 @@ public:
TK_IDENTIFIER,
TK_STRING,
TK_NUMBER,
TK_COLOR,
TK_COLON,
TK_COMMA,
TK_EQUAL,