Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Enable Erlson syntax in Erlang shell

To do this, just run erlson:init().
  • Loading branch information...
commit 407af5ee6ef734714e2653228017a4293fc18dd3 1 parent fa812e5
@alavrik authored
Showing with 19 additions and 0 deletions.
  1. +19 −0 src/erlson.erl
View
19 src/erlson.erl
@@ -23,6 +23,8 @@
% Erlson runtime library
%
-module(erlson).
+
+-export([init/0]).
-export([fetch/2, store/3]).
@@ -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.
+
Please sign in to comment.
Something went wrong with that request. Please try again.