inkytonik / sbt-rats

sbt-rats provides a plugin that enables the Rats! parser generator to be used in Scala projects.
Other
1 stars 2 forks source link

Wishlist: PrettyPrinting "line break within list" #8

Open inkytonik opened 4 years ago

inkytonik commented 4 years ago

Peter Höfner says:

this is a super minor issue. It's about Pretty printing. I would love to have a line break (\n) after every item of a list. That means I would like to have something like Example = '' nestnl(Lst)\n ''. Lst = 'Item,'\n'Item'. where Lst should be replaced by a list.

I can write Example = '' nestnl(Lst2)\n ''. Lst2 = Item++',\n'. which has two draw backs (a) it requires a line break for parsing as well (not only when pretty printing) (b) the outcome looks like " Item, Item "; that means nesting is not preserved.

Again: really only on my wish list; nothing major.

inkytonik commented 4 years ago

It's not exactly what you suggest, but have you tried the {line} directive on rules? Here is the description from the docs:

A common situation arises when you want to place all instances of a construct on separate lines (unless they fit together). To specify this behaviour you can add a line annotation to the relevant rule. It is equivalent to placing a \n at the beginning of each alternative in the rule.

Stm {line} = ...