/// <summary>Adds a useable operator to the global lookup.</summary>
		/// <param name="newOperator">The operator to add.</param>
		public static void Add(Operator newOperator){
			string pattern=newOperator.Pattern;
			// The first character is cached for fast lookup purposes.
			char first=pattern[0];
			
			if(!Starts.ContainsKey(first)){
				Starts.Add(first,0);
			}
			
			FullOperators.Add(pattern,newOperator);
		}
Exemple #2
0
 /// <summary>Creates a new type fragment by reading it from the given lexer.</summary>
 /// <param name="sr">The lexer to read it from.</param>
 /// <param name="hasColon">True if a colon (:) should be read from the lexer.</param>
 public TypeFragment(CodeLexer sr, bool hasColon)
 {
     HasColon = hasColon;
     if (HasColon)
     {
         // Read off the colon:
         sr.Read();
     }
     // Read until some other block can take over:
     while (true)
     {
         char peek = sr.Peek();
         if (peek == '<')
         {
             List <TypeFragment> generics = new List <TypeFragment>();
             while (true)
             {
                 // Read off the < or the comma:
                 sr.Read();
                 generics.Add(new TypeFragment(sr, false));
                 if (sr.Peek() == '>')
                 {
                     sr.Read();
                     GenericSet = generics.ToArray();
                     break;
                 }
             }
             if (sr.Peek() == '[')
             {
                 SetArray(sr);
             }
             break;
         }
         else if (peek == '[')
         {
             SetArray(sr);
             break;
         }
         else if (peek == ',' || peek == ';' || peek == StringReader.NULL || BracketFragment.AnyBracket(peek) || Operator.IsOperator(peek))
         {
             // Pass control back to the operation:
             break;
         }
         Value += char.ToLower(sr.Read());
     }
 }