// TrimStart is ignored! public override void handleMultilineComment(Cache.Cache compiler, int startIndex = 0) { string line = ""; int CurrentLine = 0; for (CurrentLine = compiler.CurrentLine; compiler.LineCount >= CurrentLine; CurrentLine++) { if (!compiler.GetLine(CurrentLine, ref line)) { throw new IndexOutOfRangeException("Line is out of expected code range in EvenMessierTranslator.handleMultilineComment"); } if (CurrentLine == compiler.CurrentLine) { if (startIndex != 0) { line = SubString(line, startIndex); } } line = line.TrimStart(); if (line.Contains("*/")) { var i = line.IndexOf("*/") + 2; compiler.CurrentLine = CurrentLine - 1; compiler.offsetIndex = i; var s = SubString(line, 0, i - 2); if (s == "*/") { compiler.WriteLine(" " + s); } else { var str = SubString(line, i); ParseCS_String(str, str.Trim(), str.TrimStart(), compiler); } compiler.CurrentLine = CurrentLine; break; } else { compiler.WriteLine(" " + line); } } }
private void ParseCS_String(string line, string trim, string trims, Cache.Cache compiler) { compiler.Logger.Info.WriteLine(this, compiler, "Parsing string: " + trims); // Check if line is empty of whitespaced if (string.IsNullOrWhiteSpace(trim)) { var lastLine = ""; if (compiler.GetLine(compiler.CurrentLine - 1, ref lastLine)) { if (!string.IsNullOrWhiteSpace(lastLine) || _tSet.Syntax.IgnoreBetweenWhitespace) { // Whitespaced line, append new line with correct tabulation/whitespace. compiler.WriteLine("", true); return; } } return; } // Check if string starts with a single line comment if (trims.StartsWith("//")) { compiler.WriteLine(trims, true); return; } // Check if line contains a multi-line comment if (trims.Contains("/*")) { if (!trims.StartsWith("/*")) { // Get index of the first occurence of /* int i = trims.IndexOf("/*"); string code = SubString(trims, 0, i); ParseCS_String(code, code.Trim(), code.TrimStart(), compiler); this.handleMultilineComment(compiler, i); } else { this.handleMultilineComment(compiler, 0); } return; } // Check if line contains braces if (trims.Contains("{") || trims.Contains("}")) { HandleBraces(compiler); return; } // Check if the line does not contain a // semi-colon If it does not exist bitch about it // because there is no reason it should not be there // mainly for debuggin and syntax checking? //if (!trims.Contains(";")) // throw new Exception("U WOT M8, U GOT NO ;... DO YOU THINK THIS A GAME????"); // Check if the line contains more than one semi-colons string[] lines = trims.Split(';'); if (lines.Length - 1 >= 1) { foreach (string x in lines) { ParseCS_String(x, x.Trim(), x.TrimStart(), compiler); } return; } // Now we print our code compiler.WriteLine(trims); }