org.kiama.util

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 (defaults to 4). defaultWidth specifies the default output medium width (defaults to 75).

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. def != (arg0: AnyRef): Boolean

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

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

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

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

    Attributes
    final
    Definition Classes
    Any
  6. 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
  7. 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-print using the value combinator.

    Attributes
    implicit
    Definition Classes
    PrettyPrinterBase
  8. def asInstanceOf [T0] : T0

    Attributes
    final
    Definition Classes
    Any
  9. def backslash : Doc

    A backslash document.

    A backslash document.

    Definition Classes
    PrettyPrinterBase
  10. 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
  11. def brackets (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
  12. 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
  13. 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
  14. def clone (): AnyRef

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

    A colon document.

    A colon document.

    Definition Classes
    PrettyPrinterBase
  16. def comma : Doc

    A comma document.

    A comma document.

    Definition Classes
    PrettyPrinterBase
  17. val defaultIndent : Int

    Default indentation is four spaces.

    Default indentation is four spaces.

    Definition Classes
    PrettyPrinterBase
  18. val defaultWidth : Int

    Default layout width is 75 characters.

    Default layout width is 75 characters.

    Definition Classes
    PrettyPrinterBase
  19. def dot : Doc

    A dot (period) document.

    A dot (period) document.

    Definition Classes
    PrettyPrinterBase
  20. def dquote : Doc

    A double quote document.

    A double quote document.

    Definition Classes
    PrettyPrinterBase
  21. 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
  22. 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
  23. 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
  24. def eq (arg0: AnyRef): Boolean

    Attributes
    final
    Definition Classes
    AnyRef
  25. def equal : Doc

    An equal sign document.

    An equal sign document.

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

    Definition Classes
    AnyRef → Any
  27. 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
  28. 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
  29. def finalize (): Unit

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

    A forward slash document.

    A forward slash document.

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

    Attributes
    final
    Definition Classes
    AnyRef
  32. 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
  33. def hashCode (): Int

    Definition Classes
    AnyRef → Any
  34. 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
  35. 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
  36. def isInstanceOf [T0] : Boolean

    Attributes
    final
    Definition Classes
    Any
  37. def langle : Doc

    A left angle bracket document.

    A left angle bracket document.

    Definition Classes
    PrettyPrinterBase
  38. def lbrace : Doc

    A left brace document.

    A left brace document.

    Definition Classes
    PrettyPrinterBase
  39. def lbracket : Doc

    A left square bracket document.

    A left square bracket document.

    Definition Classes
    PrettyPrinterBase
  40. 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
  41. 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
  42. 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: call the element's toDoc method). sep defaults to a comma.

    Definition Classes
    PrettyPrinterBase
  43. def lparen : Doc

    A left parenthesis document.

    A left parenthesis document.

    Definition Classes
    PrettyPrinterBase
  44. 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 a space if omitted.

    Definition Classes
    PrettyPrinterBase
  45. 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 a space if omitted. The end line break turns into nothing if omitted.

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

    Attributes
    final
    Definition Classes
    AnyRef
  47. 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
  48. def notify (): Unit

    Attributes
    final
    Definition Classes
    AnyRef
  49. def notifyAll (): Unit

    Attributes
    final
    Definition Classes
    AnyRef
  50. 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
  51. 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
  52. 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
  53. def product (p: Any): Doc

    Return a pretty-printer document for p.

    Return a pretty-printer document for p. If p is a Product, print it in standard prefix list form, otherwise use p's toDoc method. As a special case, print lists as List (...) and Nil instead of using ::. Also, strings are printed with surrounding double quotes.

    Definition Classes
    PrettyPrinterBase
  54. def rangle : Doc

    A right angle bracket document.

    A right angle bracket document.

    Definition Classes
    PrettyPrinterBase
  55. def rbrace : Doc

    A right brace document.

    A right brace document.

    Definition Classes
    PrettyPrinterBase
  56. def rbracket : Doc

    A right square bracket document.

    A right square bracket document.

    Definition Classes
    PrettyPrinterBase
  57. def rparen : Doc

    A right parenthesis document.

    A right parenthesis document.

    Definition Classes
    PrettyPrinterBase
  58. def semi : Doc

    A semicolon document.

    A semicolon document.

    Definition Classes
    PrettyPrinterBase
  59. 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
  60. 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
  61. 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
  62. def space : Doc

    A space document.

    A space document.

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

    Return a document representing n spaces if n > 0, otherwise return an empty document.

    Return a document representing n spaces if n > 0, otherwise return an empty document.

    Definition Classes
    PrettyPrinterBase
  64. def squote : Doc

    A single quote document.

    A single quote document.

    Definition Classes
    PrettyPrinterBase
  65. 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
  66. 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
  67. 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
  68. 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
  69. 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
  70. def synchronized [T0] (arg0: ⇒ T0): T0

    Attributes
    final
    Definition Classes
    AnyRef
  71. 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
  72. def toString (): String

    Definition Classes
    AnyRef → Any
  73. 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.

    Definition Classes
    PrettyPrinterBase
  74. 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
  75. 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
  76. def wait (): Unit

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

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

    Attributes
    final
    Definition Classes
    AnyRef
    Annotations
    @throws()

Inherited from PrettyPrinterBase

Inherited from AnyRef

Inherited from Any