Skip to content

Instantly share code, notes, and snippets.

@dizzyd
Created January 8, 2010 15:44
Show Gist options
  • Save dizzyd/272113 to your computer and use it in GitHub Desktop.
Save dizzyd/272113 to your computer and use it in GitHub Desktop.
consult_str(eof, Acc) ->
lists:reverse(Acc);
consult_str(B, Acc) ->
case erl_scan:tokens([], B, 0) of
{done, Result, Remaining} ->
case Result of
{ok, Tokens, _} ->
{ok, Term} = erl_parse:parse_term(Tokens),
consult_str(Remaining, [Term | Acc]);
{eof, _} ->
consult_str(eof, Acc);
{error, Info, _} ->
{error, Info}
end;
{more, _Cont} ->
consult_str(eof, Acc)
end.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment