Formatting comments with semicolon newlines #272

Open
opened 2019-12-10 20:52:08 +01:00 by bredelings · 0 comments
bredelings commented 2019-12-10 20:52:08 +01:00 (Migrated from github.com)

Hi, thank you for implementing newlines for semicolons! This might be more complicated, but I wonder if it might be possible to handle comments intermingled with the semicolons.

Suppose we have

do {
; A
;
;-- This is a comment
;
; B
}

Right now this gets indented like this:

do
   A--This is a comment
   B

First, it seems that if there are any comments mixed in with the semicolons, then the comments are retained, but the newlines are lost. Would it be possible to make the semi-colon -> newline translation work when there are comments embedded?

(Note, I think in some cases A--comment would not be parsed as a comment, but if we have e.g. let x=y--comment, then --comment is indeed parsed as a comment.)

Second, this might be too messy, but would it be possible to handle cases where we have a line like

;--comment

and indent the comment to the level of the ;?

My apologies for the complication, but would be useful (to me at least) when trying to generate Haskell code with comments. That is, ideally, I would be able to write

do {
;-- part 1
;A
;
;-- part 2
;B
}

and get

do
  -- part 1
  A

  --part 2
  B
Hi, thank you for implementing newlines for semicolons! This might be more complicated, but I wonder if it might be possible to handle comments intermingled with the semicolons. Suppose we have ``` do { ; A ; ;-- This is a comment ; ; B } ``` Right now this gets indented like this: ``` do A--This is a comment B ``` First, it seems that if there are any comments mixed in with the semicolons, then the comments are retained, but the newlines are lost. Would it be possible to make the semi-colon -> newline translation work when there are comments embedded? (Note, I think in some cases `A--comment` would not be parsed as a comment, but if we have e.g. let x=y--comment, then `--comment` is indeed parsed as a comment.) Second, this might be too messy, but would it be possible to handle cases where we have a line like ``` ;--comment ``` and indent the comment to the level of the `;`? My apologies for the complication, but would be useful (to me at least) when trying to generate Haskell code with comments. That is, ideally, I would be able to write ``` do { ;-- part 1 ;A ; ;-- part 2 ;B } ``` and get ``` do -- part 1 A --part 2 B ```
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: hexagoxel/brittany#272
There is no content yet.