Пример #1
0
 public StringParser(string sourceCode)
 {
     _chars = sourceCode.ToCharArray();
     _pos = new TextPos { CharIndex = 0, LineNo = 1, ColNo = 1 };
 }
Пример #2
0
 public bool ThisWord(string[] wantedWordSet, ref int readIndex)
 {
     var priorPos = Pos;
     string wordRead = null;
     if (AnyWord(ref wordRead))
     {
         for (int i = 0; i < wantedWordSet.Length; i++)
             if (wantedWordSet[i].Equals(wordRead, StringComparison.OrdinalIgnoreCase))
             {
                 readIndex = i;
                 return true;
             }
         Pos = priorPos;
     }
     return false;
 }
Пример #3
0
 public bool ThisText(string wantedText)
 {
     Skip();
     var priorPos = Pos;
     var wantedChars = wantedText.ToCharArray();
     for (int i = 0; i < wantedChars.Length; i++)
         if (!ThisChar(wantedChars[i]))
         {
             Pos = priorPos;
             return false;
         }
     return true;
 }
Пример #4
0
 public bool ThisWord(string wantedWord, ref string wordRead)
 {
     var priorPos = Pos;
     if (AnyWord(ref wordRead))
     {
         if (wordRead.Equals(wantedWord, StringComparison.OrdinalIgnoreCase))
             return true;
         Pos = priorPos;
     }
     return false;
 }
Пример #5
0
 public bool ThisChar(string wantedCharSet, ref char charRead)
 {
     var priorPos = Pos;
     if (AnyChar(ref charRead))
     {
         if (wantedCharSet.IndexOf(charRead.ToString(), StringComparison.OrdinalIgnoreCase) != -1)
             return true;
         Pos = priorPos;
     }
     return false;
 }