3 ms·
To elaborate on userbinator's comment, you want to think of your format as a set of definitions: A clause consists of a '{', one or more key-value pairs, and a
by akkartik 10y ago
To elaborate on userbinator's comment, you want to think of your format as a set of definitions:
A clause consists of a '{', one or more key-value pairs, and a '}'.
A key-value pair consists of a string and a value.
A value is either a string or a clause.
Now turn each definition into a function.
Here's a nice-looking article from Googling for "writing a recursive descent parser": http://weblog.jamisbuck.org/2015/7/30/writing-a-simple-recursive-descent-parser.html http://weblog.jamisbuck.org/2015/7/30/writing-a-simple-recur...