justinmk / tree-sitter-ini

tree-sitter grammar/parser for INI files
Apache License 2.0
20 stars 10 forks source link

comment characters embedded (quoted) in names or values #12

Open gregnis opened 2 months ago

gregnis commented 2 months ago

Example:

[Misc]
Show '# Of Diffs' column message=1

Result:

document [0, 0] - [3, 0]
  section [0, 0] - [1, 0]
    section_name [0, 0] - [1, 0]
      text [0, 1] - [0, 5]
  ERROR [1, 0] - [1, 6]
    setting_name [1, 0] - [1, 6]
  comment [1, 6] - [2, 0]
    text [1, 7] - [1, 34]
gregnis commented 2 months ago

You may ask whether it's legal, and I couldn't find any information on this. All I know is that I have them in my INI files, and that Windows GetPrivateProfileString() handles such key without problems.

justinmk commented 2 months ago

This conflicts with https://github.com/justinmk/tree-sitter-ini/issues/13

Need a clear spec one way or the other. Else we're just fumbling around and will do unexpected things depending on the INI "flavor". A spec for each "flavor" would be a starting point.

'# Of Diffs' implies quote-parsing. What does Windows GetPrivateProfileString() do with the following?

[Misc]
Show '# Of Diffs column message=1
Show # Of Diffs' column message=2
gregnis commented 2 months ago

'# Of Diffs' implies quote-parsing. What does Windows GetPrivateProfileString() do with the following?

[Misc]
Show '# Of Diffs column message=1
Show # Of Diffs' column message=2

It fails in both cases (uses the default value). Still, it does succeed and reads "1" for

[Misc]
Show '# Of Diffs' column message=1

and if you follow the recommendation of https://stackoverflow.com/a/19550081/152142 to use GetPrivateProfileString as a de facto reference, it would make sense to implement this.