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

iniconf: some more adjustments for parsing TOML #4099

Merged
merged 3 commits into from
Nov 7, 2024

Conversation

techee
Copy link
Contributor

@techee techee commented Oct 13, 2024

These two patches:

  • improve parsing of TOML [[arrays_of_tables]]
  • support 'single quoted keys' = true and "double quoted keys" = true

See the individual commits for more details.

Copy link

codecov bot commented Oct 13, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 85.85%. Comparing base (ecf0c4a) to head (ae09350).
Report is 20 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4099      +/-   ##
==========================================
+ Coverage   85.72%   85.85%   +0.12%     
==========================================
  Files         239      239              
  Lines       56961    58629    +1668     
==========================================
+ Hits        48827    50333    +1506     
- Misses       8134     8296     +162     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@techee
Copy link
Contributor Author

techee commented Nov 3, 2024

@masatake Any opinion on this pull request?

@masatake
Copy link
Member

masatake commented Nov 5, 2024

Sorry for the late reply.

My primary question is whether this pull request intends a bug fix or a hack for adjusting the Iniconf parser to TOML.

We provide a PEG-based TOML parser. So modifying the Iniconf parser for supporting TOML is not a standard practice. This is my baseline to evaluate this pull request.

On the other hand, the TOML parser doesn't work well (#4096). As you were afraid, I'm not familiar with PEG enough so I have not fixed the simple bug yet. So I don't ask you to use the TOMP parser. Hacking Iniconf for supporting TOML makes sense.

But this is still a hack. So I have some requests. Please, see my review comments.

parsers/iniconf.c Outdated Show resolved Hide resolved
parsers/iniconf.c Show resolved Hide resolved
@techee
Copy link
Contributor Author

techee commented Nov 5, 2024

My primary question is whether this pull request intends a bug fix or a hack for adjusting the Iniconf parser to TOML.

You are right, I want to use this parser for parsing TOML in Geany so it's kind of hack. On the other hand, it's not such a hack - there's no formal ini specification so I think what I propose is still a valid ini. The way I understand ini files intuitively is:

  1. [section name]\n for sections
  2. whatever=whatever\n for value assignments

So in fact, I believe the key name it could be any character sequence (with stripped leading and trailing spaces). And for the section name it should be the first [ and the last ] that count as section delimiters, the rest is the section name.

In any case, no problem to add the changes you propose.

For TOML array of tables like

[[array]]

this change creates the tag [array] instead of the previously created
tag [array
This allows TOML

"key in double quotes" = 1
'key in single quotes' = 2
@techee techee force-pushed the iniconf_toml2 branch 2 times, most recently from 4fc5ddb to a0cc4df Compare November 6, 2024 21:32
@masatake
Copy link
Member

masatake commented Nov 7, 2024

Thank you for updating. I have one more request to change. See my comment.

On the other hand, it's not such a hack - there's no formal ini specification so I think what I propose is still a valid ini.

I see. However, the updated version of this pull request looks more understandable.

@masatake masatake merged commit b6d1cac into universal-ctags:master Nov 7, 2024
69 checks passed
@masatake
Copy link
Member

masatake commented Nov 7, 2024

Thank you.

techee added a commit to techee/geany that referenced this pull request Nov 7, 2024
This patch:

- improve parsing of TOML [[arrays_of_tables]]
- adds support for 'single quoted keys' = true and
  "double quoted keys" = true

See universal-ctags/ctags#4099
techee added a commit to techee/geany that referenced this pull request Nov 10, 2024
This patch:

- allows . and - in keys
- improve parsing of TOML [[arrays_of_tables]]
- adds support for 'single quoted keys' = true and
  "double quoted keys" = true

See universal-ctags/ctags#4099
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants