/// <summary> /// The method that represents the 'read' function in the language. /// Reads in a string and converts it into the most suitable TType. /// If the string cannot be converted, it just returns the string as a TString. /// </summary> /// <param name="interpreter">The interpreter that the method is being called from.</param> /// <param name="args">The arguments being passed to the function as a TArgumentList.</param> /// <returns>An TType of the type that the entered string represents best.</returns> public static TType Read(Interpreter interpreter, TArgumentList args) { // Read in a string and convert it to a suitable TType with TType.Parse. string str = System.Console.ReadLine(); TType value = TType.Parse(interpreter, str); if (value is TException) { value = new TString(str); // If the string can't be parsed, return it as a TString } return(value); }