org.kiama.util

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), 2008) and Leijen's PPrint library. The latter is a version of Wadler's library which was inspired by an earlier library by Hughes.

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. type Doc <: DocOps

    The representation type of pretty-printable documents.

    The representation type of pretty-printable documents.

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

    Attributes
    abstract
  2. 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.

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

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

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

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

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

    Attributes
    abstract

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

  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
  8. def asInstanceOf [T0] : T0

    Attributes
    final
    Definition Classes
    Any
  9. def backslash : Doc

    A backslash document.

  10. def braces (d: Doc): Doc

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

  11. def brackets (d: Doc): Doc

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

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

  13. def char (c: Char): Doc

    Convert a character to a document.

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

  14. def clone (): AnyRef

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

    A colon document.

  16. def comma : Doc

    A comma document.

  17. val defaultIndent : Int

    Default indentation is four spaces.

  18. val defaultWidth : Int

    Default layout width is 75 characters.

  19. def dot : Doc

    A dot (period) document.

  20. def dquote : Doc

    A double quote document.

  21. def dquotes (d: Doc): Doc

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

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

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

  23. def eq (arg0: AnyRef): Boolean

    Attributes
    final
    Definition Classes
    AnyRef
  24. def equal : Doc

    An equal sign document.

  25. def equals (arg0: Any): Boolean

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

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

  28. def finalize (): Unit

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

    A forward slash document.

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

    Attributes
    final
    Definition Classes
    AnyRef
  31. def hashCode (): Int

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

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

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

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

  34. def isInstanceOf [T0] : Boolean

    Attributes
    final
    Definition Classes
    Any
  35. def langle : Doc

    A left angle bracket document.

  36. def lbrace : Doc

    A left brace document.

  37. def lbracket : Doc

    A left square bracket document.

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

  39. def lparen : Doc

    A left parenthesis document.

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

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

  42. def ne (arg0: AnyRef): Boolean

    Attributes
    final
    Definition Classes
    AnyRef
  43. def notify (): Unit

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

    Attributes
    final
    Definition Classes
    AnyRef
  45. def parens (d: Doc): Doc

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

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

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

  48. def rangle : Doc

    A right angle bracket document.

  49. def rbrace : Doc

    A right brace document.

  50. def rbracket : Doc

    A right square bracket document.

  51. def rparen : Doc

    A right parenthesis document.

  52. def semi : Doc

    A semicolon document.

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

  54. def softbreak : Doc

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

  55. def softline : Doc

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

  56. def space : Doc

    A space document.

  57. def spaces (n: Int): Doc

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

  58. def squote : Doc

    A single quote document.

  59. def squotes (d: Doc): Doc

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

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

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

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

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

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

  64. def synchronized [T0] (arg0: ⇒ T0): T0

    Attributes
    final
    Definition Classes
    AnyRef
  65. def toString (): String

    Definition Classes
    AnyRef → Any
  66. def value (v: Any): Doc

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

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

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

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

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

  69. def wait (): Unit

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

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

    Attributes
    final
    Definition Classes
    AnyRef
    Annotations
    @throws()

Inherited from AnyRef

Inherited from Any