Skip to content

Commit

Permalink
Enable Erlson syntax in Erlang shell
Browse files Browse the repository at this point in the history
To do this, just run erlson:init().
  • Loading branch information
alavrik committed Jul 10, 2011
1 parent fa812e5 commit 407af5e
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/erlson.erl
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
% Erlson runtime library
%
-module(erlson).

-export([init/0]).
-export([fetch/2, store/3]).


Expand Down Expand Up @@ -60,3 +62,20 @@ fetch_val(_Name, _) ->
store(Name, Value, Dict) ->
orddict:store(Name, Value, Dict).


% Enable Erlson syntax in Erlang shell
init() ->
case code:get_object_code(erl_parse_shell) of
{_, Code, File} ->
code:unstick_dir(filename:dirname(File)),
case code:load_binary(erl_parse, File, Code) of
{module, _Name} -> ok;
{error, Reason} ->
exit({erlson_error,
{"failed to load erl_parse_shell.beam", Reason}})
end;
error ->
exit({erlson_error,
"failed to load code from erl_parse_shell.beam"})
end.

0 comments on commit 407af5e

Please sign in to comment.