Trait

org.bitbucket.inkytonik.kiama.output

PrettyPrinterBase

Related Doc: package output

Permalink

trait PrettyPrinterBase extends AnyRef

The interface of a pretty printer using combinators from Swierstra and Chitil (Linear, bounded, functional pretty-printing, Journal of Functional Programming, 19 (1), 2009) and Leijen's PPrint library. The latter is a version of Wadler's library which was inspired by an earlier library by Hughes.

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

Type Members

  1. abstract type Doc <: DocOps

    Permalink

    The representation type of pretty-printable documents.

  2. trait DocOps extends AnyRef

    Permalink

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

Abstract Value Members

  1. abstract def column(f: (Int) ⇒ Doc): Doc

    Permalink

    Return the document produced by f when it is passed the column at which rendering is currently placed.

  2. abstract def emptyDoc: Doc

    Permalink

    An empty document.

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

  3. abstract def group(d: Doc): Doc

    Permalink

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

  4. abstract def line(repl: Layout): Doc

    Permalink

    A document representing a potential line break.

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

  5. abstract def line: Doc

    Permalink

    A document representing a potential line break.

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

  6. abstract def linebreak: Doc

    Permalink

    A document representing a potential line break.

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

  7. abstract def link(n: AnyRef, d: Doc): Doc

    Permalink

    Return a document that prints as d but also records the fact that the printed representation of d is linked to n.

    Return a document that prints as d but also records the fact that the printed representation of d is linked to n. The positions of that pretty-printed representation can be retrieved via the position information in the Document returned when this Doc is pretty-printed.

  8. abstract def nest(d: Doc, j: Indent = defaultIndent): Doc

    Permalink

    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.

  9. abstract def nesting(f: (Int) ⇒ Doc): Doc

    Permalink

    Return the document produced by f when it is passed the nesting level (indentation) of the current line.

  10. abstract def pretty(d: Doc, w: Width = defaultWidth): Document

    Permalink

    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.

  11. implicit abstract def text(t: String): Doc

    Permalink

    Convert a string to a document.

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

