コード例 #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);
        }
コード例 #2
0
        public override Node Clone(Node newParent)
        {
            var newDirective = new IncludeDirective(newParent);

            newDirective.Name = (Expression)Name.Clone(newDirective);
            return(newDirective);
        }
コード例 #3
0
ファイル: IncludeDirective.cs プロジェクト: lzcd/Crass
        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;
        }
コード例 #4
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);
        }
コード例 #5
0
ファイル: IncludeDirective.cs プロジェクト: lzcd/Crass
 public override Node Clone(Node newParent)
 {
     var newDirective = new IncludeDirective(newParent);
     newDirective.Name = (Expression)Name.Clone(newDirective);
     return newDirective;
 }