BitOrchestra.Parser.AcceptOperator C# (CSharp) Method

AcceptOperator() public static method

Tries parsing an operator in the given text.
public static AcceptOperator ( string Text, int &Index, Operator &Operator ) : bool
Text string
Index int
Operator Operator
return bool
        public static bool AcceptOperator(string Text, ref int Index, ref Operator Operator)
        {
            bool found = false;
            int sindex = Index;
            int maxlen = Math.Min(Operator.MaxOperatorLength, Text.Length - Index);
            for (int t = 1; t <= maxlen; t++)
            {
                string optext = Text.Substring(sindex, t);
                Operator op;
                if (Operator.Map.TryGetValue(optext, out op))
                {
                    Index = sindex + t;
                    Operator = op;
                    found = true;
                }
            }
            return found;
        }