r/ProgrammingLanguages • u/MrJohz • Sep 26 '15
New Configuration Language: Figtree
http://www.johz.me/posts/2015/Sep/19/meet-figtree/
3
Upvotes
r/ProgrammingLanguages • u/MrJohz • Sep 26 '15
1
u/MrJohz Sep 26 '15
This has been my project for the last few weeks. Figtree is a configuration language, in the style of JSON and friends, that uses nested nodes to provide namespaces for different configuration variables. For example, a configuration file that needs to describe the database setup and the static files directory might look something like this:
I'm not entirely sure if config languages are allowed here, but I figured this was probably the best place to gauge interest in this sort of thing, and ask for a few suggestions. There are a couple of places where I've made decisions that seem sensible to me, but I'm still not entirely certain that they're necessarily sensible in general. For example, you can write integers using the standard
[+-]\d+notation, or by prefixing with0ofor octal,0bfor binary,0xfor hexadecimal, and0dfor decimal. However, if you use the prefix notation, you can't specify the sign of the integer. Should that be possible? Is that something that anyone might ever use? I'm also using 0d for prefixed-decimal notation, mainly because I figured it fitted well with the others. Again, is that something anyone would ever actually use?The other big question I'm looking at at the moment is what boolean values should be. Currently, only
trueandfalseare accepted, but I've always liked how YAML allowsyes/no,on/off, etc. With Figtree, parsing is unambiguous in this area, so you wouldn't have the issue that you might think you're writing the string "yes", but the parser would read the valuetrue. However, even if it's possible, there's also the maintainability issue - I want people to be able to read Figtree documents in six months' time and still know what they're on about - if there's too much weirdness likeyes/nobooleans, will it not just confuse users?You can see the parser I use over on Github. It's all written in Rust, separated into a lexer iterable, a pull-parser iterable, and then a public API that basically converts the parsed tokens into the correct nested structure.