| 683 | } |
| 684 | |
| 685 | Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream, int &line, String &r_err_str, ResourceParser *p_res_parser, bool p_allow_objects) { |
| 686 | if (token.type == TK_CURLY_BRACKET_OPEN) { |
| 687 | Dictionary d; |
| 688 | Error err = _parse_dictionary(d, p_stream, line, r_err_str, p_res_parser, p_allow_objects); |
| 689 | if (err) { |
| 690 | return err; |
| 691 | } |
| 692 | value = d; |
| 693 | return OK; |
| 694 | } else if (token.type == TK_BRACKET_OPEN) { |
| 695 | Array a; |
| 696 | Error err = _parse_array(a, p_stream, line, r_err_str, p_res_parser, p_allow_objects); |
| 697 | if (err) { |
| 698 | return err; |
| 699 | } |
| 700 | value = a; |
| 701 | return OK; |
| 702 | } else if (token.type == TK_IDENTIFIER) { |
| 703 | String id = token.value; |
| 704 | if (id == "true") { |
| 705 | value = true; |
| 706 | } else if (id == "false") { |
| 707 | value = false; |
| 708 | } else if (id == "null" || id == "nil") { |
| 709 | value = Variant(); |
| 710 | } else if (id == "inf") { |
| 711 | value = Math::INF; |
| 712 | } else if (id == "-inf" || id == "inf_neg") { |
| 713 | // inf_neg kept for compatibility. |
| 714 | value = -Math::INF; |
| 715 | } else if (id == "nan") { |
| 716 | value = Math::NaN; |
| 717 | } else if (id == "Variant") { |
| 718 | Error err = get_token(p_stream, token, line, r_err_str); |
| 719 | if (err) { |
| 720 | return err; |
| 721 | } |
| 722 | if (token.type != TK_COLON) { |
| 723 | r_err_str = "Expected '::' after 'Variant'"; |
| 724 | return ERR_PARSE_ERROR; |
| 725 | } |
| 726 | |
| 727 | err = get_token(p_stream, token, line, r_err_str); |
| 728 | if (err) { |
| 729 | return err; |
| 730 | } |
| 731 | if (token.type != TK_COLON) { |
| 732 | r_err_str = "Expected '::' after 'Variant'"; |
| 733 | return ERR_PARSE_ERROR; |
| 734 | } |
| 735 | |
| 736 | err = get_token(p_stream, token, line, r_err_str); |
| 737 | if (err) { |
| 738 | return err; |
| 739 | } |
| 740 | |
| 741 | if (token.type != TK_IDENTIFIER) { |
| 742 | r_err_str = "Expected identifier after 'Variant::'"; |
nothing calls this directly
no test coverage detected