Ejemplo n.º 1
0
        public static Dictionary <string, string> ImportGrammars(List <string> args)
        {
            Dictionary <string, string> results = new Dictionary <string, string>();

            foreach (string f in args)
            {
                if (!System.IO.File.Exists(f))
                {
                    continue;
                }
                var input = System.IO.File.ReadAllText(f);
                if (f.EndsWith(".y"))
                {
                    var imp = new BisonImport();
                    imp.Try(f, input, ref results);
                }
                else if (f.EndsWith(".ebnf"))
                {
                    var imp = new W3CebnfImport();
                    imp.Try(f, input, ref results);
                }
                else if (f.EndsWith(".g2"))
                {
                    var imp = new Antlr2Import();
                    imp.Try(f, input, ref results);
                }
                else if (f.EndsWith(".g3"))
                {
                    var imp = new Antlr3Import();
                    imp.Try(f, input, ref results);
                }
            }
            return(results);
        }
Ejemplo n.º 2
0
        public void TestImport4()
        {
            var cwd     = Directory.GetCurrentDirectory();
            var ffn     = cwd + "/" + "../../../../UnitTestProject1/calc.y";
            var code    = System.IO.File.ReadAllText(ffn);
            var results = new Dictionary <string, string>();
            var imp     = new LanguageServer.BisonImport();

            imp.Try(ffn, code, ref results);
            var new_code = results.ToList()[1].Value;
            //var gold = cwd + "/" + "../../../../UnitTestProject1/ANTLRv3.g4";
            //var gold_code = System.IO.File.ReadAllText(gold);
            //if (!results.Any()) throw new Exception();
            //if (results.First().Value != gold_code) throw new Exception();
        }