public virtual string Compile(XmlNode node, int indent = 0) { string result = ""; foreach (XmlNode child in node.ChildNodes) { INodeCompiler compiler = CompilerFactory.Create(child); result += compiler.Compile(child, indent); } return(result); }
public string Compile(XmlNode node, int indent = 0) { string indentString = new string('\t', indent); string result = indentString + "else\n"; XmlNode body = node.SelectSingleNode("body"); INodeCompiler compiler = CompilerFactory.Create(body); result += compiler.Compile(body, indent + 1); return(result); }
public string Compile(XmlNode node, int indent = 0) { string indentString = new string('\t', indent); XmlNode checks = node.SelectSingleNode("checks"); INodeCompiler compiler = CompilerFactory.Create(checks); string result = indentString + "if (" + compiler.Compile(checks) + ") then\n"; XmlNode body = node.SelectSingleNode("body"); compiler = CompilerFactory.Create(body); result += compiler.Compile(body, indent + 1); return(result); }
public string Compile(XmlNode node, int indent = 0) { string result = ""; foreach (XmlNode child in node.ChildNodes) { INodeCompiler compiler = CompilerFactory.Create(child); if (result != "") { result += " " + child.Attributes["operator"].InnerText + " "; } result += compiler.Compile(child); } return(result); }
public string Compile(XmlNode node, int indent = 0) { string result = ""; foreach (XmlNode child in node.ChildNodes) { INodeCompiler compiler = CompilerFactory.Create(child); result += compiler.Compile(child) + ","; } if (node.ChildNodes.Count > 0) { return(Utils.ReplaceLastOccurrence(result, ",", ""));; } return(result); }
public string Compile(XmlNode node, int indent = 0) { string indentString = new string('\t', indent); string result = String.Format("{0}{1}(", indentString, node.Attributes["function"].InnerText); foreach (XmlNode child in node.ChildNodes) { INodeCompiler compiler = CompilerFactory.Create(child); result += compiler.Compile(child) + ", "; } if (node.ChildNodes.Count > 0) { return(Utils.ReplaceLastOccurrence(result, ", ", "") + ")\n"); } return(result + ")\n"); }
public string Compile(XmlNode node, int indent = 0) { string result = ""; string indentString = new string('\t', indent); result += String.Format("{0}for {1},{2} in pairs({3}) do\n", indentString, node.Attributes["key"].InnerText, node.Attributes["value"].InnerText, node.Attributes["variable"].InnerText ); foreach (XmlNode child in node.ChildNodes) { INodeCompiler compiler = CompilerFactory.Create(child); result += compiler.Compile(child, indent + 1); } result += indentString + "end\n"; return(result); }
public string Compile(XmlNode node, int indent = 0) { string result = ""; string indentString = new string('\t', indent); result += String.Format("{0}for {1} = {2}, {3}, {4} do\n", indentString, node.Attributes["variable"].InnerText, node.Attributes["start"].InnerText, node.Attributes["end"].InnerText, (node.Attributes["increments"] != null) ? node.Attributes["increments"].InnerText : "1" ); foreach (XmlNode child in node.ChildNodes) { INodeCompiler compiler = CompilerFactory.Create(child); result += compiler.Compile(child, indent + 1); } result += indentString + "end\n"; return(result); }
public string Compile(XmlNode node, int indent = 0) { string indentString = new string('\t', indent); var children = node.ChildNodes; if (children.Count > 0 && children[0].NodeType != XmlNodeType.Text) { string result = "\n"; foreach (XmlNode child in children) { INodeCompiler compiler = CompilerFactory.Create(child); result += compiler.Compile(child, indent + 1); } return(result); } else { return(indentString + node.InnerText); } }
public void Compile(string path) { try { XmlDocument file = new XmlDocument(); file.Load(path); XmlNode rootNode = file.ChildNodes[0]; INodeCompiler compiler = CompilerFactory.Create(rootNode); string script = compiler.Compile(rootNode); string newPath = Utils.ReplaceLastOccurrence(path, src, bin).Replace("." + fileType, ".lua"); if (File.Exists(newPath)) { File.Delete(newPath); } File.WriteAllText(newPath, script); } catch (XmlException e) { Console.WriteLine("Syntax error in {0}", path); Console.WriteLine(e); } }