コード例 #1
0
ファイル: Subtract.cs プロジェクト: lzcd/Crass
 internal static bool TryParse(Node parent, Queue<Word> remainingWords, out Subtract subtract)
 {
     if (remainingWords.Peek().Text != "-")
     {
         subtract = null;
         return false;
     }
     var word = remainingWords.Dequeue();
     subtract = new Subtract(parent);
     return true;
 }
コード例 #2
0
ファイル: Subtract.cs プロジェクト: lzcd/Crass
        internal static bool TryParse(Node parent, Queue <Word> remainingWords, out Subtract subtract)
        {
            if (remainingWords.Peek().Text != "-")
            {
                subtract = null;
                return(false);
            }
            var word = remainingWords.Dequeue();

            subtract = new Subtract(parent);
            return(true);
        }
コード例 #3
0
        internal static bool TryParse(Node parent, Queue <Word> remainingWords, out Expression expression)
        {
            expression = new Expression(parent);
            while (remainingWords.Count > 0 &&
                   remainingWords.Peek().Text != ";" &&
                   remainingWords.Peek().Text != "," &&
                   remainingWords.Peek().Text != ")" &&
                   remainingWords.Peek().Text != "}")
            {
                Add add;
                if (Add.TryParse(expression, remainingWords, out add))
                {
                    expression.Children.Add(add);
                }

                Subtract subtract;
                if (Subtract.TryParse(expression, remainingWords, out subtract))
                {
                    expression.Children.Add(subtract);
                }

                Multiply multiply;
                if (Multiply.TryParse(expression, remainingWords, out multiply))
                {
                    expression.Children.Add(multiply);
                }

                Divide divide;
                if (Divide.TryParse(expression, remainingWords, out divide))
                {
                    expression.Children.Add(divide);
                }

                Variable variable;
                if (Variable.TryParse(expression, remainingWords, out variable))
                {
                    expression.Children.Add(variable);
                    continue;
                }

                Colour colour;
                if (Colour.TryParse(expression, remainingWords, out colour))
                {
                    expression.Children.Add(colour);
                    continue;
                }

                Units unit;
                if (Units.TryParse(expression, remainingWords, out unit))
                {
                    expression.Children.Add(unit);
                    continue;
                }

                MethodCall methodCall;
                if (MethodCall.TryParse(expression, remainingWords, out methodCall))
                {
                    expression.Children.Add(methodCall);
                    continue;
                }

                if (remainingWords.Count > 0)
                {
                    var namedValue = new NamedValue(expression)
                    {
                        Text = remainingWords.Dequeue().Text
                    };
                    expression.Children.Add(namedValue);
                }
            }



            return(true);
        }