seanjensengrey / kiama

Automatically exported from code.google.com/p/kiama
GNU Lesser General Public License v3.0
0 stars 0 forks source link

Allow the pretty printing newline replacement document to be customised #58

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
When a pretty-printed group is rendered, line breaks in the group may be 
omitted, depending on how things fit on the output line. At the moment, if a 
line break is omitted it is always replaced by an empty document. Sometimes it 
is desirable to replace it with some other document. E.g., for pretty-printing 
Scala we could replace line breaks with semicolons.

This feature is inspired by a similar feature in the gnieh-pp library by Lucas 
Sabatin.

Original issue reported on code.google.com by inkytonik on 22 Jan 2013 at 10:15

GoogleCodeExporter commented 9 years ago

Original comment by inkytonik on 22 Jan 2013 at 10:15

GoogleCodeExporter commented 9 years ago
The "line (repl)" method is now part of the pretty-printer API so the 
replacement string can be customised (rf9d6a7847f1d).

We could go further and allow an arbitrary document to specify the replacement. 
For now we stick to strings since that is easy to implement and covers the 
obvious use cases.

We can revisit the arbitrary document case in the future if we can find use 
cases where this is needed. Presumably we would have to recursively 
pretty-print the replacement document on a single line to get the replacement 
string. Allowing newlines in the replacement seems wrong since we are replacing 
a line break. The main question is whether this additional implementation 
complexity is worth it.

Original comment by inkytonik on 16 Feb 2013 at 11:56