public string?Parse(string fileName) { if (!_scanner.OpenFile(fileName)) { Console.Error.WriteLine("Could not open file: " + fileName); return(null); } _curr = _scanner.GetNextToken(); if (!P_Program()) { return(null); } // LogError("File compiled successfully!"); return(_asmFileName); }
private static IList <Tuple <string, bool> > Split(string line, int max, int min) { var lines = new List <Tuple <string, bool> >(); int nLine = (line.Length / max) + ((line.Length % max) != 0 ? 1 : 0); if (nLine == 1) { lines.Add(new Tuple <string, bool>(line, false)); return(lines); } if (line.Length < 1) { lines.Add(new Tuple <string, bool>(line, false)); } else { for (int i = 0; i < line.Length; i += (i == 0 ? max : min)) { lines.Add(new Tuple <string, bool>(line.Substring(i, Math.Min((i == 0 ? max : min), line.Length - i)), true)); } } TokensLine tempTokensLine = TokensLine.CreateVirtualLineForInsertedToken(0, line); tempTokensLine.InitializeScanState(new MultilineScanState(false, false, false, IBMCodePages.GetDotNetEncodingFromIBMCCSID(1147))); Scanner.Scanner scanner = new Scanner.Scanner(line, 0, line.Length - 1, tempTokensLine, null, false); Token t = null; int nCurLength = 0; int nSpan = max; int index = 0; bool bNextNoIndicator = false; while ((t = scanner.GetNextToken()) != null) { nCurLength += t.Length; if (nCurLength >= nSpan) { if (t.TokenFamily == TokenFamily.Whitespace || (nCurLength == nSpan)) { bNextNoIndicator = true; } nSpan += min; index++; } else if (bNextNoIndicator) { lines[index] = new Tuple <string, bool>(lines[index].Item1, false); bNextNoIndicator = false; } } return(lines); }