public CanCauseError Apply(string[] parameters, IDirectivePreprocessor host) { switch (parameters[0]) { case "hailthelord": host.Input.AddNewLine("MESSAGE Praise Nintenlord!"); break; case "hextator": host.Input.AddNewLine("MESSAGE hexpotato"); break; case "feditor": host.Input.AddNewLine("MESSAGE FE_Editor"); break; case "baldur": case "tordo": host.Input.AddNewLine("MESSAGE The proyect is dead? Reply soon. :)"); break; case "incest": host.Input.AddNewLine("MESSAGE incext? Are you sure you didn't mean incest?"); break; case "proyect": host.Input.AddNewLine("MESSAGE soon"); break; default: break; } return(CanCauseError.NoError); }
public CanCauseError Apply(string[] parameters, IDirectivePreprocessor host) { CanCauseError canCauseError; if (parameters.Length > 1) { int length = parameters[0].IndexOf('('); int num = parameters[0].LastIndexOf(')'); string[] strArray; string name; if (length != -1 && num != -1 && length < num) { strArray = parameters[0].Substring(length + 1, num - length - 1).Split(macroSeparators, uniters); name = parameters[0].Substring(0, length); } else { strArray = new string[0]; name = parameters[0]; } for (int index = 0; index < strArray.Length; ++index) { strArray[index] = strArray[index].Trim(); } if (name.Equals(parameters[1])) { canCauseError = CanCauseError.Error("Defining something as itself. "); } else if (!host.DefCol.IsValidName(name)) { canCauseError = CanCauseError.Error(name + " is not valid name to define."); } else if (host.IsValidToDefine(name)) { canCauseError = CanCauseError.Error(name + " cannot be redefined."); } else { if (host.DefCol.ContainsName(name, strArray)) { host.Log.AddWarning(host.Input.GetPositionString() + ", Warning: Redefining " + name); host.DefCol.Remove(name, strArray); } host.DefCol.Add(name, parameters[1].Trim('"'), strArray); canCauseError = CanCauseError.NoError; } } else if (parameters.Length == 1) { host.DefCol.Add(parameters[0], ""); canCauseError = CanCauseError.NoError; } else { canCauseError = CanCauseError.NoError; } return(canCauseError); }
public CanCauseError Apply(string[] parameters, IDirectivePreprocessor host) { foreach (string parameter in parameters) { host.DefCol.Remove(parameter); } return(CanCauseError.NoError); }
public CanCauseError Apply(string[] parameters, IDirectivePreprocessor host) { foreach (var item in parameters) { host.DefCol.Remove(item); } return CanCauseError.NoError; }
public CanCauseError Apply(string[] parameters, IDirectivePreprocessor host) { if (host.Include.Count <= 0) { return(CanCauseError.Error("#endif used without #ifdef or #ifndef.")); } host.Include.Pop(); return(CanCauseError.NoError); }
public override CanCauseError ApplyIncludeTool(byte[] toolOutput, IDirectivePreprocessor host) { foreach (string line in Encoding.UTF8.GetString(toolOutput).Split(new string[] { Environment.NewLine }, StringSplitOptions.None)) { host.Log.AddMessage(line); } return(CanCauseError.NoError); }
public override CanCauseError ApplyIncludeTool(byte[] toolOutput, IDirectivePreprocessor host) { string eventCode = Encoding.UTF8.GetString(toolOutput); string[] lines = eventCode.Split(new string[] { Environment.NewLine }, StringSplitOptions.None); host.Input.AddNewLines(lines); return(CanCauseError.NoError); }
public CanCauseError Apply(string[] parameters, IDirectivePreprocessor host) { if (host.Include.Count <= 0) { return(CanCauseError.Error("#else before any #ifdef or #ifndef.")); } bool flag = host.Include.Pop(); host.Include.Push(!flag); return(CanCauseError.NoError); }
public CanCauseError Apply(string[] parameters, IDirectivePreprocessor host) { if (host.Include.Count > 0) { host.Include.Pop(); return CanCauseError.NoError; } else { return CanCauseError.Error("#endif used without #ifdef or #ifndef."); } }
public CanCauseError Apply(string[] parameters, IDirectivePreprocessor host) { /* * for (int i=1; i<parameters.Length; i++) * { * CanCauseError<string> res = host.DefCol.ApplyDefines(parameters[i]); * if (!res.CausedError) * parameters[i] = res.Result; * }*/ string file = IO.IOHelpers.FindFile(host.Input.CurrentFile, getFileName(parameters[0])); if (file.Length <= 0) { return(CanCauseError.Error("Tool " + parameters[0] + " not found.")); } //from http://stackoverflow.com/a/206347/1644720 // Start the child process. System.Diagnostics.Process p = new System.Diagnostics.Process(); // Redirect the output stream of the child process. p.StartInfo.WorkingDirectory = Path.GetDirectoryName(host.Input.CurrentFile); p.StartInfo.UseShellExecute = false; p.StartInfo.RedirectStandardOutput = true; p.StartInfo.CreateNoWindow = true; p.StartInfo.FileName = file; string[] passedParams = parameters.GetRange(1); for (int i = 0; i < passedParams.Length; i++) { if (passedParams[i].ContainsWhiteSpace()) { passedParams[i] = "\"" + passedParams[i] + "\""; } } p.StartInfo.Arguments = passedParams.ToElementWiseString(" ", "", " --to-stdout"); p.Start(); // Do not wait for the child process to exit before // reading to the end of its redirected stream. // p.WaitForExit(); // Read the output stream first and then wait. MemoryStream outputBytes = new MemoryStream(); p.StandardOutput.BaseStream.CopyTo(outputBytes); p.WaitForExit(); byte[] output = outputBytes.GetBuffer().GetRange(0, (int)outputBytes.Length); if (output.Length >= 7 && Encoding.ASCII.GetString(output.GetRange(0, 7)) == "ERROR: ") { return(CanCauseError.Error(Encoding.ASCII.GetString(output.GetRange(7)))); } host.Input.AddBytes(output); return(CanCauseError.NoError); }
public CanCauseError Apply(string[] parameters, IDirectivePreprocessor host) { string file = Nintenlord.Event_Assembler.Core.IO.IOHelpers.FindFile(host.Input.CurrentFile, parameters[0]); if (file.Length > 0) { host.Input.OpenSourceFile(file); return CanCauseError.NoError; } else { return CanCauseError.Error("File " + parameters[0] + " not found."); } }
public CanCauseError Apply(string[] parameters, IDirectivePreprocessor host) { if (host.Include.Count > 0) { bool toFlip = host.Include.Pop(); host.Include.Push(!toFlip); return CanCauseError.NoError; } else { return CanCauseError.Error("#else before any #ifdef or #ifndef."); } }
public CanCauseError Apply(string[] parameters, IDirectivePreprocessor host) { bool toPush = false; foreach (var item in parameters) { if (!host.DefCol.ContainsName(item)) { toPush = true; break; } } host.Include.Push(toPush); return CanCauseError.NoError; }
public CanCauseError Apply(string[] parameters, IDirectivePreprocessor host) { bool flag = false; foreach (string parameter in parameters) { if (!host.DefCol.ContainsName(parameter) && !host.IsPredefined(parameter)) { flag = true; break; } } host.Include.Push(flag); return(CanCauseError.NoError); }
public CanCauseError Apply(string[] parameters, IDirectivePreprocessor host) { string file = IOHelpers.FindFile(host.Input.CurrentFile, parameters [0]); if (file.Length <= 0) { if (!host.IncludeListener.AllowsMissingFiles()) { return(CanCauseError.Error("File " + parameters [0] + " not found.")); } file = IOHelpers.GetPrefferedFileName(host.Input.CurrentFile, parameters [0]); } else { host.Input.OpenSourceFile(file); } host.IncludeListener.IncludeTextFile(file); return(CanCauseError.NoError); }
public CanCauseError Apply(string[] parameters, IDirectivePreprocessor host) { CanCauseError result; if (parameters.Length > 1) { string[] macroParam; string mname; int startIndex = parameters[0].IndexOf('('); int endIndex = parameters[0].LastIndexOf(')'); if (startIndex != -1 && endIndex != -1 && startIndex < endIndex) { string paramString = parameters[0].Substring( startIndex + 1, endIndex - startIndex - 1); macroParam = paramString.Split(macroSeparators, uniters); mname = parameters[0].Substring(0, startIndex); } else { macroParam = new string[0]; mname = parameters[0]; } for (int j = 0; j < macroParam.Length; j++) { macroParam[j] = macroParam[j].Trim(); } if (mname.Equals(parameters[1])) { //Should be a warning. result = CanCauseError.Error("Defining something as itself. "); } else if (!host.DefCol.IsValidName(mname)) { result = CanCauseError.Error(mname + " is not valid name to define."); } else if (host.IsValidToDefine(mname)) { result = CanCauseError.Error(mname + " cannot be redefined."); } else { if (host.DefCol.ContainsName(mname, macroParam)) { //Should be a warning. result = CanCauseError.Error("Redefining " + mname); } else { result = CanCauseError.NoError; } host.DefCol.Add(mname, parameters[1].Trim('"'), macroParam); } } else if (parameters.Length == 1) { host.DefCol.Add(parameters[0], ""); result = CanCauseError.NoError; } else result = CanCauseError.NoError; return result; }
public override CanCauseError ApplyIncludeTool(byte[] toolOutput, IDirectivePreprocessor host) { host.Input.AddBytes(toolOutput); return(CanCauseError.NoError); }
public abstract CanCauseError ApplyIncludeTool(byte[] toolOutput, IDirectivePreprocessor host);
public CanCauseError Apply(string[] parameters, IDirectivePreprocessor host) { host.Input.AddNewLines(host.Pool.DumpPool()); return CanCauseError.NoError; }
public CanCauseError Apply(string[] parameters, IDirectivePreprocessor host) { string fileName = IO.IOHelpers.FindFile(host.Input.CurrentFile, GetToolFileName(parameters[0])); if (fileName.Length <= 0) { return(CanCauseError.Error("Tool " + parameters[0] + " not found.")); } // Based on http://stackoverflow.com/a/206347/1644720 // Start the child process. System.Diagnostics.Process process = new System.Diagnostics.Process(); process.StartInfo.WorkingDirectory = Path.GetDirectoryName(host.Input.CurrentFile); process.StartInfo.UseShellExecute = false; process.StartInfo.CreateNoWindow = true; process.StartInfo.FileName = fileName; // Redirect the output stream of the child process. process.StartInfo.RedirectStandardOutput = true; process.StartInfo.RedirectStandardError = true; string[] passedParams = parameters.GetRange(1); for (int i = 0; i < passedParams.Length; i++) { if (passedParams[i].ContainsWhiteSpace()) { passedParams[i] = "\"" + passedParams[i] + "\""; } } process.StartInfo.Arguments = passedParams.ToElementWiseString(" ", "", " --to-stdout"); process.Start(); // Do not wait for the child process to exit before // reading to the end of its redirected stream. // p.WaitForExit(); // Read the output stream first and then wait. MemoryStream outputBytes = new MemoryStream(); process.StandardOutput.BaseStream.CopyTo(outputBytes); MemoryStream errorBytes = new MemoryStream(); process.StandardError.BaseStream.CopyTo(errorBytes); process.WaitForExit(); // For tools that err using stderr if (errorBytes.Length > 0) { return(CanCauseError.Error(Encoding.ASCII.GetString(errorBytes.GetBuffer()))); } // For tools that err using stdout and "ERROR: ..." byte[] output = outputBytes.GetBuffer().GetRange(0, (int)outputBytes.Length); if (output.Length >= 7 && Encoding.ASCII.GetString(output.GetRange(0, 7)) == "ERROR: ") { return(CanCauseError.Error(Encoding.ASCII.GetString(output.GetRange(7)))); } return(ApplyIncludeTool(output, host)); }
public CanCauseError Apply(string[] parameters, IDirectivePreprocessor host) { host.Input.AddNewLines((IEnumerable <string>)host.Pool.DumpPool()); return(CanCauseError.NoError); }