pmderodat / ada-toml Goto Github PK
View Code? Open in Web Editor NEWTOML parser for Ada
License: Other
TOML parser for Ada
License: Other
Looking at this in toml.ads
we have
procedure Set (Value : TOML_Value; Key : String; Entry_Value : TOML_Value)
with Pre => Value.Kind = TOML_Table;
-- Create an entry in Value to bind Key to Entry_Value. If Value already
-- has an entry for Key, replace it.
In other words, the intent is to modify Value
.
Now, TOML_Value
is a tagged type and therefore passed by reference, so since Set
only touches the internals it appears to work.
However, here in alire-user_pins.adb
we have
function To_TOML (This : Pin) return TOML.TOML_Value is
use TOML;
Table : constant TOML_Value := Create_Table;
begin
[...]
Table.Set (Keys.Path,
Create_String (VFS.Attempt_Portable (Path (This))));
Table.Set (Keys.Internal, Create_Boolean (True));
return Table;
end To_TOML;
and the compiler is entitled to ignore the two Table.Set
calls -- which claim not to alter Table
- and return the unmodified Table
(it being constant
).
I have a strong suspicion that this is exactly what is happening with alire built on Apple M1 (aarch64).
There are several other similar subprograms.
See the output of exporting, e.g., the description of libhello:
$ cat alire/libhello.toml
(...)
description = ""Hello, world!" demonstration project support library"
(...)
I noticed some problems with arrays:
echo 'a = ["a", "b"]' | obj-checkers/ada_toml_decode
-> OK
echo 'a = [0, 1]' | obj-checkers/ada_toml_decode
-> 1:6: invalid token
echo 'a = [[0], [1]]' | obj-checkers/ada_toml_decode
-> 1:7: invalid token
echo 'a = [["a"], ["b"]]' | obj-checkers/ada_toml_decode
-> OK
I'm using ada-toml in my utility alr_appimage, and I'm getting a weird error when processing a file in UTF-8 format, like https://github.com/jfuica/bingada/blob/master/alire.toml:
Error: while loading alire.toml: 5: 31: invalid UTF-8 encoding
I'm using latest version in Alire index (0.3.0).
Alire also uses this library to load the same file without problem.
Could it be that the default Alire switches are now not compatible with how this library is loading the file? I guess that in order to work like in Alire, this commit should be included and a new release made:
Is there any problem impending the merge of that change?
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.
I've found that master
branch accepts these examples with the obvious intended meaning of creating a table:
one.two = false
or the actual case where I found it:
[[one]]
two.three = false
but these are rejected by the Python and JS parsers, and the haskell validator.
See this stackoverflow post I made for a bit more detail.
Please see this issue raised on Alire.
$ head -1 alire/libhello.toml
[1.0.0] # should be ['1.0.0']
Tested on v0.2
:
$ cat test.toml
[[a.b]]
c = 0
[[a]]
c = 1
$ cat test.toml | obj-checkers/ada_toml_decode
raised SYSTEM.ASSERTIONS.ASSERT_FAILURE : failed precondition from toml.ads:229
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.