/// <summary>Creates a new variable fragment by reading it from the given lexer.</summary>
        /// <param name="sr">The lexer to read the variable from.</param>
        public VariableFragment(CodeLexer sr)
        {
            Value += char.ToLower(sr.Read());

            // Read until some other block can take over:
            while (true)
            {
                char peek = sr.Peek();
                if (peek == ';' || peek == ',' || peek == StringReader.NULL || BracketFragment.AnyBracket(peek))
                {
                    // Pass control back to the operation:
                    break;
                }

                if (sr.PeekJunk())
                {
                    // Is Value anything special?
                    if (Value == "var")
                    {
                        break;
                    }
                    else if (Value == "private")
                    {
                        break;
                    }
                    else if (Value == "function")
                    {
                        break;
                    }
                    else if (Value == "class")
                    {
                        break;
                    }
                    else if (Value == "new")
                    {
                        GivenType = new TypeFragment(sr, false);
                        break;
                    }
                    else if (IsKeyword())
                    {
                        break;
                    }
                }

                Handler handle = Handlers.Find(peek);

                if (handle != Handler.Stop && handle != Handler.Variable && handle != Handler.Number)
                {
                    break;
                }

                Value += char.ToLower(sr.Read());
            }
        }
示例#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());
     }
 }
 /// <summary>Creates a property fragment by reading it from the given lexer.</summary>
 /// <param name="sr">The lexer to read the fragment from.</param>
 public PropertyFragment(CodeLexer sr)
 {
     // Skip the dot:
     sr.Read();
     // Read a 'variable':
     Value += char.ToLower(sr.Read());
     while (true)
     {
         char peek = sr.Peek();
         if (peek == ';' || peek == ',' || peek == '.' || peek == StringReader.NULL || BracketFragment.AnyBracket(peek))
         {
             // Pass control back to the operation:
             break;
         }
         Handler handle = Handlers.Find(peek);
         if (handle != Handler.Stop && handle != Handler.Variable && handle != Handler.Number && handle != Handler.Property)
         {
             break;
         }
         Value += char.ToLower(sr.Read());
     }
 }