Пример #1
0
        internal override async Task Dump(IndentedTextWriter writer)
        {
            await writer.WriteAsync("REPEAT");

            await this.Loop.Dump(writer);

            await writer.WriteAsync("UNTIL ");

            await this.Test.Dump(writer);

            await writer.WriteLineAsync(";");

            await this.NextBlock.Dump(writer, false);
        }
Пример #2
0
        internal virtual Task Dump(IndentedTextWriter writer)
        {
            StringBuilder stringBuilder = new();

            this.BuildString(stringBuilder);
            return(writer.WriteAsync(stringBuilder));
        }
Пример #3
0
        public async Task Dump(IndentedTextWriter writer)
        {
            await writer.WriteAsync(this.IsFunction? "FUNCTION " : "PROCEDURE ");

            await writer.WriteAsync(this.Name);

            await writer.WriteAsync('(');

            for (var i = 1; i < this.Parameters.Count; i++)
            {
                if (i != 1)
                {
                    await writer.WriteAsync(", ");
                }
                var param = this.Parameters.GetTypeAtOffset((WordCount)i);
                await writer.WriteAsync("param" + i + " : " + param);
            }

            await writer.WriteLineAsync(this.IsFunction? ") : " + this.ReturnType : ")");
        }
Пример #4
0
        public async Task WriteAsync_WithIndents_OmitsTabsAfterWriteAsync(Func <IndentedTextWriter, Task> callWriteAsync, string expected)
        {
            var indicator = new IndicatingTextWriter();
            var itw       = new IndentedTextWriter(indicator, TabString);

            itw.NewLine = NewLine;
            itw.Indent  = 1;

            string prefix = "prefix";
            await itw.WriteAsync(prefix);

            await callWriteAsync(itw);

            Assert.Equal(nameof(IndentedTextWriter.WriteAsync), indicator.LastCalledMethod);
            Assert.Equal($"{prefix}{expected}", indicator.GetStringBuilder().ToString());
        }
Пример #5
0
        public async Task ParameterlessWriteLineAsync_IndentsLinesAfterIndentIsSet()
        {
            var sw  = new StringWriter();
            var itw = new IndentedTextWriter(sw, TabString);

            itw.NewLine = NewLine;
            await itw.WriteLineAsync("Wibble");

            await itw.WriteAsync("Wobble");

            itw.Indent++;
            await itw.WriteLineAsync();

            await itw.WriteLineAsync("Wooble");

            await itw.WriteLineAsync("Qwux");

            string expected = $"Wibble{NewLine}Wobble{NewLine}{TabString}Wooble{NewLine}{TabString}Qwux{NewLine}";

            Assert.Equal(expected, sw.GetStringBuilder().ToString());
        }
Пример #6
0
        internal override async Task Dump(IndentedTextWriter writer)
        {
            await writer.WriteAsync("IF ");

            await this.Expression.Dump(writer);

            await writer.WriteLineAsync(" THEN");

            //await WriteChildren("IF", this.TrueBlock.Statements, writer);
            await this.TrueBlock.Dump(writer);

            //if (this.HasElse)
            //{
            //    await writer.WriteLineAsync("ELSE");
            //    //await WriteChildren("ELSE", this.FalseBlock, writer);
            //    await this.FalseBlock.Dump(writer);
            //}

            await this.NextBlock.Dump(writer, false);

            //else
            //    foreach (var statement in this.FalseBlock)
            //        await statement.Dump(writer);
        }
Пример #7
0
        public static async Task Writes_ProducesExpectedOutput(string newline)
        {
            var sb  = new StringBuilder();
            var sw  = new StringWriter(sb, CultureInfo.InvariantCulture);
            var itw = new IndentedTextWriter(sw, "t");

            itw.Indent  = 1;
            itw.NewLine = newline;
            itw.WriteLine();

            itw.Write(true);
            itw.Write('a');
            itw.Write(new char[] { 'b', 'c' });
            itw.Write(new char[] { 'd', 'e' }, 0, 2);
            itw.Write(4m);
            itw.Write(5.6);
            itw.Write(6.7f);
            itw.Write(8);
            itw.Write(9L);
            itw.Write((object)10);
            itw.Write("11");
            itw.Write(12u);
            itw.Write(13uL);
            itw.Write("{0}", 14);
            itw.Write("{0} {1}", 15, 16);
            itw.Write("{0} {1} {2}", 15, 16, 17);
            itw.Write("{0} {1} {2} {3}", 15, 16, 17, 18);

            itw.WriteLine(true);
            itw.WriteLine('a');
            itw.WriteLine(new char[] { 'b', 'c' });
            itw.WriteLine(new char[] { 'd', 'e' }, 0, 2);
            itw.WriteLine(4m);
            itw.WriteLine(5.6);
            itw.WriteLine(6.7f);
            itw.WriteLine(8);
            itw.WriteLine(9L);
            itw.WriteLine((object)10);
            itw.WriteLine("11");
            itw.WriteLine(12u);
            itw.WriteLine(13uL);
            itw.WriteLine("{0}", 14);
            itw.WriteLine("{0} {1}", 15, 16);
            itw.WriteLine("{0} {1} {2}", 15, 16, 17);
            itw.WriteLine("{0} {1} {2} {3}", 15, 16, 17, 18);

            await itw.WriteAsync('a');

            await itw.WriteAsync(new char[] { 'b', 'c' });

            await itw.WriteAsync(new char[] { 'd', 'e' }, 0, 2);

            await itw.WriteAsync("1");

            await itw.WriteLineAsync('a');

            await itw.WriteLineAsync(new char[] { 'b', 'c' });

            await itw.WriteLineAsync(new char[] { 'd', 'e' }, 0, 2);

            await itw.WriteLineAsync("1");

            itw.WriteLineNoTabs("notabs");

            Assert.Equal(
                "" + newline +
                "tTrueabcde45.66.789101112131415 1615 16 1715 16 17 18True" + newline +
                "ta" + newline +
                "tbc" + newline +
                "tde" + newline +
                "t4" + newline +
                "t5.6" + newline +
                "t6.7" + newline +
                "t8" + newline +
                "t9" + newline +
                "t10" + newline +
                "t11" + newline +
                "t12" + newline +
                "t13" + newline +
                "t14" + newline +
                "t15 16" + newline +
                "t15 16 17" + newline +
                "t15 16 17 18" + newline +
                "tabcde1a" + newline +
                "tbc" + newline +
                "tde" + newline +
                "t1" + newline +
                "notabs" + newline,
                sb.ToString());
        }