diff --git a/core/variant_parser.cpp b/core/variant_parser.cpp index 2d5b8925834..3c8c43f5b38 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 '"': { @@ -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 { diff --git a/core/variant_parser.h b/core/variant_parser.h index 831876705da..16d576a6b4a 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,