Наследование: ICodeParser
Пример #1
0
        public void Compile()
        {
            string testScript = "alias test {\n  echo -a Hallo $left($me, 1) $+ .\n }\nalias -l coolHu { echo -a private! }";
            TextReader reader = new StringReader(testScript);
            Parser p = new Parser();
            CodeCompileUnit result = p.Parse(reader);
            ScriptContainer container = new ScriptContainer("Extensions\\", "test");
            container.ScriptDom = result;

            // container.Compile();
        }
Пример #2
0
 public void Parse()
 {
     string testScript = "alias test {\n  echo -a Hallo $left($me, 1) $+ .\n }\nalias -l coolHu { echo -a private! }";
     StringBuilder csharpCode = new StringBuilder();
     TextReader reader = new StringReader(testScript);
     TextWriter writer = new StringWriter(csharpCode);
     Parser p = new Parser();
     CodeCompileUnit result = p.Parse(reader);
     ICodeGenerator csharpGen = new CSharpCodeProvider().CreateGenerator(writer);
     csharpGen.GenerateCodeFromCompileUnit(result, writer, null);
     Console.WriteLine(csharpCode.ToString());
     Console.Out.Flush();
 }
Пример #3
0
 /// <summary>
 /// Compiles the given msl script string to a Script instance.
 /// </summary>
 /// <param name="script">The string to interpret as a msl script.</param>
 /// <returns></returns>
 public ScriptContainer Compile(string name, string source, string binPathes)
 {
     ScriptContainer result = new ScriptContainer(binPathes, name);
     Parser mslParser = new Parser();
     mslParser.ScriptName = name;
     StringReader reader = new StringReader(source);
     CodeCompileUnit unit = mslParser.Parse(reader);
     reader.Close();
     result.ScriptDom = unit;
     result.Compile(name, this);
     return result;
 }
Пример #4
0
 /// <summary>
 /// Compiles the given msl script file to a Script instance.
 /// </summary>
 /// <param name="file">The file to compile.</param>
 /// <returns>The compiled script.</returns>
 public ScriptContainer Compile(System.IO.FileInfo file, string binPathes)
 {
     ScriptContainer result = new ScriptContainer(binPathes, file.Name);
     Parser mslParser = new Parser();
     StreamReader reader = new StreamReader(file.OpenRead(), System.Text.Encoding.Default, false);
     CodeCompileUnit unit = mslParser.Parse(reader);
     reader.Close();
     result.ScriptDom = unit;
     result.Compile(file.Name, this);
     return result;
 }