filipegoncalves / rust-config

Configuration file library in Rust similar to C/C++'s libconfig
MIT License
20 stars 10 forks source link

libconfig compatibility: trailing commas not permitted in lists #18

Open sp3d opened 8 years ago

sp3d commented 8 years ago

The following configuration file is parsed by the C/C++ libconfig library as a list with two groups:

foo = (
    {
        key="val";
    },
    {
        key="val2";
    },
);

but rust-config treats it as a syntax error due to the trailing comma after the second closing curly brace. It would be nice if it were accepted so the behaviors were identical between the two libraries. Personally, I think trailing commas are just nice in general, since they make diffs cleaner.

I don't believe this behavior of libconfig is actually documented: their grammar for lists looks like it would reject trailing commas. When I get time to investigate fully, I'll submit a bug on that project to have the grammar updated to match reality.

I also need to check whether libconfig accepts trailing commas in arrays; I expect it to but don't know for sure.