Strange formatting of comments
- Dominant language
- ANTLR
- Stars
- 47
- Forks
- 18
- PR merge metrics
- No merged PRs in 30d
Description
Unfortunately javadoc style multiline comments preceding a rule cause a strange formatting effect. The following rule is moved to just after the comment ending. Also, multiple single line comments are indented and extra lines are added.
```
grammar Funny;
/**
This is a funny grammar that confuses Antlr4Formatter
*/
test : 'a' 'b' 'c' test2 EOF;
//
// test number 2
//
test2 : '1' '2' '3';
```
turns into
```
grammar Funny;
/**
This is a funny grammar that confuses Antlr4Formatter
*/ test
: 'a' 'b' 'c' test2 EOF
;
//
// test number 2
//
test2
: '1' '2' '3'
;
```
This seems very odd to me. I'm not sure if this is intentional or not.
Contributor guide
No contributing guide indexed for this repository
Research direction
Reproduce the issue with the Funny grammar shown in the report, focusing on a Javadoc comment before a rule and consecutive single-line comments. Trace the Antlr4Formatter entry point that formats comments and rules; done means comments retain their placement and indentation without extra blank lines or a rule being joined to a comment terminator.
Written by the indexing model from the issue text.
Assessment
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100