public IEnumerator ParseRoot(string source, Action <ParsedTree> parsed) { var lines = source.Replace("\r\n", "\n").Split('\n'); for (var i = 0; i < lines.Length; i++) { lines[i] = lines[i].TrimStart(); } var root = new ParsedTree(); parseFailed = (code, reason) => { root.errors.Add(new ParseError(code, reason)); }; var cor = Parse(root, string.Join(string.Empty, lines)); while (cor.MoveNext()) { yield return(null); } // defaultImageLoaderはHTMLParserに依存しているのでここで読み込み完了まで待つ while (defaultImageDownloader.IsRunning()) { yield return(null); } parsed(root); }
public IEnumerator ParseRoot(string source, Action <ParsedTree> parsed) { var lines = source.Replace("\r\n", "\n").Split('\n'); for (var i = 0; i < lines.Length; i++) { lines[i] = lines[i].TrimStart(); } var root = new ParsedTree(); parseFailed = (code, reason) => { root.errors.Add(new ParseError(code, reason)); }; var cor = Parse(root, string.Join(string.Empty, lines)); while (cor.MoveNext()) { yield return(null); } parsed(root); }
public static string ShowErrors(ParsedTree tree) { var stringBuilder = new StringBuilder(); foreach (var error in tree.errors) { stringBuilder.AppendLine("error code:" + error.code + " reason:" + error.reason); } return(stringBuilder.ToString()); }