Esempio n. 1
0
        public static byte[] Compile(string rel, string source)
        {
            var grammar  = new GSCGrammar();
            var parser   = new Parser(grammar);
            var compiler = new ScriptCompiler(parser.Parse(source));

            if (!compiler.Init(rel, true))
            {
                return(null);
            }

            return(compiler.Compiled);
        }
Esempio n. 2
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;
        }
Esempio n. 3
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)));

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

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

            return(result);
        }
Esempio n. 4
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();
                }
            }
        }
Esempio n. 5
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)));

            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();
                }
            }
        }