Concrete Value Members

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

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

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

    Permalink
    Definition Classes
    AnyRef → Any
  4. def align(d: Doc): Doc

    Permalink

    Return a document that renders d with the nesting level set to the current indentation column.

  5. def ampersand: Doc

    Permalink

    An ampersand document.

  6. def angles(d: Doc): Doc

    Permalink

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

  7. def any(a: Any): Doc

    Permalink

    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 value on a. null prints as null.

  8. def arguments[T](l: Seq[T], elemToDoc: (T) ⇒ Doc = (x : T) => value(x), sep: Doc = comma, sepfn: (Seq[Doc], Doc) ⇒ Doc = lsep): Doc

    Permalink

    Return a document that pretty-prints a sequence as a Scala argument list.

    Return a document that pretty-prints a sequence as a Scala argument list. The arguments are parenthesized and pretty-printed using sepfn (default: lsep). Each element of the list is pretty-printed using elemToDoc (default: value). The separator defaults to a comma.

  9. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  10. def asterisk: Doc

    Permalink

    An asterisk document.

  11. def atsign: Doc

    Permalink

    An at-sign document.

  12. def backquote: Doc

    Permalink

    A backquote document.

  13. def backslash: Doc

    Permalink

    A backslash document.

  14. def braces(d: Doc): Doc

    Permalink

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

  15. def brackets(d: Doc): Doc

    Permalink

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

  16. def caret: Doc

    Permalink

    A caret document.

  17. def cat(ds: Seq[Doc]): Doc

    Permalink

    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 <@@>.

  18. implicit def char(c: Char): Doc

    Permalink

    Convert a character to a document.

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

  19. def clone(): AnyRef

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

    Permalink

    A colon document.

  21. def comma: Doc

    Permalink

    A comma document.

  22. val defaultIndent: Int

    Permalink

    Default indentation is four spaces.

  23. val defaultWidth: Int

    Permalink

    Default layout width is 75 characters.

  24. def dollar: Doc

    Permalink

    A dollar sign document.

  25. def dot: Doc

    Permalink

    A dot (period) document.

  26. def dquote: Doc

    Permalink

    A double quote document.

  27. def dquotes(d: Doc): Doc

    Permalink

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

  28. def enclose(l: Doc, d: Doc, r: Doc): Doc

    Permalink

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

  29. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  30. def equal: Doc

    Permalink

    An equal sign document.

  31. def equals(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  32. def exclamation: Doc

    Permalink

    An exclamation mark document.

  33. def fillcat(ds: Seq[Doc]): Doc

    Permalink

    Return a document that concatenates the documents in the given sequence horizontally with <> until they don't fit the output width, then inserts a line break and continues to the end of the sequence.

  34. def fillsep(ds: Seq[Doc], sep: Doc): Doc

    Permalink

    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 <+>.

  35. def fillsep(ds: Seq[Doc]): Doc

    Permalink

    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.

  36. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  37. def folddoc(ds: Seq[Doc], f: (Doc, Doc) ⇒ Doc): Doc

    Permalink

    Return a document that is the result of folding f over the sequence ds.

    Return a document that is the result of folding f over the sequence ds. Returns the empty document is ds is empty.

  38. def forwslash: Doc

    Permalink

    A forward slash document.

  39. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  40. def hang(d: Doc, i: Indent = defaultIndent): Doc

    Permalink

    Return a document that is like d but whose second and subsequent lines have hanging indentation of i spaces (defaults to the deafult indentation).

    Return a document that is like d but whose second and subsequent lines have hanging indentation of i spaces (defaults to the deafult indentation). In other words, the first line is indented at the current nesting level and the remaining lines are indented i spaces more.

  41. def hash: Doc

    Permalink

    A hash mark document.

  42. def hashCode(): Int

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

    Permalink

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

  44. def hsep(ds: Seq[Doc], sep: Doc): Doc

    Permalink

    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 <+>.

  45. def hsep(ds: Seq[Doc]): Doc

    Permalink

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

  46. def indent(d: Doc, i: Indent = defaultIndent): Doc

    Permalink

    Return a document that is d but with the first line indented by i more spaces.

  47. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  48. def langle: Doc

    Permalink

    A left angle bracket document.

  49. def layout(d: Doc, w: Width = defaultWidth): Layout

    Permalink

    Pretty-print a document as per pretty but just return the layout.

  50. def lbrace: Doc

    Permalink

    A left brace document.

  51. def lbracket: Doc

    Permalink

    A left square bracket document.

  52. def links(d: Doc, w: Width = defaultWidth): Links

    Permalink

    Pretty-print a document as per pretty but just return the links.

  53. def list[T](l: List[T], prefix: String = "List", elemToDoc: (T) ⇒ Doc = (x : T) => value(x), sep: Doc = comma, sepfn: (Seq[Doc], Doc) ⇒ Doc = lsep): Doc

    Permalink

    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 same as calling seq with a prefix of "List" and passing all other arguments through.

  54. def lparen: Doc

    Permalink

    A left parenthesis document.

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

    Permalink

    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.

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

    Permalink

    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.

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

    Permalink

    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.

  58. def minus: Doc

    Permalink

    An minus sign document.

  59. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  60. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  61. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  62. def padto(p: Int, d: Doc): Doc

    Permalink

    Return a document that pads d out to a width of p.

    Return a document that pads d out to a width of p. If d already has a width greater than or equal to d, don't add any padding. This combinator is called fill in the PPrint library.

  63. def padtobreak(p: Int, d: Doc): Doc

    Permalink

    As for padto but if the document width is already greater than or equal to p, insert a possible line break and new nesting level instead of not adding any padding.

    As for padto but if the document width is already greater than or equal to p, insert a possible line break and new nesting level instead of not adding any padding. This combinator is called fillBreak in the PPrint library.

  64. def parens(d: Doc): Doc

    Permalink

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

  65. def percent: Doc

    Permalink

    A percent sign document.

  66. def plus: Doc

    Permalink

    An plus sign document.

  67. def question: Doc

    Permalink

    A question mark document.

  68. def rangle: Doc

    Permalink

    A right angle bracket document.

  69. def rbrace: Doc

    Permalink

    A right brace document.

  70. def rbracket: Doc

    Permalink

    A right square bracket document.

  71. def rparen: Doc

    Permalink

    A right parenthesis document.

  72. def semi: Doc

    Permalink

    A semicolon document.

  73. def sep(ds: Seq[Doc]): Doc

    Permalink

    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 <@>.

  74. def seq[T](l: Seq[T], prefix: String = "Seq", elemToDoc: (T) ⇒ Doc = (x : T) => value(x), sep: Doc = comma, sepfn: (Seq[Doc], Doc) ⇒ Doc = lsep): Doc

    Permalink

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

    Return a document that pretty-prints a sequence in Scala notation, inserting line breaks between elements as necessary. The same as pretty-printing the prefix followed by a space, then using arguments to pretty-print the content of the sequence, passing all other arguments through.

  75. def softbreak: Doc

    Permalink

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

  76. def softline: Doc

    Permalink

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

  77. def space: Doc

    Permalink

    A space document.

  78. def spaces(n: Int): Doc

    Permalink

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

  79. def squote: Doc

    Permalink

    A single quote document.

  80. def squotes(d: Doc): Doc

    Permalink

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

  81. def ssep(ds: Seq[Doc], sep: Doc): Doc

    Permalink

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

  82. def sterm(ds: Seq[Doc], term: Doc): Doc

    Permalink

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

  83. def string(s: String): Doc

    Permalink

    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.

  84. def surround(d: Doc, b: Doc): Doc

    Permalink

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

  85. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  86. def tilde: Doc

    Permalink

    A tilde document.

  87. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  88. def underscore: Doc

    Permalink

    An underscore document.

  89. def value(v: Any): Doc

    Permalink

    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.

  90. def vcat(ds: Seq[Doc]): Doc

    Permalink

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

  91. def verticalbar: Doc

    Permalink

    A vertical bar document.

  92. def vsep(ds: Seq[Doc], sep: Doc): Doc

    Permalink

    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 <@>.

  93. def vsep(ds: Seq[Doc]): Doc

    Permalink

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

  94. final def wait(): Unit

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

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

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  97. def width(d: Doc, f: (Int) ⇒ Doc): Doc

    Permalink

    Return a document that renders d beside the document obtained by running f on the width of d.

Inherited from AnyRef

Inherited from Any

Ungrouped