Created
April 17, 2012 08:42
-
-
Save voluntas/2404659 to your computer and use it in GitHub Desktop.
nodetool
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%% | |
%% Given a string or binary, parse it into a list of terms, ala file:consult/0 | |
%% | |
consult(Str) when is_list(Str) -> | |
consult([], Str, []); | |
consult(Bin) when is_binary(Bin)-> | |
consult([], binary_to_list(Bin), []). | |
consult(Cont, Str, Acc) -> | |
case erl_scan:tokens(Cont, Str, 0) of | |
{done, Result, Remaining} -> | |
case Result of | |
{ok, Tokens, _} -> | |
{ok, Term} = erl_parse:parse_term(Tokens), | |
consult([], Remaining, [Term | Acc]); | |
{eof, _Other} -> | |
lists:reverse(Acc); | |
{error, Info, _} -> | |
{error, Info} | |
end; | |
{more, Cont1} -> | |
consult(Cont1, eof, Acc) | |
end. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
rel/files/nodetool にあるし ...