Parse any IDL type.
| 795 | |
| 796 | // Parse any IDL type. |
| 797 | CheckedError Parser::ParseType(Type &type) { |
| 798 | if (token_ == kTokenIdentifier) { |
| 799 | if (IsIdent("bool")) { |
| 800 | type.base_type = BASE_TYPE_BOOL; |
| 801 | NEXT(); |
| 802 | } else if (IsIdent("byte") || IsIdent("int8")) { |
| 803 | type.base_type = BASE_TYPE_CHAR; |
| 804 | NEXT(); |
| 805 | } else if (IsIdent("ubyte") || IsIdent("uint8")) { |
| 806 | type.base_type = BASE_TYPE_UCHAR; |
| 807 | NEXT(); |
| 808 | } else if (IsIdent("short") || IsIdent("int16")) { |
| 809 | type.base_type = BASE_TYPE_SHORT; |
| 810 | NEXT(); |
| 811 | } else if (IsIdent("ushort") || IsIdent("uint16")) { |
| 812 | type.base_type = BASE_TYPE_USHORT; |
| 813 | NEXT(); |
| 814 | } else if (IsIdent("int") || IsIdent("int32")) { |
| 815 | type.base_type = BASE_TYPE_INT; |
| 816 | NEXT(); |
| 817 | } else if (IsIdent("uint") || IsIdent("uint32")) { |
| 818 | type.base_type = BASE_TYPE_UINT; |
| 819 | NEXT(); |
| 820 | } else if (IsIdent("long") || IsIdent("int64")) { |
| 821 | type.base_type = BASE_TYPE_LONG; |
| 822 | NEXT(); |
| 823 | } else if (IsIdent("ulong") || IsIdent("uint64")) { |
| 824 | type.base_type = BASE_TYPE_ULONG; |
| 825 | NEXT(); |
| 826 | } else if (IsIdent("float") || IsIdent("float32")) { |
| 827 | type.base_type = BASE_TYPE_FLOAT; |
| 828 | NEXT(); |
| 829 | } else if (IsIdent("double") || IsIdent("float64")) { |
| 830 | type.base_type = BASE_TYPE_DOUBLE; |
| 831 | NEXT(); |
| 832 | } else if (IsIdent("string")) { |
| 833 | type.base_type = BASE_TYPE_STRING; |
| 834 | NEXT(); |
| 835 | } else { |
| 836 | ECHECK(ParseTypeIdent(type)); |
| 837 | } |
| 838 | } else if (token_ == '[') { |
| 839 | ParseDepthGuard depth_guard(this); |
| 840 | ECHECK(depth_guard.Check()); |
| 841 | NEXT(); |
| 842 | Type subtype; |
| 843 | ECHECK(ParseType(subtype)); |
| 844 | if (IsSeries(subtype)) { |
| 845 | // We could support this, but it will complicate things, and it's |
| 846 | // easier to work around with a struct around the inner vector. |
| 847 | return Error("nested vector types not supported (wrap in table first)"); |
| 848 | } |
| 849 | if (token_ == ':') { |
| 850 | NEXT(); |
| 851 | if (token_ != kTokenIntegerConstant) { |
| 852 | return Error("length of fixed-length array must be an integer value"); |
| 853 | } |
| 854 | uint16_t fixed_length = 0; |