org.kiama.output

PrettyPrinterBase

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. Hide All
  2. Show all
  1. PrettyPrinterBase
  2. AnyRef
  3. Any
Visibility
  1. Public
  2. All

Type Members

  1. abstract type Doc <: DocOps

    The representation type of pretty-printable 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.

  4. type Layout = String

    The final layout of a document

  5. trait PrettyPrintable extends AnyRef

    Interface for pretty-printable values.

  6. type Width = Int

    Output medium width

Abstract Value Members

  1. abstract 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.

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

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

  3. abstract 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.

  4. abstract 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.

  5. abstract 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.

  6. abstract 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.

  7. implicit abstract 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.

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

  7. def angles(d: Doc): Doc

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

  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.

  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.

  10. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  11. def asterisk: Doc

    An asterisk document.

  12. def atsign: Doc

    An at-sign document.

  13. def backquote: Doc

    A backquote document.

  14. def backslash: Doc

    A backslash document.

  15. def braces(d: Doc): Doc

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

  16. def brackets(d: Doc): Doc

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

  17. def caret: Doc

    A caret document.

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

  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.

  20. def clone(): AnyRef

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

    A colon document.

  22. def comma: Doc

    A comma document.

  23. val defaultIndent: Int

    Default indentation is four spaces.

  24. val defaultWidth: Int

    Default layout width is 75 characters.

  25. def dollar: Doc

    A dollar sign document.

  26. def dot: Doc

    A dot (period) document.

  27. def dquote: Doc

    A double quote document.

  28. def dquotes(d: Doc): Doc

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

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

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

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

    Definition Classes
    AnyRef
  31. def equal: Doc

    An equal sign document.

  32. def equals(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  33. def exclamation: Doc

    An exclamation mark document.

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

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

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

  37. def finalize(): Unit

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

    A forward slash document.

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

    Definition Classes
    AnyRef → Any
  40. def hash: Doc

    A hash mark document.

  41. def hashCode(): Int

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

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

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

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

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

  45. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  46. def langle: Doc

    A left angle bracket document.

  47. def lbrace: Doc

    A left brace document.

  48. def lbracket: Doc

    A left square bracket document.

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

  50. def lparen: Doc

    A left parenthesis document.

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

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

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

  54. def minus: Doc

    An minus sign document.

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

    Definition Classes
    AnyRef
  56. final def notify(): Unit

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

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

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

  59. def percent: Doc

    A percent sign document.

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

  61. def plus: Doc

    An plus sign document.

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

  63. def pretty_any(a: Any): Layout

    Pretty-print any value using the any method.

  64. def question: Doc

    A question mark document.

  65. def rangle: Doc

    A right angle bracket document.

  66. def rbrace: Doc

    A right brace document.

  67. def rbracket: Doc

    A right square bracket document.

  68. def rparen: Doc

    A right parenthesis document.

  69. def semi: Doc

    A semicolon document.

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

  71. def softbreak: Doc

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

  72. def softline: Doc

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

  73. def space: Doc

    A space document.

  74. def spaces(n: Int): Doc

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

  75. def squote: Doc

    A single quote document.

  76. def squotes(d: Doc): Doc

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

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

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

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

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

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

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

    Definition Classes
    AnyRef
  82. def tilde: Doc

    A tilde document.

  83. def toString(): String

    Definition Classes
    AnyRef → Any
  84. def underscore: Doc

    An underscore document.

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

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

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

  87. def verticalbar: Doc

    A vertical bar document.

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

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

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

  90. final def wait(): Unit

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

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

    Definition Classes
    AnyRef
    Annotations
    @throws()

Deprecated Value Members

  1. def product(p: Any): Doc

    Annotations
    @deprecated
    Deprecated

    (Since version 1.2.1) Use PrettyPrinter.any instead.

Inherited from AnyRef

Inherited from Any