Example #1
0
        static int ParseFile(string rel, string source, string dest)
        {
            var grammar = new GSCGrammar();
            var parser = new Parser(grammar);
            var compiler = new ScriptCompiler(parser.Parse(File.ReadAllText(source)), dest);

            int result = (compiler.Init(rel) ? 1 : 0);

            using (var writer = File.Create(dest))
            {
                writer.Write(compiler.Compiled, 0, compiler.Compiled.Length);
                writer.Dispose();
            }

            return result;
        }
Example #2
0
        static void ParseSingleFile(string file)
        {
            string dest = file.Substring(file.LastIndexOfAny(new char[] { '/', '\\' }) + 1);
            string destPath = Path.GetFileNameWithoutExtension(file) + "-compiled.gsc";

            var grammar = new GSCGrammar();
            var parser = new Parser(grammar);
            var compiler = new ScriptCompiler(parser.Parse(File.ReadAllText(file)), dest);

            if (compiler.Init(dest.Substring(0, dest.IndexOf(".")), true))
            {
                using (var writer = File.Create(destPath))
                {
                    writer.Write(compiler.Compiled, 0, compiler.Compiled.Length);
                    writer.Dispose();
                }
            }
        }