Пример #1
0
        public static StatementSyntax Transpile(this Syntax.ElseifSyntax elseifNode)
        {
            _ = elseifNode ?? throw new ArgumentNullException(nameof(elseifNode));

            var ifStatement = SyntaxFactory.IfStatement(
                elseifNode.ConditionExpressionNode.Transpile(),
                SyntaxFactory.Block(elseifNode.StatementListNode.Transpile()));

            return(elseifNode.EmptyElseClauseNode is null
                ? ifStatement.WithElse(elseifNode.ElseClauseNode.Transpile())
                : ifStatement);
        }
Пример #2
0
        public static void Transpile(this Syntax.ElseifSyntax elseifNode, ref StringBuilder sb)
        {
            _ = elseifNode ?? throw new ArgumentNullException(nameof(elseifNode));

            sb.Append("elseif ");
            elseifNode.ConditionExpressionNode.Transpile(ref sb);
            sb.AppendLine(" then");
            elseifNode.StatementListNode.Transpile(ref sb);
            if (elseifNode.EmptyElseClauseNode is null)
            {
                elseifNode.ElseClauseNode.Transpile(ref sb);
            }
            else
            {
                sb.Append("end");
            }
        }