Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Parse erlang config file loaded into binary
parse(Text) when is_binary(Text) ->
parse(Text) when is_list(Text) ->
parse(Text, [], 0, []).
parse(Text, Env, Line, Acc) ->
case erl_scan:tokens([], Text, Line) of
{done, {ok, Scanned, NewLine}, Rest} ->
{ok, Parsed} = erl_parse:parse_exprs(Scanned),
{value, Out, NewEnv} = erl_eval:exprs(Parsed, Env),
parse(Rest, NewEnv, NewLine, [Out|Acc]);
{more, _} ->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment