diff options
author | Juan Linietsky <reduzio@gmail.com> | 2015-12-31 14:30:50 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2015-12-31 14:30:50 -0300 |
commit | bc2b1696e6bbe2cd50c65be81ee2bed71ea7cf9e (patch) | |
tree | 070d4530036da0b1504d681ba3bc2ef19c4260ff | |
parent | ff1763e38f5ded25a5a3b19d739757bb6d2c44ac (diff) |
suport old-style engine.cfg colors in VariantParser, fixes #3176
-rw-r--r-- | core/variant_parser.cpp | 28 | ||||
-rw-r--r-- | core/variant_parser.h | 1 |
2 files changed, 29 insertions, 0 deletions
diff --git a/core/variant_parser.cpp b/core/variant_parser.cpp index 2d5b892583..3c8c43f5b3 100644 --- a/core/variant_parser.cpp +++ b/core/variant_parser.cpp @@ -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 '"': { @@ -1371,6 +1395,10 @@ Error VariantParser::parse_value(Token& token,Variant &value,Stream *p_stream,in value=token.value; return OK; + } else if (token.type==TK_COLOR) { + + value=token.value; + return OK; } else { r_err_str="Expected value, got "+String(tk_name[token.type])+"."; return ERR_PARSE_ERROR; diff --git a/core/variant_parser.h b/core/variant_parser.h index 831876705d..16d576a6b4 100644 --- a/core/variant_parser.h +++ b/core/variant_parser.h @@ -66,6 +66,7 @@ public: TK_IDENTIFIER, TK_STRING, TK_NUMBER, + TK_COLOR, TK_COLON, TK_COMMA, TK_EQUAL, |