Framework and tests for code generation (icode/fcode) errors

This commit is contained in:
Ulf Norell
2019-09-03 10:21:37 +02:00
parent f2469a676d
commit 510935d945
20 changed files with 481 additions and 208 deletions
+8 -1
View File
@@ -34,6 +34,7 @@
, pos/2
, pos/3
, pp/1
, throw/1
, type/1
]).
@@ -49,6 +50,12 @@ pos(Line, Col) ->
pos(File, Line, Col) ->
#pos{ file = File, line = Line, col = Col }.
throw([]) -> ok;
throw(Errs) when is_list(Errs) ->
erlang:throw({error, Errs});
throw(#err{} = Err) ->
erlang:throw({error, [Err]}).
msg(#err{ message = Msg, context = none }) -> Msg;
msg(#err{ message = Msg, context = Ctxt }) -> Msg ++ Ctxt.
@@ -68,4 +75,4 @@ pp(#err{ pos = Pos } = Err) ->
pp_pos(#pos{file = no_file, line = L, col = C}) ->
io_lib:format("At line ~p, col ~p:", [L, C]);
pp_pos(#pos{file = F, line = L, col = C}) ->
io_lib:format("In '~s' at line ~p, col~p:", [F, L, C]).
io_lib:format("In '~s' at line ~p, col ~p:", [F, L, C]).