public void RunTestCase(string testFile) { try { string testFilePath = this.ResolvePath(testFile); CompileUnit[] array = CSharpAssertModule.Convert(new FileInput(testFilePath)); CompileUnit resultingCSharpNode = array[0]; CompileUnit resultingBooNode = array[1]; string[] expectedOutput = this.GetExpectedOutput(testFilePath); string expectedCSharpOutput = expectedOutput[0]; string expectedBooOutput = expectedOutput[1]; string inputJSCode = expectedOutput[2]; Debug.WriteLine("JavaScript:\n" + inputJSCode); var output = new StringWriter(); resultingCSharpNode.Accept(new CSharpPrinter(output)); Debug.WriteLine("Generated C#:\n" + output.ToString().TrimEnd()); Debug.WriteLine("Generated Boo:\n" + resultingBooNode.ToCodeString()); CSharpAssertModule.AssertCSharpCode(expectedCSharpOutput, resultingCSharpNode); StringsModule.AssertAreEqualIgnoringNewLineDifferences(expectedBooOutput, resultingBooNode.ToCodeString()); } catch (CompilationErrorsException x) { Assert.Fail(x.Errors.ToString(true)); } }
public static Module ParseModule(CompileUnit cu, TextReader input, ConverterSettings settings, out IList <ISpecial> specials) { if (cu == null) { throw new ArgumentNullException("cu"); } if (input == null) { throw new ArgumentNullException("input"); } if (settings == null) { throw new ArgumentNullException("settings"); } IParser parser = ParserFactory.CreateParser(settings.IsVisualBasic ? SupportedLanguage.VBNet : SupportedLanguage.CSharp, input); ErrorTrap errorTrap = new ErrorTrap(settings); parser.Errors.SemErr = errorTrap.DefaultCodeError; parser.Errors.SynErr = errorTrap.DefaultCodeError; parser.Errors.Error = errorTrap.DefaultMsgError; parser.Parse(); specials = parser.Lexer.SpecialTracker.CurrentSpecials; if (settings.IsVisualBasic) { PreprocessingDirective.VBToCSharp(specials); } // abort when file has errors if (errorTrap.count > 0) { return(null); } Module m = Converter.Convert(parser.CompilationUnit, settings); if (m != null && cu != null) { cu.Modules.Add(m); if (settings.RemoveRedundantTypeReferences) { cu.Accept(new RemoveRedundantTypeReferencesVisitor()); } } return(m); }
void OnUpdateStep(object sender, ParserUpdateStepEventArgs e) { if (FileUtility.IsEqualFileName(e.FileName, this.TextEditor.FileName)) { ParseInformation parseInfo = e.ParseInformation; if (parseInfo == null && this.declarations == null) { parseInfo = ParserService.GetParseInformation(this.TextEditor.FileName); } if (parseInfo != null) { ICompilationUnit cu = parseInfo.MostRecentCompilationUnit; CompileUnit booCu = cu.Tag as CompileUnit; if (booCu != null) { FindAssignmentsVisitor visitor = new FindAssignmentsVisitor(); booCu.Accept(visitor); this.declarations = visitor.declarations; // volatile access! } } WorkbenchSingleton.SafeThreadAsyncCall(MarkOutstanding); } }
public virtual void Run() { CompileUnit.Accept(this); }
override public void Run() { Visit(CompileUnit); CompileUnit.Accept(new OrBlockNormalizer(Context)); }
override public void Run() { CompileUnit.Accept(new QuasiquoteExpander()); }
private CompileUnit ApplyCSharpTransformer(CompileUnit node) { node.Accept(new CSharpTransformer()); return(node); }
private CompileUnit ApplyBooTransformer(CompileUnit node) { node.Accept(new BooTransformer()); return(node); }
public static void printCSharpCodeFor(CompileUnit cu) { cu.Accept(new CSharpPrinter()); }