public void Print(LNode node, StringBuilder target, IMessageSink sink = null, ParsingMode mode = null, ILNodePrinterOptions options = null) { if (_usePlainCsPrinter) EcsNodePrinter.PrintPlainCSharp(node, target, sink, mode, options); else EcsNodePrinter.PrintECSharp(node, target, sink, mode, options); }
public Les2PrinterOptions(ILNodePrinterOptions options) { if (options != null) { CopyFrom(options); } }
/// <summary>Prints an LNode as LESv3 with HTML syntax highlighting elements.</summary> /// <param name="nodes">Syntax trees to print.</param> /// <param name="output">Output StringBuilder for HTML code.</param> /// <param name="addPreCode">Whether to wrap the output in "<pre class='highlight'><code>" tags.</param> /// <param name="options">Options to control the style for code printing.</param> /// <returns>The output StringBuilder</returns> public static StringBuilder PrintToHtml( IEnumerable <ILNode> nodes, StringBuilder output = null, bool addPreCode = true, IMessageSink sink = null, ILNodePrinterOptions options = null) { var pp = new Les3PrettyPrinter(sink, options); return(pp.PrintToHtml(nodes, output, addPreCode)); }
public Les3PrinterOptions(ILNodePrinterOptions options) { WarnAboutUnprintableLiterals = true; SpaceAfterComma = true; ForcedLineBreakThreshold = 120; if (options != null) { CopyFrom(options); } }
public void CopyFrom(ILNodePrinterOptions original) { AllowChangeParentheses = original.AllowChangeParentheses; OmitComments = original.OmitComments; OmitUnknownTrivia = original.OmitUnknownTrivia; PrintTriviaExplicitly = original.PrintTriviaExplicitly; CompatibilityMode = original.CompatibilityMode; CompactMode = original.CompactMode; IndentString = original.IndentString; NewlineString = original.NewlineString; }
/// <summary>Converts a sequences of LNodes to strings, adding a line separator between each.</summary> /// <param name="printer">Printer to be used for each single LNode.</param> /// <remarks>The newline between two nodes is suppressed if the second /// node has a <c>#trivia_appendStatement</c> attribute.</remarks> public static StringBuilder PrintMultiple(ILNodePrinter printer, IEnumerable<LNode> nodes, StringBuilder sb, IMessageSink sink, ParsingMode mode, ILNodePrinterOptions options) { sb = sb ?? new StringBuilder(); var lineSeparator = (options != null ? options.NewlineString : null) ?? "\n"; bool first = true; foreach (LNode node in nodes) { if (!first) sb.Append(node.AttrNamed(CodeSymbols.TriviaAppendStatement) == null ? lineSeparator : " "); printer.Print(node, sb, sink, mode, options); first = false; } return sb; }
/// <summary>Creates an instance of this class, which produces plain LES /// augmented with control codes.</summary> public Les3PrettyPrinter(IMessageSink sink = null, ILNodePrinterOptions options = null) : this(null, sink, options) { }
/// <summary>Creates an instance of this class, which produces plain LES /// augmented with control codes.</summary> public Les3PrettyPrinter(StringBuilder target, IMessageSink sink, ILNodePrinterOptions options) : base(target, sink, options) { }
public void Print(ILNode node, StringBuilder target, IMessageSink sink = null, ParsingMode mode = null, ILNodePrinterOptions options = null) { Les2Printer.Print(node, target, sink, mode, options); }
public string Print(ILNode node, IMessageSink sink = null, ParsingMode mode = null, ILNodePrinterOptions options = null) { StringBuilder target = new StringBuilder(); Print(node, target, sink, mode, options); return(target.ToString()); }
public void Print(IEnumerable <ILNode> nodes, StringBuilder target, IMessageSink sink = null, ParsingMode mode = null, ILNodePrinterOptions options = null) { CheckParam.IsNotNull("target", target); var p = new Les3Printer(target, sink, options); p.Print(nodes); }
void ILNodePrinter.Print(LNode node, StringBuilder target, IMessageSink sink, ParsingMode mode, ILNodePrinterOptions options) { Print((ILNode)node, target, sink, mode, options); }
public void SetOptions(ILNodePrinterOptions options) { _o = options as Les2PrinterOptions ?? new Les2PrinterOptions(options); }
internal Les2Printer(StringBuilder target, ILNodePrinterOptions options = null) { SetOptions(options); Writer = new Les2PrinterWriter(target, _o.IndentString ?? "\t", _o.NewlineString ?? "\n"); }
/// <summary>Serializes a list of syntax trees to a string in the /// syntax supported by the specified <see cref="ILNodePrinter"/>.</summary> public static string Print(this ILNodePrinter printer, IEnumerable<LNode> nodes, IMessageSink sink = null, ParsingMode mode = null, ILNodePrinterOptions options = null) { StringBuilder target = new StringBuilder(); printer.Print(nodes, target, sink, mode, options); return target.ToString(); }
public void Print(LNode node, StringBuilder target, IMessageSink sink = null, ParsingMode mode = null, ILNodePrinterOptions options = null) { if (_usePlainCsPrinter) { EcsNodePrinter.PrintPlainCSharp(node, target, sink, mode, options); } else { EcsNodePrinter.PrintECSharp(node, target, sink, mode, options); } }
/// <summary>Prints an LNode as LESv3 with HTML syntax highlighting elements.</summary> /// <param name="nodes">Syntax trees to print.</param> /// <param name="output">Output StringBuilder for HTML code.</param> /// <param name="addPreCode">Whether to wrap the output in "<pre class='highlight'><code>" tags.</param> /// <param name="options">Options to control the style for code printing.</param> /// <returns>The output StringBuilder</returns> public static StringBuilder PrintToHtml( IEnumerable<ILNode> nodes, StringBuilder output = null, bool addPreCode = true, IMessageSink sink = null, ILNodePrinterOptions options = null) { var pp = new Les3PrettyPrinter(sink, options); return pp.PrintToHtml(nodes, output, addPreCode); }
/// <summary>Serializes a list of syntax trees to a string in the /// syntax supported by the specified <see cref="ILNodePrinter"/>.</summary> public static string Print(this ILNodePrinter printer, IEnumerable <LNode> nodes, IMessageSink sink = null, ParsingMode mode = null, ILNodePrinterOptions options = null) { StringBuilder target = new StringBuilder(); printer.Print(nodes, target, sink, mode, options); return(target.ToString()); }
public void Print(IEnumerable<ILNode> nodes, StringBuilder target, IMessageSink sink = null, ParsingMode mode = null, ILNodePrinterOptions options = null) { CheckParam.IsNotNull("target", target); var p = new Les3Printer(target, sink, options); p.Print(nodes); }
/// <summary>Converts a sequences of LNodes to strings, adding a line separator between each.</summary> /// <param name="printer">Printer to be used for each single LNode.</param> /// <remarks>The newline between two nodes is suppressed if the second /// node has a <c>%appendStatement</c> attribute.</remarks> public static StringBuilder PrintMultiple(ILNodePrinter printer, IEnumerable <LNode> nodes, StringBuilder sb, IMessageSink sink, ParsingMode mode, ILNodePrinterOptions options) { sb = sb ?? new StringBuilder(); var lineSeparator = (options != null ? options.NewlineString : null) ?? "\n"; bool first = true; foreach (LNode node in nodes) { if (!first) { sb.Append(node.AttrNamed(CodeSymbols.TriviaAppendStatement) == null ? lineSeparator : " "); } printer.Print(node, sb, sink, mode, options); first = false; } return(sb); }
void ILNodePrinter.Print(IEnumerable <LNode> nodes, StringBuilder target, IMessageSink sink, ParsingMode mode, ILNodePrinterOptions options) { Print(nodes.Upcast <ILNode, LNode>(), target, sink, mode, options); }
public void Print(IEnumerable <LNode> nodes, StringBuilder target, IMessageSink sink = null, ParsingMode mode = null, ILNodePrinterOptions options = null) { LNodePrinter.PrintMultiple(this, nodes, target, sink, mode, options); }
internal static void Print(ILNode node, StringBuilder target, IMessageSink sink, ParsingMode mode, ILNodePrinterOptions options = null) { var p = _printer = _printer ?? new Les2Printer(TextWriter.Null, null); var oldOptions = p._o; var oldWriter = p.Writer; var oldSink = p.ErrorSink; p.ErrorSink = sink; p.SetOptions(options); p.Writer = new Les2PrinterWriter(target, p.Options.IndentString ?? "\t", p.Options.NewlineString ?? "\n"); if (mode == ParsingMode.Expressions) { p.Print(node, StartStmt, ""); } else { p.Print(node, StartStmt, ";"); } p.Writer = oldWriter; p._o = oldOptions; p.ErrorSink = oldSink; }
public void Print(IEnumerable<LNode> nodes, StringBuilder target, IMessageSink msgs = null, ParsingMode mode = null, ILNodePrinterOptions options = null) { LNodePrinter.PrintMultiple(this, nodes, target, msgs, mode, options); }
void ILNodePrinter.Print(IEnumerable<LNode> nodes, StringBuilder target, IMessageSink sink, ParsingMode mode, ILNodePrinterOptions options) { Print(nodes.Upcast<ILNode, LNode>(), target, sink, mode, options); }