Esempio n. 1
0
        internal static bool TryParse(Node parent, Queue <Word> remainingWords, out Script script)
        {
            script = new Script(parent);

            do
            {
                MixinDefinition mixinDefinition;
                if (MixinDefinition.TryParse(script, remainingWords, out mixinDefinition))
                {
                    script.Children.Add(mixinDefinition);
                    continue;
                }

                VariableAssignment variableAssignment;
                if (VariableAssignment.TryParse(script, remainingWords, out variableAssignment))
                {
                    script.Children.Add(variableAssignment);
                    continue;
                }

                Selector selector;
                if (Selector.TryParse(script, remainingWords, out selector))
                {
                    script.Children.Add(selector);
                    continue;
                }
            }while (remainingWords.Count > 0);

            return(true);
        }
Esempio n. 2
0
        internal static bool TryParse(Node parent, Queue <Word> remainingWords, out Block block)
        {
            if (remainingWords.Peek().Text != "{")
            {
                block = null;
                return(false);
            }
            remainingWords.Dequeue();

            block = new Block(parent);
            while (remainingWords.Peek().Text != "}")
            {
                IncludeDirective includeDirective;
                if (IncludeDirective.TryParse(block, remainingWords, out includeDirective))
                {
                    block.Children.Add(includeDirective);
                    continue;
                }

                ExtendDirective excludeDirective;
                if (ExtendDirective.TryParse(block, remainingWords, out excludeDirective))
                {
                    block.Children.Add(excludeDirective);
                    continue;
                }

                PropertyAssignment property;
                if (PropertyAssignment.TryParse(block, remainingWords, out property))
                {
                    block.Children.Add(property);
                    continue;
                }

                Selector selector;
                if (Selector.TryParse(block, remainingWords, out selector))
                {
                    block.Children.Add(selector);
                    continue;
                }
            }
            remainingWords.Dequeue();

            return(true);
        }