BitOrchestra.Parser.AcceptWord C# (CSharp) Method

AcceptWord() public static method

Tries parsing a word in the given text.
public static AcceptWord ( string Text, int &Index, string &Word ) : bool
Text string
Index int
Word string
return bool
        public static bool AcceptWord(string Text, ref int Index, ref string Word)
        {
            int cur = Index;
            while (cur < Text.Length)
            {
                char c = Text[cur];
                if (cur == Index)
                {
                    int dummy = 0;
                    if (Parser.IsDecimalDigit(c, ref dummy) || !Parser.IsWordChar(c))
                        break;
                }
                else
                {
                    if (!Parser.IsWordChar(c))
                        break;
                }
                cur++;
            }
            if (cur > Index)
            {
                Word = Text.Substring(Index, cur - Index);
                Index = cur;
                return true;
            }
            return false;
        }