/// <summary> /// Interprets root and generates XHTML files /// </summary> /// <param name="tree">Tree to interpret</param> public void InterpretAST(SyntaxTree tree) { Module root = tree.GetRoot(); //Get dependency's and add functions to SymbolTable List <Module> dependencyList = ModuleCache.Instance.RequestDependencies(root); SymbolTable = new SymbolTable(); foreach (Module module in dependencyList) { foreach (FunctionDefinition function in module.GetFunctionDefinitions()) { SymbolTable.AddFunctionDefinition(function); } } //Interpret the main function if (SymbolTable.ContainsFunction("main")) { XHTMLVisitor xhtmlVisitor = new XHTMLVisitor(SymbolTable); SymbolTable.GetFunctionDefinition("main").AcceptVisitor(xhtmlVisitor); //Write xhtml output XHTMLStreamWriter writer = new XHTMLStreamWriter(Console.Out, XHTMLStreamWriter.DocType.TRANSITIONAL, xhtmlVisitor.GetTree()); writer.WriteStream(); } //Interpret all sites an write to files foreach (Module module in dependencyList) { foreach (Site site in module.GetSites()) { foreach (Mapping mapping in site.GetMappings()) { //Get function which should be called Markup markup = mapping.GetMarkup(); //Determine site path and open writer and lets interpret it Writer = CreateOutputStream(mapping.GetPath().ToString()); XHTMLVisitor xhtmlVisitor = new XHTMLVisitor(SymbolTable); markup.AcceptVisitor(xhtmlVisitor); //Write xhtml output XHTMLStreamWriter writer = new XHTMLStreamWriter(Writer, XHTMLStreamWriter.DocType.TRANSITIONAL, xhtmlVisitor.GetTree()); writer.WriteStream(); } } } }