예제 #1
0
        protected override void Visit(ConditionalChunk chunk)
        {
            switch (chunk.Type)
            {
            case ConditionalType.If:
                _source.Write("if ").WriteLine(chunk.Condition);
                break;

            case ConditionalType.ElseIf:
                _source.ClearEscrowLine();
                _source.Write("elsif ").WriteLine(chunk.Condition);
                break;

            case ConditionalType.Else:
                _source.ClearEscrowLine();
                _source.Write("else ").WriteLine(chunk.Condition);
                break;

            case ConditionalType.Once:
                _source.Write("if once(").Write(chunk.Condition).WriteLine(")");
                break;

            default:
                throw new CompilerException(string.Format("Unknown ConditionalChunk type {0}", chunk.Type));
            }
            _source.Indent++;
            _variables.PushScope();
            Accept(chunk.Body);
            _variables.PopScope();
            _source.Indent--;
            _source.EscrowLine("end");
        }