Merge pull request #22 from aeternity/fix-compiler-interface

Remove specific filename extension handling
This commit is contained in:
Robert Virding 2019-02-06 15:17:53 +01:00 committed by GitHub
commit b65c4edd19
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -44,9 +44,11 @@ file(Filename) ->
-spec file(string(), options()) -> {ok, map()} | {error, binary()}. -spec file(string(), options()) -> {ok, map()} | {error, binary()}.
file(File, Options) -> file(File, Options) ->
case read_contract(File, Options) of case read_contract(File) of
{ok, Bin} -> from_string(Bin, Options); {ok, Bin} -> from_string(Bin, Options);
{error, Error} -> {error, {File, Error}} {error, Error} ->
ErrorString = [File,": ",file:format_error(Error)],
{error, join_errors("File errors", [ErrorString], fun(E) -> E end)}
end. end.
-spec from_string(binary() | string(), options()) -> {ok, map()} | {error, binary()}. -spec from_string(binary() | string(), options()) -> {ok, map()} | {error, binary()}.
@ -283,13 +285,5 @@ parse_error({Line, Pos}, ErrorString) ->
Error = io_lib:format("line ~p, column ~p: ~s", [Line, Pos, ErrorString]), Error = io_lib:format("line ~p, column ~p: ~s", [Line, Pos, ErrorString]),
error({parse_errors, [Error]}). error({parse_errors, [Error]}).
read_contract(Name, Opts) -> read_contract(Name) ->
FileName = filename(Name, ".aes", Opts), file:read_file(Name).
file:read_file(FileName).
filename(File, Suffix, _Opts) ->
Base = filename:basename(File, Suffix),
Sdir = filename:dirname(File),
if Sdir == "." -> Base ++ Suffix;
true -> filename:join(Sdir, Base ++ Suffix)
end.