org.kiama.output

PrettyPrinter

trait PrettyPrinter extends PrettyPrinterBase

A pretty-printer implemented using the continuation-based approach from Section 3.3 of Swierstra, S., and Chitil, O. Linear, bounded, functional pretty-printing. Journal of Functional Programming 19, 01 (2008), 1–16.

defaultIndent specifies the indentation to use if none is specified in uses of the nest method (default: 4). defaultWidth specifies the default output width (default: 75).

Source
PrettyPrinter.scala
Linear Supertypes
PrettyPrinterBase, AnyRef, Any
Known Subclasses
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. Hide All
  2. Show all
  1. PrettyPrinter
  2. PrettyPrinterBase
  3. AnyRef
  4. Any
Visibility
  1. Public
  2. All

Type Members

  1. class Doc extends ((Indent, Width)) ⇒ ((Int, Queue[(Int, (Boolean) ⇒ ((Int) ⇒ Layout) ⇒ (Int) ⇒ Layout)]) ⇒ (Int) ⇒ Layout) ⇒ (Int, Queue[(Int, (Boolean) ⇒ ((Int) ⇒ Layout) ⇒ (Int) ⇒ Layout)]) ⇒ (Int) ⇒ Layout with DocOps

    Continuation representation of documents.

  2. trait DocOps extends AnyRef

    The operations provided by a pretty-printable document that don't depend on the document's representation type.

  3. type Indent = Int

    Indentation is expressed as integer space units.

    Indentation is expressed as integer space units.

    Definition Classes
    PrettyPrinterBase
  4. type Layout = String

    The final layout of a document

    The final layout of a document

    Definition Classes
    PrettyPrinterBase
  5. trait PrettyPrintable extends AnyRef

    Interface for pretty-printable values.

  6. type Width = Int

    Output medium width

    Output medium width

    Definition Classes
    PrettyPrinterBase

