Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for multiline comments. #32

Open
9 tasks
tacosontitan opened this issue Nov 26, 2024 · 1 comment
Open
9 tasks

Add support for multiline comments. #32

tacosontitan opened this issue Nov 26, 2024 · 1 comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Milestone

Comments

@tacosontitan
Copy link
Owner

tacosontitan commented Nov 26, 2024

Multiline comments in JSON are defined in the same way they are in JavaScript:

Comment
    : Delimited_Comment
    ;
    
fragment Delimited_Comment
    : '/*' Delimited_Comment_Section* ASTERISK+ '/'
    ;
    
fragment Delimited_Comment_Section
    : SLASH
    | ASTERISK* Not_Slash_Or_Asterisk
    ;

fragment Not_Slash_Or_Asterisk
    : ~('/' | '*')    // Any except SLASH or ASTERISK
    ;

👆🏻 single-line comment lexical structure excluded.

This issue requests the addition of support for multiline comments to the JSON library even though they aren't an official part of the spec. Many developers still add comments to JSON files and the JsonLexer could simply discard those, but that's likely a better decision for the consumer to make instead.

Acceptance Criteria

  • JsonLexer returns CommentToken for multiline comments.
  • Column number advances when horizontal movement is captured.
  • Line number advances when vertical movement is captured.
    • Column number is reset to 0 when line number advances.
  • Captured comments exclude leading/trailing whitespace.
    • 👆🏻 should be configurable.
    • 👆🏻 as a whole.
    • 👆🏻 per line.
  • Test coverage for implementation.
@tacosontitan tacosontitan converted this from a draft issue Nov 26, 2024
@tacosontitan tacosontitan added enhancement New feature or request help wanted Extra attention is needed labels Nov 26, 2024
@tacosontitan tacosontitan added this to the JSON milestone Nov 26, 2024
@tacosontitan
Copy link
Owner Author

Related: #31

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
Status: Ready for Work
Development

No branches or pull requests

1 participant