Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

Parse erlang config file loaded into binary

View parse_erlang.erl
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
parse(Text) when is_binary(Text) ->
parse(binary_to_list(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, _} ->
lists:reverse(Acc)
end.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.