コード例 #1
0
ファイル: Program.cs プロジェクト: dlurton/Happy
 static HappyRuntimeContext compileModule(string filename)
 {
     HappyRuntimeContext hrc = new HappyRuntimeContext(Console.Out);
     try
     {
         Action<HappyRuntimeContext> runtimeContextInitializer = HappyCompiler.CompileModule(filename);
         runtimeContextInitializer(hrc);
     }
     catch (SourceException e)
     {
         throw new FatalException(string.Format("{0}: {1}", e.Location.Span.Start, e.Message));
     }
     catch (SyntaxErrorException se)
     {
         throw new FatalException(se.Message);
     }
     return hrc;
 }
コード例 #2
0
ファイル: TestFixtureBase.cs プロジェクト: dlurton/Happy
        protected HappyRuntimeContext CompileModule(string script)
        {
            HappyRuntimeContext retval = new HappyRuntimeContext(new StringWriter());
            var ss = Engine.CreateScriptSourceFromString(script, "<unit test>", SourceCodeKind.File);
            dynamic runtimeContextInitializer = ss.Execute();

            runtimeContextInitializer(retval);
            return retval;
        }