static Module Parse(string fileName, string fileContent) { BooParsingStep step = new BooParsingStep(); StringBuilder errors = new StringBuilder(); Module module = BooParser.ParseModule(4, new CompileUnit(), fileName, new StringReader(fileContent), delegate(antlr.RecognitionException e) { errors.AppendLine(e.ToString()); }); if (errors.Length > 0) { throw new FormsDesignerLoadException("Syntax errors in " + fileName + ":\r\n" + errors.ToString()); } return module; }
private void AddNamespaceImports(Import node) { RemoveCurrentNode(); string url = GetFilePath(node); using(TextReader reader = urlResolver(url, baseDirectory)) { BooParsingStep parser = new BooParsingStep(); CompilerContext context = new CompilerContext(); StringInput input = new StringInput(node.AssemblyReference.Name, reader.ReadToEnd()); context.Parameters.Input.Add(input); parser.Initialize(context); parser.Run(); Module current = (Module) node.GetAncestor(NodeType.Module); foreach (Module module in context.CompileUnit.Modules) { foreach (Import import in module.Imports) { current.Imports.Add(import); } } } }