/// <summary> /// Gets the compilation unit for this test /// </summary> /// <returns>The compilation unit</returns> public override Unit GetUnit(string fixture) { Hime.SDK.Input.Loader loader = new Hime.SDK.Input.Loader(); loader.AddInput(node.Children[1], originalInput); return(new Unit( loader.Load()[0], "", Mode.Assembly, (ParsingMethod)Enum.Parse(typeof(ParsingMethod), node.Children[2].Value), "Hime.Tests.Generated." + fixture, Modifier.Public)); }
/// <summary> /// Initializes a new compilation task /// </summary> /// <param name="reporter">The reported to use</param> public CompilationTask(Reporter reporter) { this.grammarName = null; this.outputMode = null; this.outputTarget = null; this.outputTargetRust = null; this.outputPath = null; this.outputNamespace = null; this.outputAccess = null; this.method = null; this.reporter = reporter; this.loader = new Input.Loader(this.reporter); }
/// <summary> /// Builds the test parsers /// </summary> private void BuildTestParsers(string fixtureName, string testName) { // get all units from the tests List <Unit> units = new List <Unit>(); // add the unit for the expected tree parser Stream stream1 = typeof(Program).Assembly.GetManifestResourceStream("Hime.Tests.Driver.Resources.Fixture.gram"); Stream stream2 = typeof(CompilationTask).Assembly.GetManifestResourceStream("Hime.SDK.Sources.Input.HimeGrammar.gram"); Hime.SDK.Input.Loader loader = new Hime.SDK.Input.Loader(); loader.AddInputRaw(stream1); loader.AddInputRaw(stream2); List <Grammar> grammars = loader.Load(); foreach (Grammar grammar in grammars) { if (grammar.Name == "ExpectedTree") { units.Add(new Unit(grammar, "", Mode.Assembly, ParsingMethod.LALR1, "Hime.Tests.Generated", Modifier.Public)); break; } } // add the unit for the parsers foreach (Fixture fixture in fixtures) { if (fixtureName != null && fixture.Name != fixtureName) { continue; } foreach (Test test in fixture.Tests) { if (testName != null && test.Name != testName) { continue; } units.Add(test.GetUnit(fixture.Name)); } } // emit the artifacts (new EmitterForNet(reporter, units)).Emit(); File.Move("Parsers.dll", "parsers-net.dll"); (new EmitterForJava(reporter, units)).Emit(); File.Move("Parsers.jar", "parsers-java.jar"); EmitterForRust emitterForRust = new EmitterForRust(reporter, units, Path.Combine(Path.GetDirectoryName(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)), "runtime-rust")); emitterForRust.Emit(); File.Move("Parsers.crate", "parsers-rust.crate"); File.Move("Parsers" + emitterForRust.SuffixSystemAssembly, "parsers-rust" + emitterForRust.SuffixSystemAssembly); }