pmderodat / ada-toml

TOML parser for Ada
Other
31 stars 5 forks source link

Provide line information where a value is defined #14

Closed stcarrez closed 5 months ago

stcarrez commented 6 months ago

This is an improvement suggestion. It would be nice to know the Source_Location where a TOML_Value is defined in the file.

This is useful when the TOML file is correct but you want to report some configuration error specific to your tool (such as an invalid value, ...).

Example with Alire, if we write an invalid tag somewhere, we get the error:

error: Cannot continue without a workspace:
error:    Loading release from manifest: alire.toml:
error:    Failed to load alire.toml:
error:    Loading release from manifest: alire.toml:
error:    invalid property: 'plop'. Can be: actions, authors, auto-gpr-with, build-profiles, build-switches, configuration, description, environment, executables, gpr-externals, gpr-set-externals, hint, licenses, long-description, maintainers, maintainers-logins, name, notes, project-files, tags, version, website.

I don't think we need the path name since there is no ambiguity on the file name.

pmderodat commented 6 months ago

Hello,

I was originally reluctant to include source location information in TOML_Value since that kind of information isn’t really part of the values themselves: it’s ignored during serialization, comparisons/equality, … and will necessarily be absent for all values that are not created by a parser (for instance for a value created by the Create_Table function).

But at the same time as you noted, this feature would be really useful for most uses of ada-toml, it would be really convenient to track it in TOML_Value and I don’t see other realistic designs… so I’ll give it a try. :-)