Created
June 27, 2009 11:47
-
-
Save alinpopa/136981 to your computer and use it in GitHub Desktop.
This file contains 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
-module(evaluator_utils). | |
-export([eval_string/1]). | |
eval_string([]) -> []; | |
eval_string(String) -> | |
{ok, Tokens, _} = erl_scan:string(lists:concat([String, "."])), | |
{Status, Term} = erl_parse:parse_term(Tokens), | |
case Status of | |
ok -> {ok, Term}; | |
error -> | |
{_, _, ErrorMessage} = Term, | |
{error, ErrorMessage} | |
end. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment