Пример #1
0
 public void MergeByMainBlock(SyntaxDefinition Target)
 {
     SpanDefinition.SpanDefinition[] spanDefinitions = SpanDefinitions;
     foreach (SpanDefinition.SpanDefinition bt in spanDefinitions)
     {
         bt.childSpanDefinitions.Insert(0, Target.mainSpanDefinition);
     }
 }
Пример #2
0
 public void MergeByChildBlocks(SyntaxDefinition Target)
 {
     SpanDefinition.SpanDefinition[] spanDefinitions = SpanDefinitions;
     foreach (SpanDefinition.SpanDefinition bt in spanDefinitions)
     {
         for (int i = Target.mainSpanDefinition.childSpanDefinitions.Count - 1; i >= 0; i--)
         {
             SpanDefinition.SpanDefinition child = Target.mainSpanDefinition.childSpanDefinitions[i];
             bt.childSpanDefinitions.Insert(0, child);
         }
     }
 }
Пример #3
0
        /// <summary>
        ///
        /// </summary>
        public SyntaxDefinitionList()
        {
            languages = new List <SyntaxDefinition>();

            string[] files = Directory.GetFiles(".", "*.syn");
            foreach (string file in files)
            {
                var loader = new SyntaxDefinitionLoader();
                SyntaxDefinition syntax = loader.Load(file);
                languages.Add(syntax);
            }
        }
        /// <summary>
        /// Load a specific syntax file
        /// </summary>
        /// <param name="File">File name</param>
        /// <returns>SyntaxDefinition object</returns>
        public SyntaxDefinition Load(string File)
        {
            styleLookup          = new Hashtable();
            spanDefinitionLookup = new Hashtable();
            syntaxDefinition     = new SyntaxDefinition();

            var xmlDocument = new XmlDocument();

            xmlDocument.Load(File);
            ReadLanguageDefinition(xmlDocument);

            return(syntaxDefinition);
        }
        /// <summary>
        /// Load a specific syntax from an xml string
        /// </summary>
        /// <param name="XML"></param>
        /// <returns></returns>
        public SyntaxDefinition LoadXML(string XML)
        {
            styleLookup          = new Hashtable();
            spanDefinitionLookup = new Hashtable();
            syntaxDefinition     = new SyntaxDefinition();

            var xmlDocument = new XmlDocument();

            xmlDocument.LoadXml(XML);
            ReadLanguageDefinition(xmlDocument);

            if (syntaxDefinition.mainSpanDefinition == null)
            {
                throw new Exception("no main block found in syntax");
            }


            return(syntaxDefinition);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="File"></param>
        /// <param name="Separators"></param>
        /// <returns></returns>
        public SyntaxDefinition Load(string File, string Separators)
        {
            styleLookup          = new Hashtable();
            spanDefinitionLookup = new Hashtable();
            syntaxDefinition     = new SyntaxDefinition {
                Separators = Separators
            };

            var xmlDocument = new XmlDocument();

            xmlDocument.Load(File);
            ReadLanguageDefinition(xmlDocument);

            if (syntaxDefinition.mainSpanDefinition == null)
            {
                throw new Exception("no main block found in syntax");
            }

            return(syntaxDefinition);
        }