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.
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.)
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:
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:
The config layout would look like this diagram.
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:
(notice some whitespace is not accounted for, this is purposefully depicted.)