public void KleinDefinition_ShouldPrint() { var ast = new Definition ( identifier: new Identifier(0, "main"), typeDeclaration: new BooleanTypeDeclaration(0), formals: new List <Formal> { new Formal(new Identifier(0, "arg1"), new BooleanTypeDeclaration(0)), new Formal(new Identifier(0, "arg2"), new IntegerTypeDeclaration(0)), }, body: new Body(expr: new BooleanLiteral(0, false)) ); Assert.That(PrettyPrinter.ToString(ast), Is.EqualTo( @"Definition(main) Type(Boolean) Formals Formal(arg1) Type(Boolean) Formal(arg2) Type(Integer) Body Expr Boolean(False) ")); }
public override string ToString() { var prettyPrinter = new PrettyPrinter(); Print(prettyPrinter); return(prettyPrinter.ToString()); }
public static string PrintToString(this object me) { var prettyPrinter = new PrettyPrinter(); me.PrintEx(prettyPrinter); return(prettyPrinter.ToString()); }
public void KleinProgram_ShouldPrint() { var ast = new Program( new Definition ( identifier: new Identifier(0, "main"), typeDeclaration: new BooleanTypeDeclaration(0), formals: new List <Formal>(), body: new Body(expr: new BooleanLiteral(0, false)) ), new Definition ( identifier: new Identifier(0, "subsidiary"), typeDeclaration: new IntegerTypeDeclaration(0), formals: new List <Formal>(), body: new Body(expr: new BooleanLiteral(0, false)) ) ); Assert.That(PrettyPrinter.ToString(ast), Is.EqualTo( @"Program Definition(main) Type(Boolean) Formals Body Expr Boolean(False) Definition(subsidiary) Type(Integer) Formals Body Expr Boolean(False) ")); }
public static string PrintToString(this Object thIs) { var prettyPrinter = new PrettyPrinter(); thIs.PrintEx(prettyPrinter); return(prettyPrinter.ToString()); }
public void IntegerLiteral_ShouldPrint() { var ast = new IntegerLiteral(0, "123"); Assert.That(PrettyPrinter.ToString(ast), Is.EqualTo( @"Integer(123) ")); }
public void BooleanLiteral_ShouldPrint() { var ast = new BooleanLiteral(0, true); Assert.That(PrettyPrinter.ToString(ast), Is.EqualTo( @"Boolean(True) ")); }
public void Formal_ShouldPrint() { var ast = new Formal(identifier: new Identifier(0, "arg1"), typeDeclaration: new BooleanTypeDeclaration(0)); Assert.That(PrettyPrinter.ToString(ast), Is.EqualTo( @"Formal(arg1) Type(Boolean) ")); }
public static string PrintToStringNoLimits(this object me) { var prettyPrinter = new PrettyPrinter { CollectionMaxLength = Int32.MaxValue }; me.PrintEx(prettyPrinter); return(prettyPrinter.ToString()); }
public void Actual_ShouldPrint() { var ast = new Actual(new Identifier(0, "x")); Assert.That(PrettyPrinter.ToString(ast), Is.EqualTo( @"Actual Identifier(x) ")); }
private void DisplayAstDifferences(MessageWriter writer, Ast expected, Ast actual) { writer.WriteLine("Expected:"); writer.Write(PrettyPrinter.ToString(expected)); writer.WriteMessageLine(""); writer.WriteLine("But was:"); writer.Write(PrettyPrinter.ToString(actual)); writer.WriteMessageLine(""); }
private void UpdateDisplay() { textview1.Buffer.Text = String.Empty; if (asn == null) { return; } if (pp == null) { pp = new PrettyPrinter(asn); } pp.Options = options; textview1.Buffer.Text = pp.ToString(); Highlight(findhighlight); findfwd = textview1.Buffer.StartIter; findbck = textview1.Buffer.EndIter; // process possible encapsulated ASN.1 element // (i.e. ASN.1 elements contained in other ASN.1 elements) if (options.IncludeEncapsulated) { TextIter start; TextIter end; TextIter search = textview1.Buffer.StartIter; while (search.ForwardSearch(", encapsulates {", tsf, out start, out end, textview1.Buffer.EndIter)) { start.ForwardChars(2); int num1 = 1; while (end.ForwardChar()) { if (end.Char == "}") { num1--; if (num1 == 0) { end.ForwardChar(); break; } continue; } if (end.Char == "{") { num1++; } } textview1.Buffer.ApplyTag(encapsulated, start, end); search = end; } } else { textview1.Buffer.RemoveTag(encapsulated, textview1.Buffer.StartIter, textview1.Buffer.EndIter); } }
public void NegateOperator_ShouldPrint() { var ast = new NegateOperator ( position: 0, right: new Identifier(0, "y") ); Assert.That(PrettyPrinter.ToString(ast), Is.EqualTo( @"Negate Identifier(y) ")); }
protected void After() { SpinWaitEx.SpinUntil(ModelLifetime, 10_000, () => Finished); SpinWaitEx.SpinUntil(ModelLifetime, 1_000, () => false); SocketLifetimeDef.Terminate(); ModelLifetimeDef.Terminate(); using (myOutputFile) { myOutputFile.Write(Printer.ToString()); } }
public void DivideOperator_ShouldPrint() { var ast = new DivideOperator ( position: 0, left: new Identifier(0, "x"), right: new Identifier(0, "y") ); Assert.That(PrettyPrinter.ToString(ast), Is.EqualTo( @"Divide Identifier(x) Identifier(y) ")); }
public void FunctionCall_ShouldPrint() { var ast = new FunctionCall( new Identifier(0, "func"), new List <Actual>() { new Actual(new Identifier(0, "x")), new Actual(new Identifier(0, "y")) } ); Assert.That(PrettyPrinter.ToString(ast), Is.EqualTo( @"FunctionCall(func) Actual Identifier(x) Actual Identifier(y) ")); }
public void IfThenElse_ShouldPrint() { var ast = new IfThenElse ( position: 0, ifExpr: new Identifier(0, "x"), thenExpr: new Identifier(0, "y"), elseExpr: new Identifier(0, "z") ); Assert.That(PrettyPrinter.ToString(ast), Is.EqualTo( @"If Identifier(x) Then Identifier(y) Else Identifier(z) ")); }
public void Body_ShouldPrint_Prints() { var ast = new Body ( new IntegerLiteral(0, "123"), new List <Print> { new Print(0, new Identifier(0, "x")), new Print(0, new Identifier(0, "y")) } ); Assert.That(PrettyPrinter.ToString(ast), Is.EqualTo( @"Body Print Identifier(x) Print Identifier(y) Expr Integer(123) ")); }
public void IntegerTypeDeclaration_ShouldPrint() { var ast = new IntegerTypeDeclaration(0); Assert.That(PrettyPrinter.ToString(ast), Is.EqualTo("Type(Integer)\r\n")); }
public void BooleanTypeDeclaration_ShouldPrint() { var ast = new BooleanTypeDeclaration(0); Assert.That(PrettyPrinter.ToString(ast), Is.EqualTo("Type(Boolean)\r\n")); }
protected override void ProcessRecord() { WriteObject(PrettyPrinter.ToString(Ast)); }