public void LoadGrammar(string grammar_name) { Feedback.print("Loading " + grammar_name + "...", Feedback.Status.story); Familiar_Document library = Familiar_Document.get_document(grammar_name); vocabularies.Add(grammar_name, library); Feedback.print("done.\r\n", Feedback.Status.story); }
//public static void init() //{ // id = 0; //} //public void initialize() //{ // type = Element_Type.item; //} public static Element_Item create_rule(Familiar_Document new_document, XmlElement element) { Element_Item result = new Element_Item(); result.document = new_document; result.initialize(element); return(result); }
public static Familiar_Document get_document(string document_name) { var result = find_document(document_name); if (result == null) { result = new Familiar_Document(document_name); } return(result); }
static public Action create(string type, string text, Familiar_Document document) { if (!types.ContainsKey(type)) { return(null); } Action item = (Action)Activator.CreateInstance(types[type]); item.library = document; item.create(text); return(item); }
protected override void initialize(XmlElement element) { load(element); string reference = element.GetAttribute("uri"); text = reference; if (reference[0] == '#') { document.all_local_references.Add(this); } else { string[] parameters = reference.Split(new char[] { '#' }); if (parameters.Length > 1) { reference = parameters[0]; } Familiar_Document external_document = document.add_external_document(reference); if (!external_document.dependants.ContainsKey(key)) { external_document.dependants.Add(key, document); } if (!document.referenced_documents.Contains(external_document)) { document.referenced_documents.Add(external_document); } if (parameters.Length > 1) { foreach (Element_Base rule in external_document.all_rules) { if (rule.name == parameters[1]) { children.Add(rule); return; } } throw new Exception("External rule was not found!"); } else { children.Add(external_document.rules[0]); } } }
//private void create_final_word() //{ // text = ""; // if (value != null) // text = value; // if (text != null) // { // initialize(text); // } //} public void initialize(string input_text) { id = input_text; Match match = Regex.Match(input_text, @"::([^.]+).(\d+)(?:\.(\d+))?"); if (match.Success) { Familiar_Document item_document = Familiar_Document.find_document(match.Groups[1].Value); source = item_document.items[int.Parse(match.Groups[2].Value)]; if (source.GetType() != typeof(Element_Word)) { text = source.text; return; } Element_Word item = source as Element_Word; text = item.display; if (match.Groups[3].Value != "") { text = item.get_suffix(item.suffixes[int.Parse(match.Groups[3].Value)]); } } else { // var source = MetaHub.Core.Meta_Object.parse_absolute_path(input_text); // if (source != null) // { // text = input_text; //// Feedback.print(text + "\r\n", Feedback.Status.info); // } // else // text = input_text; } }
public void initialize(Familiar_Document new_document) { document = new_document; }
public void LoadInitialGrammars() { Feedback.print("Loading Grammar Documents...\r\n", Feedback.Status.story); applications.Clear(); vocabularies.Clear(); Global.configuration.load_block("applications.xml", (file_name) => { XmlDocument document = new XmlDocument(); document.Load(Global.configuration.settings_path(file_name)); foreach (XmlElement element in document.ChildNodes[1].ChildNodes) { try { if (applications.ContainsKey(element.GetAttribute("name"))) { continue; } Context settings = null; if (element.HasAttribute("class")) { settings = (Context)Activator.CreateInstance( Context.types[element.GetAttribute("class")], element.GetAttribute("name"), this); } else { settings = new Context(element.GetAttribute("name"), this); } XmlNodeList titles = element.GetElementsByTagName("title"); foreach (XmlNode title in titles) { settings.title_patterns.Add(new System.Text.RegularExpressions.Regex(title.InnerText)); } XmlNodeList items = element.GetElementsByTagName("process"); foreach (XmlNode item in items) { settings.processes.Add(item.InnerText); } items = element.GetElementsByTagName("class"); foreach (XmlNode item in items) { settings.class_patterns.Add(new System.Text.RegularExpressions.Regex(item.InnerText)); } XmlNodeList grammar_list = element.GetElementsByTagName("grammar"); foreach (XmlNode grammar_name in grammar_list) { if (!vocabularies.ContainsKey(grammar_name.InnerText)) { LoadGrammar(grammar_name.InnerText); } settings.vocabularies.Add(grammar_name.InnerText, vocabularies[grammar_name.InnerText]); } XmlNodeList second_grammar_list = element.GetElementsByTagName("new_grammar"); foreach (XmlNode grammar_name in second_grammar_list) { var key = grammar_name.InnerText; //if (!main_grammar.documents.ContainsKey(key)) // LoadGrammar2(key); if (main_grammar.documents.ContainsKey(key)) { settings.documents.Add(key, main_grammar.documents[key]); } } applications.Add(settings.name, settings); } catch (Exception ex) { Feedback.print(ex); } } }); Feedback.print("Initializing Grammars...", Feedback.Status.story); Familiar_Document.finalize_all_grammars(engine); Feedback.print("done.\r\n", Feedback.Status.story); main_grammar.update(); applications["global"].Activate(); engine.start(); Feedback.print("Finished loading Grammar documents.\r\n", Feedback.Status.story); }
public Old_Action(Familiar_Document new_document) { document = new_document; }
public Old_Action(Element_Base new_parent) { parent = new_parent; document = parent.document; }