Skip to content
This repository has been archived by the owner on Sep 12, 2024. It is now read-only.

Comment support for parsing #28

Open
hrszpuk opened this issue Jun 11, 2024 · 0 comments
Open

Comment support for parsing #28

hrszpuk opened this issue Jun 11, 2024 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@hrszpuk
Copy link
Owner

hrszpuk commented Jun 11, 2024

Lexer supports lexing comments and gives them to the parser. However, the parser ignores them and they are not stored within the config struct or generated during serialisation.

Adding comments to the config would be nice.

One of the issues we might face is how to store comment placement within the config so the serialised output is correct.

Comments can be in the following places:

; empty line comment
[section] ; after section comment
key = value ; after key/value comment

All comments after a section could be stored within that Section/Config and all comments after key/values could be stored within the key/value itself.

An example:
Assuming the following ini config:

; config.ini

key = value ; this is a key value

[section] ; this is a section

; here are my keys
key = value 

The config layout would look like this diagram.
Untitled Diagram drawio

Each comment would be stored in a list in order of their position.
During generation, the list of comments, and the position of the comment within the list, is used to generate a similar INI file:

; config.ini
key = value ; this is a key value

[section] ; this is a section
; here are my keys
key = value 

(notice some whitespace is not accounted for, this is purposefully depicted.)

@hrszpuk hrszpuk added the enhancement New feature or request label Jun 11, 2024
@hrszpuk hrszpuk self-assigned this Jun 11, 2024
@hrszpuk hrszpuk mentioned this issue Jun 12, 2024
11 tasks
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant