/// <summary> /// Interpret the AST /// </summary> /// <param name="root">Node which is root of tree</param> public void InterpretAST(Node root) { //Fill SymbolTable with functiondefinitions of all dependency's SymbolTable = new SymbolTable(); List <Node> dependencyList = ModuleCache.Instance.RequestDependencies(root); foreach (Node dependency in dependencyList) { IndexFunctionDefinitions(dependency); } //Interpret main method if one available if (SymbolTable.ContainsFunction("main")) { //Interpret main function Interpreter interpreter = new Interpreter(SymbolTable); interpreter.VisitFunctionDefinition(SymbolTable.GetFunctionDefinition("main")); //Write XHTML output XHTMLStreamWriter writer = new XHTMLStreamWriter(Console.Out, XHTMLStreamWriter.DocType.TRANSITIONAL, interpreter.GetTree()); writer.WriteStream(); } //Interpret all sites foreach (Node dependency in dependencyList) { List <Node> sites = GetSitesOfModule(dependency); foreach (Node site in sites) { foreach (Node mapping in site.ViewAllNodes()) { //Get markup Node markup = mapping.ViewAllNodes().ElementAt(1); Node pathNode = mapping.ViewAllNodes().ElementAt(0); String path = pathNode.AtomicValue.ToString(); //Remove ./ or / from path string path = path.TrimStart('.', '/'); Interpreter interpreter = new Interpreter(SymbolTable); interpreter.VisitMarkup(markup); //Write XHTML output Writer = CreateOutputStream(path); XHTMLStreamWriter writer = new XHTMLStreamWriter(Writer, XHTMLStreamWriter.DocType.TRANSITIONAL, interpreter.GetTree()); writer.WriteStream(); } } } }
/// <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(); } } } }
/// <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(); } } } }
/// <summary> /// Determine if an markup is an CallMarkup /// </summary> /// <param name="markup">Markup to check</param> /// <returns>IsCall</returns> private bool IsCall(Markup markup) { return(SymbolTable.ContainsFunction(markup.GetDesignator().GetIdentifier())); }