protected void prepareErrorDescription() { switch (ErrorType) { case "ZeroDivisionError": PositionInLine = Value.LastIndexOf("/"); break; case "TypeError": { Match noArgsMatch = functionWithoutArgsRegex.Match(Description); if (noArgsMatch.Success) { string functionName = noArgsMatch.Groups[1].Value; int argsRequired = int.Parse(noArgsMatch.Groups[2].Value); Description = $"<{functionName}> FUNCTION too less args (required {argsRequired} more)"; break; } Match functionErrorMatch = functionArguementsRegex.Match(Description); if (functionErrorMatch.Success) { int argsRequired = int.Parse(functionErrorMatch.Groups[2].Value); int argsGiven = int.Parse(functionErrorMatch.Groups[3].Value); Description = $"<{functionErrorMatch.Groups[1].Value}> FUNCTION too many args (takes {argsRequired} args only)"; break; } Match binaryOperationErrorMatch = binaryOperationArgumentsRegex.Match(Description); if (binaryOperationErrorMatch.Success) { string operation = binaryOperationErrorMatch.Groups[1].Value; string type1 = binaryOperationErrorMatch.Groups[2].Value; string type2 = binaryOperationErrorMatch.Groups[3].Value; PositionInLine = Value.LastIndexOf(operation); operation = Token.GetTokenType(operation).ToString(); VarTypes varType = VarTypes.NONE_VAR; if (StringVarTypes.TryGetValue(type1, out varType)) { type1 = varType.ToString(); } if (StringVarTypes.TryGetValue(type2, out varType)) { type2 = varType.ToString(); } Description = $"operation << {type1} {operation} {type2} >> is impossible"; break; } break; } case "NameError": { Match nameErrorMatch = nameErrorRegex.Match(Description); if (nameErrorMatch.Success) { string name = nameErrorMatch.Groups[1].Value; Description = $"<<{name}>> UNKNOWN_VAR"; PositionInLine = Value.IndexOf(name); } break; } default: break; } }
public static string GetTypeName(this VarTypes type, Assembly asm, int StructID, int dimension) { string name = ""; try { switch (type) { case VarTypes.StrucRef: name = "ref " + asm.Structures[StructID].Name; break; case VarTypes.Struct: name = asm.Structures[StructID].Name; break; case VarTypes.ArrayStruct: name = asm.Structures[StructID].Name + dimension.GetDimension(); break; case VarTypes.IntRef: name = "ref int"; break; case VarTypes.FloatRef: name = "ref float"; break; case VarTypes.StringRef: name = "ref string"; break; case VarTypes.ArrayIntRef: name = "ref int" + dimension.GetDimension(); break; case VarTypes.ArrayFloatRef: name = "ref float" + dimension.GetDimension(); break; case VarTypes.ArrayStringRef: name = "ref string" + dimension.GetDimension(); break; case VarTypes.ArrayStructRef: name = "ref " + asm.Structures[StructID].Name + dimension.GetDimension(); break; case VarTypes.ArrayInt: name = "int" + dimension.GetDimension(); break; case VarTypes.ArrayFloat: name = "float" + dimension.GetDimension(); break; case VarTypes.ArrayString: name = "string" + dimension.GetDimension(); break; case VarTypes.ArrayBool: name = "bool" + dimension.GetDimension(); break; case VarTypes.ArrayDelegate: name = "delegate" + dimension.GetDimension(); break; default: name = type.ToString().ToLower(); break; } } catch { name = type.ToString().ToLower(); } return(name); }