/// <summary> /// Prints to the console. /// </summary> /// /// <param name="settings">Settings for interpreter</param> /// <param name="exp">The functiona call expression</param> /// <param name="printline">Whether to print with line or no line</param> public static string Print(LangSettings settings, FunctionCallExpr exp, bool printline) { if (!settings.EnablePrinting) return string.Empty; string message = BuildMessage(exp.ParamList); if (printline) Console.WriteLine(message); else Console.Write(message); return message; }
/// <summary> /// Logs severity to console. /// </summary> /// <param name="settings">Settings for interpreter</param> /// <param name="exp">The functiona call expression</param> public static string Log(LangSettings settings, FunctionCallExpr exp) { if (!settings.EnableLogging) return string.Empty; var funcname = exp.ToQualifiedName(); var severity =funcname.Substring(funcname.IndexOf(".") + 1); var message = BuildMessage(exp.ParamList); Console.WriteLine(severity.ToUpper() + " : " + message); return message; }
/// <summary> /// Initialize /// </summary> public Interpreter() { _settings = new LangSettings(); // Initialzie the context. _context = new Context(); _context.Settings = _settings; _context.Limits.Init(); _memory = _context.Memory; _parser = new Parser(_context); _parser.Settings = _settings; InitSystemFunctions(); }
private object RunCompilerMethod(string objectName, string method, LangSettings settings, FunctionCallExpr ex) { var metaCompiler = new MetaCompiler(); metaCompiler.Ctx = ex.Ctx; if(method == "ToConstDate") { } else if(method == "ToConstTime") { } else if(method == "ToConstDateTimeToken") { var dateToken = ex.ParamList[0] as TokenData; var timeToken = ex.ParamList[1] as TokenData; return metaCompiler.ToConstDateTimeToken(dateToken, timeToken); } else if (method == "ToConstDay") { var token = ex.ParamList[0] as TokenData; var day = Convert.ToInt32(ex.ParamList[1]); return metaCompiler.ToConstDay(day, token); } return LObjects.Null; }