示例#1
0
		public static Keywords Read (XmlReader reader, bool ignoreCaseDefault)
		{
			Keywords result = new Keywords ();
			
			result.Color      = reader.GetAttribute ("color");
			if (!String.IsNullOrEmpty (reader.GetAttribute ("ignorecase"))) {
				result.IgnoreCase = Boolean.Parse (reader.GetAttribute ("ignorecase"));
			} else {
				result.IgnoreCase = ignoreCaseDefault;
			}
			
			XmlReadHelper.ReadList (reader, Node, delegate () {
				switch (reader.LocalName) {
				case "Word":
					result.words.Add (reader.ReadElementString ());
					return true;
				};
				return false;
			});
			return result;
		}
示例#2
0
		void UpdateKeywordTable (Keywords keywords)
		{
			foreach (string word in keywords.Words) {
				if (keywords.IgnoreCase) {
					if (keywordTableIgnoreCase == null)
						keywordTableIgnoreCase = new Dictionary<string, Keywords> (StringComparer.InvariantCultureIgnoreCase);
					if (keywordTableIgnoreCase.ContainsKey (word)) {
						Console.WriteLine ("Error: duplicate keyword " + word);
						continue;
					}
					keywordTableIgnoreCase.Add (word, keywords);
				} else {
					if (keywordTable == null)
						keywordTable = new Dictionary<string, Keywords> ();
					if (keywordTable.ContainsKey (word)) {
						Console.WriteLine ("Error: duplicate keyword " + word);
						continue;
					}
					keywordTable.Add (word, keywords);
				}
			}
		}
		void AddToTable (Keywords keywords, char[] word)
		{
			KeyTable[] curTable = table;
			for (int i = 0; i < word.Length; i++) {
				uint idx = (uint)word[i];
				if (idx > 255)
					throw new ArgumentOutOfRangeException (word + " contains invalid chars.");
				if (curTable[idx] == null)
					curTable[idx] = new KeyTable ();
				if (i == word.Length -1) {
					curTable[idx].keywords = keywords;
					break;
				}
				curTable = curTable[idx].table;
			}
		}
示例#4
0
        protected bool ReadNode(XmlReader reader, List <Match> matchList, List <Span> spanList, List <Marker> prevMarkerList)
        {
            switch (reader.LocalName)
            {
            case "Delimiters":
                this.Delimiter = reader.ReadElementString();
                return(true);

            case "Property":
                string name  = reader.GetAttribute("name");
                string value = reader.ReadElementString();

                if (!properties.ContainsKey(name))
                {
                    properties [name] = new List <string> ();
                }
                properties [name].Add(value);
                return(true);

            case Match.Node:
                matchList.Add(Match.Read(reader));
                return(true);

            case Span.Node:
            case Span.AltNode:
                spanList.Add(Span.Read(reader));
                return(true);

            case Mono.TextEditor.Highlighting.Keywords.Node:
                Keywords keywords = Mono.TextEditor.Highlighting.Keywords.Read(reader, IgnoreCase);
                this.keywords.Add(keywords);
                foreach (string word in keywords.Words)
                {
                    if (keywords.IgnoreCase)
                    {
                        if (keywordTableIgnoreCase == null)
                        {
                            keywordTableIgnoreCase = new Dictionary <string, Keywords> (StringComparer.InvariantCultureIgnoreCase);
                        }
                        if (keywordTableIgnoreCase.ContainsKey(word))
                        {
                            Console.WriteLine("Error: duplicate keyword " + word);
                            continue;
                        }
                        keywordTableIgnoreCase.Add(word, keywords);
                    }
                    else
                    {
                        if (keywordTable == null)
                        {
                            keywordTable = new Dictionary <string, Keywords> ();
                        }
                        if (keywordTable.ContainsKey(word))
                        {
                            Console.WriteLine("Error: duplicate keyword " + word);
                            continue;
                        }
                        keywordTable.Add(word, keywords);
                    }
                }
                return(true);

            case Marker.PrevMarker:
                prevMarkerList.Add(Marker.Read(reader));
                return(true);
            }
            return(false);
        }