Ejemplo n.º 1
0
 public keywords GetSearchString(string str, ref int c1, Tags DealData, string read)
 {
     keywords k = new keywords();
     if (c1 > str.Length)
     {
         Console.WriteLine("Mistake at the end of Search keyword (?).");
         AtTheEnd += "ERROR: Mistake at the end of Search keyword (?).";
         k.SetTimes(-1);
         return (k);
     }
     while (str[c1] == ' ')
     {
         c1 += 1;
     }
     if (str[c1] == '<')
     {
         k.SetDirection('<');
         c1 += 1;
         while (str[c1] == ' ')
         {
             c1 += 1;
         }
     }
     if ((str[c1] >= '1') && (str[c1] <= '9'))
     {
         do
         {
             k.SetTimes(10 * k.GetTimes() + (str[c1] - 48));
             c1 += 1;
         } while ((str[c1] >= '1') && (str[c1] <= '9'));
         while (str[c1] == ' ')
         {
             c1 += 1;
         }
     }
     if (str[c1] == '$')
     {
         int c2;
         c1 += 1;
         c2 = c1 + 1;
         int num = -1;
         if ((str[c2] >= '0') && (str[c2] <= '9') && (str[c1] >= '0') && (str[c1] <= '9'))
         {
             num = Convert.ToInt16(str.Substring(c1, 2));
             c1 += 1;
         }
         else if ((str[c1] >= '0') && (str[c1] <= '9'))
         {
             num = Convert.ToInt16(str.Substring(c1, 1));
         }
         else
         {
             Console.WriteLine("Mistake at variable ($).");
             AtTheEnd += "ERROR: Mistake at variable ($).";
             k.SetTimes(-1);
             return (k);
         }
         if (DealData.data[num] == "")
         {
             str = this.oneWebsite.data[num];
             if (!RecursList.Contains(num))
             {
                 RecursList.Add(num);
                 str = this.SingleDataExtraction(str, read, DealData);
                 RecursList.Remove(num);
                 DealData.data[num] = str;
             }
             else
             {
                 Console.WriteLine("ERROR: Recursivity definition!" + str);
                 AtTheEnd += "ERROR: Recursivity definition!" + str;
                 k.SetTimes(-1);
                 return (k);
             }
         }
         k.SetKeyword(DealData.data[num]);
         k.SetIndex(num);
         if (k.GetTimes() == 0) k.SetTimes(1);
         k.SetType('?');
         c1 += 1;
     }
     else if (str[c1] == '"')
     {
         int c2 = c1;
         c1 += 1;
         do
         {
             c2 = str.IndexOf('"', c2 + 1);
             if (c2 == -1)
             {
                 Console.WriteLine("Missing \" in Search keyword. Can't go on.");
                 AtTheEnd += "ERROR: Missing \" in Search keyword. Can't go on.";
                 k.SetTimes(-1);
                 return (k);
             }
         } while (str[c2 - 1] == '\\');
         k.SetKeyword(str.Substring(c1, c2 - c1));
         k.SetKeyword(k.GetKeyword().Replace("\\\"", "\""));
         if (k.GetTimes() == 0) k.SetTimes(1);
         k.SetType('?');
         c1 = c2 + 1;
     }
     else
     {
         Console.WriteLine("Error in Search tag (?) format. Probably missing \" at " + c1 + " character.");
         AtTheEnd += "ERROR: Error in Search tag (?) format. Probably missing \" at " + c1 + " character.";
         k.SetTimes(-1);
     }
     return (k);
 }
Ejemplo n.º 2
0
 public keywords GetEndString(string str, ref int c1)
 {
     keywords k = new keywords();
     if (c1 > str.Length)
     {
         Console.WriteLine("Mistake at the end of End keyword (@).");
         AtTheEnd += "ERROR: Mistake at the end of End keyword (@).";
         k.SetTimes(-1);
         return (k);
     }
     while (str[c1] == ' ')
     {
         c1 += 1;
     }
     if (str[c1] == '<')
     {
         Console.WriteLine("ERROR: End delimiter can't search back.");
         AtTheEnd += "ERROR: End delimiter can't search back.";
         k.SetTimes(-1);
         return (k);
     }
     if ((str[c1] >= '1') && (str[c1] <= '9'))
     {
         do
         {
             k.SetTimes(10 * k.GetTimes() + str[c1]);
             c1 += 1;
         } while ((str[c1] >= '1') && (str[c1] <= '9'));
         while (str[c1] == ' ')
         {
             c1 += 1;
         }
     }
     if (str[c1] == '"')
     {
         int c2 = c1;
         c1 += 1;
         do
         {
             c2 = str.IndexOf('"', c2 + 1);
             if (c2 == -1)
             {
                 Console.WriteLine("Missing \" in End keyword. Can't go on.");
                 AtTheEnd += "ERROR: Missing \" in End keyword. Can't go on.";
                 k.SetTimes(-1);
                 return (k);
             }
         } while (str[c2 - 1] == '\\');
         k.SetKeyword(str.Substring(c1, c2 - c1));
         k.SetKeyword(k.GetKeyword().Replace("\\\"", "\""));
         if (k.GetTimes() == 0) k.SetTimes(1);
         k.SetType('@');
         c1 = c2 + 1;
     }
     else
     {
         Console.WriteLine("Error in End tag (@) format. Probably missing \" at " + c1 + " character.");
         AtTheEnd += "ERROR: Error in End tag (@) format. Probably missing \" at " + c1 + " character.";
         k.SetTimes(-1);
     }
     return (k);
 }