コード例 #1
0
        public override object Clone() //throws CloneNotSupportedException
        {
            ConditionalNode clone = (ConditionalNode)base.Clone();

            clone.conditions = new List <IfConditionNode>();
            foreach (IfConditionNode condition in conditions)
            {
                clone.conditions.Add((IfConditionNode)condition.Clone());
            }

            return(clone);
        }
コード例 #2
0
ファイル: JadeParser.cs プロジェクト: rnrn/Jade4Net
        private Node parseConditional()
        {
            If conditionalToken = (If) expect(typeof (If));
            ConditionalNode conditional = new ConditionalNode();
            conditional.setLineNumber(conditionalToken.getLineNumber());
            conditional.setFileName(filename);

            List<IfConditionNode> conditions = conditional.getConditions();

            IfConditionNode main = new IfConditionNode(conditionalToken.getValue(), conditionalToken.getLineNumber());
            main.setInverse(conditionalToken.isInverseCondition());
            main.setBlock(block());
            conditions.Add(main);

            while (peek() is ElseIf)
            {
                ElseIf token = (ElseIf) expect(typeof (ElseIf))
                ;
                IfConditionNode elseIf = new IfConditionNode(token.getValue(), token.getLineNumber());
                elseIf.setBlock(block());
                conditions.Add(elseIf);
            }

            if (peek() is Else)
            {
                Else token = (Else) expect(typeof (Else))
                ;
                IfConditionNode elseNode = new IfConditionNode(null, token.getLineNumber());
                elseNode.setDefault(true);
                elseNode.setBlock(block());
                conditions.Add(elseNode);
            }

            return conditional;
        }