Example #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);
        }
Example #2
0
        public void TestImport3()
        {
            var cwd     = Directory.GetCurrentDirectory();
            var ffn     = cwd + "/" + "../../../../UnitTestProject1/ANTLRv2.g2";
            var code    = System.IO.File.ReadAllText(ffn);
            var results = new Dictionary <string, string>();
            var imp     = new LanguageServer.Antlr2Import();

            imp.Try(ffn, code, ref results);
            var new_code = results.First().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();
        }