Example #1
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);
        }
Example #2
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);
        }