9 using System.Collections.Generic;
12 using System.Threading.Tasks;
13 using System.Text.RegularExpressions;
20 private static void Main(
string[] args)
26 string CSNamespace =
"";
30 StreamReader SourceFile;
31 StreamWriter DestinationFile;
34 Console.ForegroundColor = ConsoleColor.DarkGreen;
39 if ((args.Length != 4) || (args[0] !=
"-i" && args[0] !=
"-o") || ((args[0] ==
"-i" && args[2] !=
"-o") && (args[0] ==
"-o" && args[2] !=
"-i")))
41 Console.ForegroundColor = ConsoleColor.Red;
42 Console.WriteLine(
"[Invalid command line input]");
43 Console.WriteLine(
"CCSPortWizard -i inputfile.c -o outputfile.cs");
44 Console.ForegroundColor = ConsoleColor.White;
47 Console.WriteLine(
"[INPUT COMMAND VALID...]");
52 if (args[2] ==
"-o") { DestinationIndex = 3; SourceIndex = 1; Console.WriteLine(
"[OUTPUT COMMAND VALID...]"); }
53 else { DestinationIndex = 1; SourceIndex = 3; }
58 SyntaxMatch = Regex.Match(args[DestinationIndex],
@"(\w+).cs");
59 if (SyntaxMatch.Success) { CSNamespace = SyntaxMatch.Groups[1].Value; Console.WriteLine(
"[OUTPUT FILE VALID...]"); }
60 else { Console.WriteLine(
@"Specific destination filename is not a valid "".cs"" file"); }
67 SourceFile =
new StreamReader(args[SourceIndex]);
68 DestinationFile =
new StreamWriter(args[DestinationIndex]);
72 bool SyntaxMainScan =
false;
74 InputLines = String.Empty;
79 while ((InputLines = SourceFile.ReadLine()) != null)
88 DestinationFile.WriteLine(InputLines);
89 SyntaxMainScan =
true;
96 if (SyntaxMainScan) { DestinationFile.WriteLine(
"\t\t" + InputLines); }
97 else { DestinationFile.WriteLine(InputLines); }
99 InputLines = String.Empty;
107 DestinationFile.WriteLine(
"\t}");
108 DestinationFile.WriteLine(
"}");
115 DestinationFile.Close();
116 Console.WriteLine(
"[TRANSPOSE COMPLETE...]");
120 Console.ForegroundColor = ConsoleColor.Red;
121 Console.WriteLine(
"[TRANSPOSE ERROR!]");
122 Console.WriteLine(ex.Message);
124 Console.ForegroundColor = ConsoleColor.White;
bool SyntaxScan(ref string codeLine)
This method scan each line of object c code and transpose it to c-sharp
static void Main(string[] args)