gsc_test_ytree: task now fails successfully
i have realized that a lot of the complexity and cognitive overhead is downstream from trying to prematurely handle errors. so i'm going to do the erlang thing and just assert/assume everything worked perfectly and let the errors speak for themselves. so re "task fails successfully": now instead of getting an NYI that looks like a success result, we're now properly getting an error.
This commit is contained in:
+34
-17
@@ -23,8 +23,7 @@ main() ->
|
||||
| using
|
||||
.
|
||||
|
||||
-record(ct, {ok = ok :: ok | {error, any()},
|
||||
payable = none :: none | false | true,
|
||||
-record(ct, {payable = none :: none | false | true,
|
||||
main = none :: none | false | true,
|
||||
contract = none :: none | tk(),
|
||||
con = none :: none | tk(),
|
||||
@@ -43,8 +42,7 @@ main() ->
|
||||
| contract_meta().
|
||||
|
||||
% @doc ys = syntax stem
|
||||
-record(ys, {ok = ok :: ok | {error, any()},
|
||||
target = signal :: syntax_target(),
|
||||
-record(ys, {target = signal :: syntax_target(),
|
||||
signal :: [tk()],
|
||||
stem_meta :: stem_meta(),
|
||||
forest :: [#ys{}]}).
|
||||
@@ -58,6 +56,11 @@ handle_src_str(SrcStr) ->
|
||||
io:format("~tp~n", [Result]).
|
||||
|
||||
|
||||
-spec gulp(Target, Signal) -> Result when
|
||||
Target :: syntax_target(),
|
||||
Signal :: [tk()],
|
||||
Result :: {gulp, syntax_stem()} | {error, any()}.
|
||||
|
||||
gulp(file, Sig) ->
|
||||
gulp({block_of, top_decl}, Sig);
|
||||
gulp({block_of, X}, Sig) ->
|
||||
@@ -96,11 +99,25 @@ gulp(contract, Sig) ->
|
||||
signal = Sig,
|
||||
stem_meta = CtMeta,
|
||||
forest = Forest};
|
||||
% Decl ::= 'type' Id ['(' TVar* ')'] '=' TypeAlias
|
||||
% | 'record' Id ['(' TVar* ')'] '=' RecordType
|
||||
% | 'datatype' Id ['(' TVar* ')'] '=' DataType
|
||||
% | 'let' Id [':' Type] '=' Expr
|
||||
% | (EModifier* 'entrypoint' | FModifier* 'function') Block(FunDecl)
|
||||
% | Using
|
||||
gulp(decl, Sig) ->
|
||||
NewTarget =
|
||||
case strings(1, Sig) of
|
||||
["type"] -> type;
|
||||
["record"] -> record;
|
||||
["datatype"] -> datatype;
|
||||
["let"] -> 'let';
|
||||
["using"] -> using;
|
||||
_ -> fn
|
||||
end,
|
||||
gulp(NewTarget, Sig);
|
||||
gulp(NyiTarget, Sig) ->
|
||||
#ys{target = NyiTarget,
|
||||
signal = Sig,
|
||||
stem_meta = {nyi, NyiTarget},
|
||||
forest = []}.
|
||||
error({nyi, [?MODULE, gulp, NyiTarget, Sig]}).
|
||||
|
||||
|
||||
%% ['payable'] ['main'] 'contract' Con [Implement] '=' Block(Decl)
|
||||
@@ -122,20 +139,20 @@ slurp(M = #ct{contract = none}, Sig) ->
|
||||
[Tk = #tk{str = "contract"} | Rest] ->
|
||||
slurp(M#ct{contract = Tk}, Rest);
|
||||
_ ->
|
||||
M#ct{ok = {error, no_keyword_contract}}
|
||||
error(no_keyword_contract)
|
||||
end;
|
||||
slurp(M = #ct{con = none}, Sig) ->
|
||||
case Sig of
|
||||
[Tk = #tk{shape = con} | Rest] ->
|
||||
slurp(M#ct{con = Tk}, Rest);
|
||||
[Tk = #tk{str = Irregar} | _] ->
|
||||
M#ct{ok = {error, {illegal_contract_name, Irregar}}};
|
||||
[#tk{str = Irregar} | _] ->
|
||||
error(illegal_contract_name, Irregar);
|
||||
[] ->
|
||||
M#ct{ok = {error, no_contract_name}}
|
||||
error(no_contract_name)
|
||||
end;
|
||||
slurp(M = #ct{impls = none}, Sig) ->
|
||||
case Sig of
|
||||
[Tk = #tk{str = ":"} | Rest] ->
|
||||
[#tk{str = ":"} | Rest] ->
|
||||
{slurp, Impls, NewRest} = slurp({sep1, con, ","}, Rest),
|
||||
NewM = M#ct{impls = {true, Impls}},
|
||||
slurp(NewM, NewRest);
|
||||
@@ -147,17 +164,17 @@ slurp(M = #ct{'=' = none}, Sig) ->
|
||||
[Tk = #tk{str = "="} | Rest] ->
|
||||
{slurp, M#ct{'=' = Tk}, Rest};
|
||||
_ ->
|
||||
M#ct{ok = {error, no_token_eq}}
|
||||
error("where the fuck my = be at nigga")
|
||||
end;
|
||||
slurp({sep1, TkShape, SepByStr}, Tks) ->
|
||||
case Tks of
|
||||
[Tk = #tk{shape = TkShape} | Rest] ->
|
||||
slurp_sep1_ii([Tk], TkShape, SepByStr, Rest);
|
||||
_ ->
|
||||
{error, irregar}
|
||||
error(irregar)
|
||||
end;
|
||||
slurp(M, Tks) ->
|
||||
{slurp, {nyi, M}, Tks}.
|
||||
slurp(BadMeta, BadTokens) ->
|
||||
error({nyi, [?MODULE, slurp, BadMeta, BadTokens]}).
|
||||
|
||||
|
||||
slurp_sep1_ii(Stk, TkShape, SepByStr, Sig) ->
|
||||
|
||||
Reference in New Issue
Block a user