示例#1
0
        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);
        }
 public RuntimeIfConditionNode(RuntimeScope parent, IfConditionNode ifNode, RuntimeNode subscope) : base(parent, ifNode)
 {
     Subscope = subscope;
 }