Beispiel #1
0
        private bool TryMatchNamedValues(
            MixinDefinition definition,
            out NamedValue includeName,
            out NamedValue mixinName)
        {
            includeName = Name.Children.First() as NamedValue;
            if (includeName == null)
            {
                includeName = null;
                mixinName   = null;
                return(false);
            }
            mixinName = definition.Name.Children.First() as NamedValue;
            if (mixinName == null)
            {
                includeName = null;
                mixinName   = null;
                return(false);
            }

            if (includeName.Text != mixinName.Text)
            {
                includeName = null;
                mixinName   = null;
                return(false);
            }

            return(true);
        }
Beispiel #2
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;
        }
Beispiel #3
0
        private bool TryMatchNamedValues(
            MixinDefinition definition,
            out NamedValue includeName,
            out NamedValue mixinName)
        {
            includeName = Name.Children.First() as NamedValue;
            if (includeName == null)
            {
                includeName = null;
                mixinName = null;
                return false;
            }
            mixinName = definition.Name.Children.First() as NamedValue;
            if (mixinName == null)
            {
                includeName = null;
                mixinName = null;
                return false;
            }

            if (includeName.Text != mixinName.Text)
            {
                includeName = null;
                mixinName = null;
                return false;
            }

            return true;
        }
Beispiel #4
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);
        }