BitOrchestra.Parser.AcceptExpression C# (CSharp) Method

AcceptExpression() public static method

Tries parsing an expression in the given text.
public static AcceptExpression ( Expression>.Dictionary Variables, string Text, int &Index, Expression &Expression, int &ErrorIndex ) : bool
Variables Expression>.Dictionary
Text string
Index int
Expression Expression
ErrorIndex int
return bool
        public static bool AcceptExpression(Dictionary<string, Expression> Variables, string Text, ref int Index, ref Expression Expression, out int ErrorIndex)
        {
            ErrorIndex = Index;
            if (AcceptTerm(Variables, Text, ref Index, ref Expression, out ErrorIndex))
            {
                _OpTree curtree = new _OpTree(Expression);
                int cur = Index;
                while (true)
                {
                    AcceptExtendedWhitespace(Text, ref cur);
                    Operator op = null;
                    if (AcceptOperator(Text, ref cur, ref op))
                    {
                        AcceptExtendedWhitespace(Text, ref cur);
                        if (AcceptTerm(Variables, Text, ref cur, ref Expression, out ErrorIndex))
                        {
                            curtree = _OpTree.Combine(curtree, op, Expression);
                            Index = cur;
                            continue;
                        }
                        return false;
                    }
                    break;
                }

                Expression = curtree.Expression;
                return true;
            }
            return false;
        }