Headline

Formating data structures such as source code as text

Details

Arguably, pretty printing is a synonym for unparsing. The term pretty printing hints at the fact that the output is supposed to be pretty. Thus, some emphasis is on the formatting rules, whereas we may prefer to speak of unparsing when we focus on mapping a (parse) tree or another data structure to a corresponding string representation. However, in practice, pretty printing and parsing are used often interchangeably.

Illustration

Consider this parse tree of an if-statement, as represented as a Haskell term:

If
  (Eq (Var "x") (Var "y"))
  (Return (Var "i))
  Skip

A pretty printer may yield the following formatted text:

if (x==y)
  return i;

If we make less effort and leave out linebreaks and indentation, we may instead get text like this:

if (x==y) return i;


Ralf Lämmel edited this article at Sat, 20 Jun 2020 14:34:05 +0200
Compare revisions Compare revisions

User contributions

    This user never has never made submissions.

    User edits

    Syntax for editing wiki

    For you are available next options:

    will make text bold.

    will make text italic.

    will make text underlined.

    will make text striked.

    will allow you to paste code headline into the page.

    will allow you to link into the page.

    will allow you to paste code with syntax highlight into the page. You will need to define used programming language.

    will allow you to paste image into the page.

    is list with bullets.

    is list with numbers.

    will allow your to insert slideshare presentation into the page. You need to copy link to presentation and insert it as parameter in this tag.

    will allow your to insert youtube video into the page. You need to copy link to youtube page with video and insert it as parameter in this tag.

    will allow your to insert code snippets from @worker.

    Syntax for editing wiki

    For you are available next options:

    will make text bold.

    will make text italic.

    will make text underlined.

    will make text striked.

    will allow you to paste code headline into the page.

    will allow you to link into the page.

    will allow you to paste code with syntax highlight into the page. You will need to define used programming language.

    will allow you to paste image into the page.

    is list with bullets.

    is list with numbers.

    will allow your to insert slideshare presentation into the page. You need to copy link to presentation and insert it as parameter in this tag.

    will allow your to insert youtube video into the page. You need to copy link to youtube page with video and insert it as parameter in this tag.

    will allow your to insert code snippets from @worker.