public void CancelEscrowPreventsOutputOfPendingLine() { var writer = new StringWriter(); var source = new SourceWriter(writer); source .WriteLine() .WriteLine("begin") .AddIndent() .WriteLine("if") .AddIndent() .WriteLine("do this") .RemoveIndent() .EscrowLine("endif") .ClearEscrowLine() .WriteLine("else") .AddIndent() .WriteLine("do that") .RemoveIndent() .EscrowLine("endif") .RemoveIndent() .WriteLine("done"); Assert.That(source.ToString(), Is.EqualTo(@" begin if do this else do that endif done ")); }
public void VisitChunk(IChunkVisitor visitor, OutputLocation location, IList<Chunk> body, StringBuilder output) { if (location == OutputLocation.ClassMembers) { foreach (var snippet in body.OfType<CodeStatementChunk>().SelectMany(chunk => chunk.Code)) { snippet.Value = snippet.Value.Replace("@class", "class"); } var source = new SourceWriter(new StringWriter(output)); var generator = new GeneratedCodeVisitor(source, new Dictionary<string, object>(), NullBehaviour.Strict); generator.Accept(body); } }
public void IndentationShouldAddLeadingSpace() { var writer = new StringWriter(); var source = new SourceWriter(writer); source .WriteLine() .WriteLine("one") .AddIndent() .WriteLine("two") .RemoveIndent() .WriteLine("three"); Assert.That(source.ToString(), Is.EqualTo(@" one two three ")); }
public void EscrowLineWritesFirstAtIndentationWhenItWasAdded() { var writer = new StringWriter(); var source = new SourceWriter(writer); source.WriteLine().AddIndent(); source .WriteLine("one") .AddIndent() .WriteLine("two") .EscrowLine("two-b") .RemoveIndent() .WriteLine("three") .RemoveIndent(); Assert.That(source.ToString(), Is.EqualTo(@" one two two-b three ")); }
public GlobalFunctionsVisitor(SourceWriter source, IDictionary<string, object> globals) { _source = source; _globals = globals; }
public GeneratedCodeVisitor(SourceWriter source, IDictionary<string, object> globals) { _source = source; _variables = new VariableTracker(globals); }
public GlobalInitializeVisitor(SourceWriter sourceWriter) { _source = sourceWriter; }
public GlobalMembersVisitor(SourceWriter sourceWriter, Dictionary<string, object> globals) { _source = sourceWriter; _globals = globals; }