public void DeepDumpFile() { var stuff = new BnfParser("JpegBnf.txt"); var dict = stuff.Dict; var allTokens = DumpBlock("<jpeg_data>", dict); var procTokens = new HashSet <string>(); while (!allTokens.SetEquals(procTokens)) { var temp = new HashSet <string>(allTokens); temp.ExceptWith(procTokens); foreach (var tt in temp) { var blocks = DumpBlock(tt, dict); allTokens.UnionWith(blocks); procTokens.Add(tt); } } Console.WriteLine("======= Proc Tokens"); foreach (var x in procTokens) { Console.WriteLine(x); } }
public void CheckFile() { var stuff = new BnfParser("JpegBnf.txt"); var dict = stuff.Dict; foreach (var pair in dict) { foreach (var line in pair.Value.Lines) { var x = line.Split(' '); foreach (var y in x) { var token = y.Trim(); if (token == "|" || token == "…" || token == "ϵ" || token.StartsWith("BY") || token.EndsWith("()")) { continue; } if (token.StartsWith("<") && token.EndsWith(">")) { Assert.IsTrue(dict.ContainsKey(token), $"Token {token} not found"); } else { Console.WriteLine("{0} → {1} ==> {2}", pair.Key, line, token); } } } } }
public void DumpJpeg() { var stuff = new BnfParser("JpegBnf.txt"); var dict = stuff.Dict; var key = "<jpeg_data>"; var data = dict[key]; var index = 0; foreach (var line in data.Lines) { Console.WriteLine("{0} : {1} → {2}", index++, key, line); } }
public void DumpFile() { var stuff = new BnfParser("JpegBnf.txt"); var dict = stuff.Dict; foreach (var pair in dict) { var index = 0; foreach (var line in pair.Value.Lines) { if (index++ == 0) { Console.WriteLine("{0} → {1}", pair.Key, line); } else { var blank = "".PadRight(pair.Key.Length); Console.WriteLine("{0} | {1}", blank, line); } } } }