Exemple #1
0
        internal static bool TryParse(Node parent, Queue <Word> remainingWords, out IncludeDirective directive)
        {
            directive = null;
            if (remainingWords.Peek().Text != "@include")
            {
                return(false);
            }

            directive = new IncludeDirective(parent);
            // remove '@include'
            remainingWords.Dequeue();


            Expression expression;

            if (!Expression.TryParse(directive, remainingWords, out expression))
            {
                throw new Exception("errp?");
            }
            // remove ';'
            if (remainingWords.Peek().Text == ";")
            {
                remainingWords.Dequeue();
            }
            directive.Name = expression;


            return(true);
        }
Exemple #2
0
        internal static bool TryParse(Node parent, Queue <Word> remainingWords, out Parameters parameters)
        {
            if (remainingWords.Count == 0 ||
                remainingWords.Peek().Text != "(")
            {
                parameters = null;
                return(false);
            }
            remainingWords.Dequeue();

            parameters = new Parameters(parent);
            while (remainingWords.Peek().Text != ")")
            {
                if (remainingWords.Peek().Text == ",")
                {
                    remainingWords.Dequeue();
                    continue;
                }

                Expression expression;
                if (Expression.TryParse(parent, remainingWords, out expression))
                {
                    parameters.Children.Add(expression);
                    continue;
                }
            }
            remainingWords.Dequeue();

            return(true);
        }
Exemple #3
0
        internal static bool TryParse(Node parent, Queue <Word> remainingWords, out ExtendDirective directive)
        {
            directive = null;
            if (remainingWords.Peek().Text != "@extend")
            {
                return(false);
            }

            directive      = new ExtendDirective(parent);
            directive.Name = remainingWords.Dequeue().Text.Substring(1);


            Expression expression;

            if (!Expression.TryParse(directive, remainingWords, out expression))
            {
                throw new Exception("errp?");
            }
            // remove ';'
            if (remainingWords.Peek().Text == ";")
            {
                remainingWords.Dequeue();
            }
            directive.Value = expression;


            return(true);
        }
Exemple #4
0
        internal static bool TryParse(Node parent, Queue <Word> remainingWords, out PropertyAssignment property)
        {
            if (remainingWords.Skip(1).First().Text != ":")
            {
                property = null;
                return(false);
            }

            property      = new PropertyAssignment(parent);
            property.Name = remainingWords.Dequeue().Text;
            // remove ':'
            remainingWords.Dequeue();

            Block block;

            if (Block.TryParse(property, remainingWords, out block))
            {
                property.Value = block;
                return(true);
            }
            Expression expression;

            if (Expression.TryParse(property, remainingWords, out expression))
            {
                property.Value = expression;
                // remove ';'
                if (remainingWords.Peek().Text == ";")
                {
                    remainingWords.Dequeue();
                }
                return(true);
            }

            property = null;
            return(false);
        }
Exemple #5
0
        internal static bool TryParse(Node parent, Queue <Word> remainingWords, out MixinDefinition definition)
        {
            definition = null;
            if (remainingWords.Peek().Text != "@mixin")
            {
                return(false);
            }

            definition = new MixinDefinition(parent);
            // remove '@mixin'
            remainingWords.Dequeue();

            var remainingNameWords = new Queue <Word>();

            while (remainingWords.Peek().Text != "{")
            {
                remainingNameWords.Enqueue(remainingWords.Dequeue());
            }

            Expression name;

            if (!Expression.TryParse(definition, remainingNameWords, out name))
            {
                throw new Exception("errp?");
            }
            definition.Name = name;

            Block block;

            if (!Block.TryParse(definition, remainingWords, out block))
            {
                throw new Exception("erh?");
            }
            definition.Value = block;
            return(true);
        }