Value Members

  1. final def !=(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  2. final def !=(arg0: Any): Boolean

    Definition Classes
    Any
  3. final def ##(): Int

    Definition Classes
    AnyRef → Any
  4. final def ==(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  5. final def ==(arg0: Any): Boolean

    Definition Classes
    Any
  6. def ampersand: Doc

    An ampersand document.

    An ampersand document.

    Definition Classes
    PrettyPrinterBase
  7. def angles(d: Doc): Doc

    Return a document that encloses a given document between left and right angle brackets.

    Return a document that encloses a given document between left and right angle brackets.

    Definition Classes
    PrettyPrinterBase
  8. def any(a: Any): Doc

    Generic pretty-printer document for any type of value.

    Generic pretty-printer document for any type of value. If a is a Vector, Map, List or Product, print it in a prefix list style, with the exception that Nil prints as Nil. Tuples are pretty-printed using arrow notation. Strings are pretty-printed surrounded by double quotes. If none of these cases apply, use the toDoc method on a. null prints as null.

    Definition Classes
    PrettyPrinterBase
  9. implicit def anyToPrettyPrintable(a: Any): PrettyPrintable

    Convert any value into a pretty-printable value.

    Convert any value into a pretty-printable value. The value will be pretty-printed using the value combinator.

    Definition Classes
    PrettyPrinterBase
  10. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  11. def asterisk: Doc

    An asterisk document.

    An asterisk document.

    Definition Classes
    PrettyPrinterBase
  12. def atsign: Doc

    An at-sign document.

    An at-sign document.

    Definition Classes
    PrettyPrinterBase
  13. def backquote: Doc

    A backquote document.

    A backquote document.

    Definition Classes
    PrettyPrinterBase
  14. def backslash: Doc

    A backslash document.

    A backslash document.

    Definition Classes
    PrettyPrinterBase
  15. def braces(d: Doc): Doc

    Return a document that encloses a given document between left and right braces.

    Return a document that encloses a given document between left and right braces.

    Definition Classes
    PrettyPrinterBase
  16. def brackets(d: Doc): Doc

    Return a document that encloses a given document between left and right square brackets.

    Return a document that encloses a given document between left and right square brackets.

    Definition Classes
    PrettyPrinterBase
  17. def caret: Doc

    A caret document.

    A caret document.

    Definition Classes
    PrettyPrinterBase
  18. def cat(ds: Seq[Doc]): Doc

    Return a document that concatenates the documents in the given sequence either horizontally with <> if they fit in the output medium width, or if not, vertically with <@@>.

    Return a document that concatenates the documents in the given sequence either horizontally with <> if they fit in the output medium width, or if not, vertically with <@@>.

    Definition Classes
    PrettyPrinterBase
  19. implicit def char(c: Char): Doc

    Convert a character to a document.

    Convert a character to a document. The character can be a newline.

    Definition Classes
    PrettyPrinterBase
  20. def clone(): AnyRef

    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws()
  21. def colon: Doc

    A colon document.

    A colon document.

    Definition Classes
    PrettyPrinterBase
  22. def comma: Doc

    A comma document.

    A comma document.

    Definition Classes
    PrettyPrinterBase
  23. val defaultIndent: Int

    Default indentation is four spaces.

    Default indentation is four spaces.

    Definition Classes
    PrettyPrinterBase
  24. val defaultWidth: Int

    Default layout width is 75 characters.

    Default layout width is 75 characters.

    Definition Classes
    PrettyPrinterBase
  25. def dollar: Doc

    A dollar sign document.

    A dollar sign document.

    Definition Classes
    PrettyPrinterBase
  26. def dot: Doc

    A dot (period) document.

    A dot (period) document.

    Definition Classes
    PrettyPrinterBase
  27. def dquote: Doc

    A double quote document.

    A double quote document.

    Definition Classes
    PrettyPrinterBase
  28. def dquotes(d: Doc): Doc

    Return a document that encloses a given document between double quotes.

    Return a document that encloses a given document between double quotes.

    Definition Classes
    PrettyPrinterBase
  29. def empty: Doc

    An empty document.

    An empty document. This is a left and right unit for the concatenation method. Called nil in the paper.

    Definition Classes
    PrettyPrinterPrettyPrinterBase
  30. def enclose(l: Doc, d: Doc, r: Doc): Doc

    Return a document that encloses a given document between left and right documents.

    Return a document that encloses a given document between left and right documents.

    Definition Classes
    PrettyPrinterBase
  31. final def eq(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  32. def equal: Doc

    An equal sign document.

    An equal sign document.

    Definition Classes
    PrettyPrinterBase
  33. def equals(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  34. def exclamation: Doc

    An exclamation mark document.

    An exclamation mark document.

    Definition Classes
    PrettyPrinterBase
  35. def fillcat(ds: Seq[Doc]): Doc

    Return a document that concatenates the documents in the given sequence horizontally with <> as long as they fit the output width, then inserts a linebreak and continues to the end of the sequence.

    Return a document that concatenates the documents in the given sequence horizontally with <> as long as they fit the output width, then inserts a linebreak and continues to the end of the sequence.

    Definition Classes
    PrettyPrinterBase
  36. def fillsep(ds: Seq[Doc], sep: Doc): Doc

    Return a document that concatenates the documents in the given sequence horizontally with <+> as long as they fit the output width, then inserts a line and continues with the rest of the sequence.

    Return a document that concatenates the documents in the given sequence horizontally with <+> as long as they fit the output width, then inserts a line and continues with the rest of the sequence. Separates documents with the given separator before the <+>.

    Definition Classes
    PrettyPrinterBase
  37. def fillsep(ds: Seq[Doc]): Doc

    Return a document that concatenates the documents in the given sequence horizontally with <+> as long as they fit the output width, then inserts a line and continues with the rest of the sequence.

    Return a document that concatenates the documents in the given sequence horizontally with <+> as long as they fit the output width, then inserts a line and continues with the rest of the sequence.

    Definition Classes
    PrettyPrinterBase
  38. def finalize(): Unit

    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws()
  39. def forwslash: Doc

    A forward slash document.

    A forward slash document.

    Definition Classes
    PrettyPrinterBase
  40. final def getClass(): java.lang.Class[_]

    Definition Classes
    AnyRef → Any
  41. def group(d: Doc): Doc

    A document representing a choice among different ways to print a structure.

    A document representing a choice among different ways to print a structure.

    Definition Classes
    PrettyPrinterPrettyPrinterBase
  42. def hash: Doc

    A hash mark document.

    A hash mark document.

    Definition Classes
    PrettyPrinterBase
  43. def hashCode(): Int

    Definition Classes
    AnyRef → Any
  44. def hcat(ds: Seq[Doc]): Doc

    Return a document that concatenates the documents in the given sequence horizontally with <>.

    Return a document that concatenates the documents in the given sequence horizontally with <>.

    Definition Classes
    PrettyPrinterBase
  45. def hsep(ds: Seq[Doc], sep: Doc): Doc

    Return a document that concatenates the documents in the given sequence horizontally with <+>.

    Return a document that concatenates the documents in the given sequence horizontally with <+>. Separates documents with the given separator before the <+>.

    Definition Classes
    PrettyPrinterBase
  46. def hsep(ds: Seq[Doc]): Doc

    Return a document that concatenates the documents in the given sequence horizontally with <+>.

    Return a document that concatenates the documents in the given sequence horizontally with <+>.

    Definition Classes
    PrettyPrinterBase
  47. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  48. def langle: Doc

    A left angle bracket document.

    A left angle bracket document.

    Definition Classes
    PrettyPrinterBase
  49. def lbrace: Doc

    A left brace document.

    A left brace document.

    Definition Classes
    PrettyPrinterBase
  50. def lbracket: Doc

    A left square bracket document.

    A left square bracket document.

    Definition Classes
    PrettyPrinterBase
  51. def line: Doc

    A document representing a potential line break.

    A document representing a potential line break. Behaves like space if the break is omitted by a group.

    Definition Classes
    PrettyPrinterPrettyPrinterBase
  52. def linebreak: Doc

    A document representing a potential line break.

    A document representing a potential line break. Behaves like empty if the break is omitted by a group.

    Definition Classes
    PrettyPrinterPrettyPrinterBase
  53. def list[T](l: List[T], prefix: String, elemToDoc: (T) ⇒ Doc, sep: Doc, sepfn: (Seq[Doc], Doc) ⇒ Doc): Doc

    Return a document that pretty-prints a list in Scala notation, inserting line breaks between elements as necessary.

    Return a document that pretty-prints a list in Scala notation, inserting line breaks between elements as necessary. The prefix string can be changed from the default "List". The elemToDoc argument can be used to alter the way each element is converted to a document (default: use the value combinator). sep defaults to comma.

    Definition Classes
    PrettyPrinterBase
  54. def lparen: Doc

    A left parenthesis document.

    A left parenthesis document.

    Definition Classes
    PrettyPrinterBase
  55. def lsep(ds: Seq[Doc], sep: Doc): Doc

    Return a pretty-printer document for a separated sequence.

    Return a pretty-printer document for a separated sequence. sep is the separator. Line breaks are allowed before the sequence and after the separators between the elements of the sequence. The before line break turns into nothing if omitted. The internal line breaks turn into space if omitted.

    Definition Classes
    PrettyPrinterBase
  56. def lsep2(ds: Seq[Doc], sep: Doc): Doc

    Return a pretty-printer document for a separated sequence.

    Return a pretty-printer document for a separated sequence. sep is the separator. Line breaks are allowed before the separators between the elements of the sequence and at the end. A space is inserted after each separator. The internal line breaks turn into space if omitted. The end line break turns into nothing if omitted.

    Definition Classes
    PrettyPrinterBase
  57. def lterm(ds: Seq[Doc], term: Doc): Doc

    Return a pretty-printer document for a sequence where each element is terminated by term.

    Return a pretty-printer document for a sequence where each element is terminated by term. Line breaks are allowed before the sequence and after the terminator between the elements of the sequence. The before line break turns into nothing if omitted. The internal line breaks turn into space if omitted.

    Definition Classes
    PrettyPrinterBase
  58. def minus: Doc

    An minus sign document.

    An minus sign document.

    Definition Classes
    PrettyPrinterBase
  59. final def ne(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  60. def nest(d: Doc, j: Indent = defaultIndent): Doc

    Nest a document by an indentation increment on top of the current nesting.

    Nest a document by an indentation increment on top of the current nesting. In the paper version, the indentation parameter comes first, but we put it second here so that it can be given a default value.

    Definition Classes
    PrettyPrinterPrettyPrinterBase
  61. final def notify(): Unit

    Definition Classes
    AnyRef
  62. final def notifyAll(): Unit

    Definition Classes
    AnyRef
  63. def parens(d: Doc): Doc

    Return a document that encloses a given document between left and right parentheses.

    Return a document that encloses a given document between left and right parentheses.

    Definition Classes
    PrettyPrinterBase
  64. def percent: Doc

    A percent sign document.

    A percent sign document.

    Definition Classes
    PrettyPrinterBase
  65. def plist(l: List[PrettyPrintable], prefix: String = "List", elemToDoc: (PrettyPrintable) ⇒ Doc = _.toDoc, sep: Doc = comma, sepfn: (Seq[Doc], Doc) ⇒ Doc = lsep): Doc

    Return a document that pretty-prints a list of pretty-printables in Scala notation, inserting line breaks between elements as necessary.

    Return a document that pretty-prints a list of pretty-printables in Scala notation, inserting line breaks between elements as necessary. The prefix string can be changed from the default "List". The elemToDoc argument can be used to alter the way each element is converted to a document (default: call the element's toDoc method). sep defaults to a comma.

    Definition Classes
    PrettyPrinterBase
  66. def plus: Doc

    An plus sign document.

    An plus sign document.

    Definition Classes
    PrettyPrinterBase
  67. def pretty(d: Doc, w: Width = defaultWidth): Layout

    Pretty print a document assuming a given output medium width.

    Pretty print a document assuming a given output medium width. In the paper the width is the first parameter, but here we put it second so we can provide a default value.

    Definition Classes
    PrettyPrinterPrettyPrinterBase
  68. def pretty(p: PrettyPrintable): Layout

    Pretty-print a pretty-printable value.

    Pretty-print a pretty-printable value. If the value passed is not a pretty-printable document, it will be converted to one using the implicit conversion anyToPrettyPrintable.

    Definition Classes
    PrettyPrinterBase
  69. def pretty_any(a: Any): Layout

    Pretty-print any value using the any method.

    Pretty-print any value using the any method.

    Definition Classes
    PrettyPrinterBase
  70. def question: Doc

    A question mark document.

    A question mark document.

    Definition Classes
    PrettyPrinterBase
  71. def rangle: Doc

    A right angle bracket document.

    A right angle bracket document.

    Definition Classes
    PrettyPrinterBase
  72. def rbrace: Doc

    A right brace document.

    A right brace document.

    Definition Classes
    PrettyPrinterBase
  73. def rbracket: Doc

    A right square bracket document.

    A right square bracket document.

    Definition Classes
    PrettyPrinterBase
  74. def rparen: Doc

    A right parenthesis document.

    A right parenthesis document.

    Definition Classes
    PrettyPrinterBase
  75. def semi: Doc

    A semicolon document.

    A semicolon document.

    Definition Classes
    PrettyPrinterBase
  76. def sep(ds: Seq[Doc]): Doc

    Return a document that concatenates the documents in the given sequence either horizontally with <+> if they fit in the output medium width, or if not, vertically with <@>.

    Return a document that concatenates the documents in the given sequence either horizontally with <+> if they fit in the output medium width, or if not, vertically with <@>.

    Definition Classes
    PrettyPrinterBase
  77. def softbreak: Doc

    Return a document that behaves like empty if the resulting output fits the page, otherwise it behaves like line.

    Return a document that behaves like empty if the resulting output fits the page, otherwise it behaves like line.

    Definition Classes
    PrettyPrinterBase
  78. def softline: Doc

    Return a document that behaves like space if the resulting output fits the page, otherwise it behaves like line.

    Return a document that behaves like space if the resulting output fits the page, otherwise it behaves like line.

    Definition Classes
    PrettyPrinterBase
  79. def space: Doc

    A space document.

    A space document.

    Definition Classes
    PrettyPrinterBase
  80. def spaces(n: Int): Doc

    Return a document representing n spaces if n s greater than zero, otherwise return an empty document.

    Return a document representing n spaces if n s greater than zero, otherwise return an empty document.

    Definition Classes
    PrettyPrinterBase
  81. def squote: Doc

    A single quote document.

    A single quote document.

    Definition Classes
    PrettyPrinterBase
  82. def squotes(d: Doc): Doc

    Return a document that encloses a given document between single quotes.

    Return a document that encloses a given document between single quotes.

    Definition Classes
    PrettyPrinterBase
  83. def ssep(ds: Seq[Doc], sep: Doc): Doc

    Return a document that concatenates the documents in the given sequence and separates adjacent documents with sep with no space around the separator.

    Return a document that concatenates the documents in the given sequence and separates adjacent documents with sep with no space around the separator.

    Definition Classes
    PrettyPrinterBase
  84. def sterm(ds: Seq[Doc], term: Doc): Doc

    Return a document that concatenates the documents in the given sequence and terminates each document with term.

    Return a document that concatenates the documents in the given sequence and terminates each document with term.

    Definition Classes
    PrettyPrinterBase
  85. def string(s: String): Doc

    Convert a string to a document.

    Convert a string to a document. The string is allowed to contain newline characters. If no newlines are included, it is best to use text directly instead.

    Definition Classes
    PrettyPrinterBase
  86. def surround(d: Doc, b: Doc): Doc

    Return a document that encloses a given document d between two occurrences of another document b.

    Return a document that encloses a given document d between two occurrences of another document b.

    Definition Classes
    PrettyPrinterBase
  87. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  88. implicit def text(t: String): Doc

    Convert a string to a document.

    Convert a string to a document. The string should not contain any newline characters. Use line instead.

    Definition Classes
    PrettyPrinterPrettyPrinterBase
  89. def tilde: Doc

    A tilde document.

    A tilde document.

    Definition Classes
    PrettyPrinterBase
  90. def toString(): String

    Definition Classes
    AnyRef → Any
  91. def underscore: Doc

    An underscore document.

    An underscore document.

    Definition Classes
    PrettyPrinterBase
  92. def value(v: Any): Doc

    Return a document representing a value formatted using toString and the string combinator.

    Return a document representing a value formatted using toString and the string combinator. As a special case, if the value is a null reference it is formatted as null.

    Definition Classes
    PrettyPrinterBase
  93. def vcat(ds: Seq[Doc]): Doc

    Return a document that concatenates the documents in the given sequence vertically with <@@>.

    Return a document that concatenates the documents in the given sequence vertically with <@@>.

    Definition Classes
    PrettyPrinterBase
  94. def verticalbar: Doc

    A vertical bar document.

    A vertical bar document.

    Definition Classes
    PrettyPrinterBase
  95. def vsep(ds: Seq[Doc], sep: Doc): Doc

    Return a document that concatenates the documents in the given sequence vertically with <@>.

    Return a document that concatenates the documents in the given sequence vertically with <@>. Separates documents with the given separator before the <@>.

    Definition Classes
    PrettyPrinterBase
  96. def vsep(ds: Seq[Doc]): Doc

    Return a document that concatenates the documents in the given sequence vertically with <@>.

    Return a document that concatenates the documents in the given sequence vertically with <@>.

    Definition Classes
    PrettyPrinterBase
  97. final def wait(): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws()
  98. final def wait(arg0: Long, arg1: Int): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws()
  99. final def wait(arg0: Long): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws()

Deprecated Value Members

  1. def product(p: Any): Doc

    Definition Classes
    PrettyPrinterBase
    Annotations
    @deprecated
    Deprecated

    (Since version 1.2.1) Use PrettyPrinter.any instead.

Inherited from PrettyPrinterBase

Inherited from AnyRef

Inherited from Any