| 1013 | } |
| 1014 | |
| 1015 | bool ParseFunctionDefinition(Lexeme** str, bool coroutine) |
| 1016 | { |
| 1017 | Lexeme *start = *str - 1; |
| 1018 | Lexeme *name = *str; |
| 1019 | |
| 1020 | if((*str)->type != lex_string && (*str)->type != lex_operator && !((*str)->type == lex_oparen && (*str - 1)->type == lex_auto)) |
| 1021 | { |
| 1022 | if(coroutine) |
| 1023 | ThrowError((*str)->pos, "ERROR: function name not found after return type"); |
| 1024 | else |
| 1025 | return false; |
| 1026 | } |
| 1027 | bool typeMethod = false; |
| 1028 | bool funcProperty = false; |
| 1029 | if((*str)->type == lex_operator) |
| 1030 | { |
| 1031 | (*str)++; |
| 1032 | if((*str)->type == lex_obracket) |
| 1033 | { |
| 1034 | if((*str)[1].type != lex_cbracket) |
| 1035 | ThrowError((*str)->pos, "ERROR: ']' not found after '[' in operator definition"); |
| 1036 | else |
| 1037 | (*str)++; |
| 1038 | } |
| 1039 | if((*str)->type == lex_oparen) |
| 1040 | { |
| 1041 | if((*str)[1].type != lex_cparen) |
| 1042 | ThrowError((*str)->pos, "ERROR: ')' not found after '(' in operator definition"); |
| 1043 | else |
| 1044 | (*str)++; |
| 1045 | } |
| 1046 | }else if((*str)->type == lex_string && ((*str + 1)->type == lex_colon || (*str + 1)->type == lex_point || (*str + 1)->type == lex_less)){ |
| 1047 | TypeInfo *retType = (TypeInfo*)GetSelectedType(); |
| 1048 | if(!ParseSelectType(str, true, false, true, false)) |
| 1049 | ThrowError((*str)->pos, "ERROR: class name expected before ':' or '.'"); |
| 1050 | if((*str)->type == lex_point) |
| 1051 | funcProperty = true; |
| 1052 | (*str)++; |
| 1053 | if((*str)->type != lex_string) |
| 1054 | ThrowError((*str)->pos, "ERROR: function name expected after ':' or '.'"); |
| 1055 | TypeContinue((*str)->pos); |
| 1056 | SelectTypeByPointer(retType); |
| 1057 | typeMethod = true; |
| 1058 | } |
| 1059 | char *functionName = NULL; |
| 1060 | if((*str)->type == lex_string || ((*str)->type >= lex_add && (*str)->type <= lex_in) || ((*str)->type >= lex_set && (*str)->type <= lex_xorset) || (*str)->type == lex_bitnot || (*str)->type == lex_lognot) |
| 1061 | { |
| 1062 | if((*str)->length >= NULLC_MAX_VARIABLE_NAME_LENGTH) |
| 1063 | ThrowError((*str)->pos, "ERROR: function name length is limited to 2048 symbols"); |
| 1064 | functionName = (char*)stringPool.Allocate((*str)->length + 2); |
| 1065 | memcpy(functionName, (*str)->pos, (*str)->length); |
| 1066 | if(!funcProperty) |
| 1067 | { |
| 1068 | functionName[(*str)->length] = 0; |
| 1069 | }else{ |
| 1070 | functionName[(*str)->length] = '$'; |
| 1071 | functionName[(*str)->length + 1] = 0; |
| 1072 | } |
no test coverage detected