Example #1
0
 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;
 }
Example #2
0
        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;
        }