renaming more
This commit is contained in:
+31
-31
@@ -31,9 +31,9 @@
|
||||
% gulp means it must consume all input
|
||||
-spec gulp(AstTarget, SigTokens) -> Perhaps
|
||||
when AstTarget :: gulp_target(),
|
||||
SigTokens :: [sfc_token()],
|
||||
SigTokens :: [gsc_token()],
|
||||
Perhaps :: {gulp, ast()}
|
||||
| {error, sfc_err()}.
|
||||
| {error, gsc_err()}.
|
||||
|
||||
gulp(ast_file, Tokens) ->
|
||||
gulp_file(Tokens);
|
||||
@@ -46,11 +46,11 @@ gulp(ast_ct, Tokens) ->
|
||||
gulp(ast_nyi, Tokens) ->
|
||||
{gulp, #ast_nyi{tokens = Tokens}};
|
||||
gulp({block_of, X}, Tokens) ->
|
||||
{barf, ItemChunks, []} = sfc_token_chunks:barf(block_as_items, Tokens),
|
||||
{barf, ItemChunks, []} = gsc_token_chunks:barf(block_as_items, Tokens),
|
||||
gulp_block_of(X, ItemChunks);
|
||||
gulp(Nyi, Tokens) ->
|
||||
Msg = io_lib:format("sfc_ast:gulp/2: unknown target: ~p", [Nyi]),
|
||||
Err = #sfc_err{atom = gulp_nyi,
|
||||
Msg = io_lib:format("gsc_ast:gulp/2: unknown target: ~p", [Nyi]),
|
||||
Err = #gsc_err{atom = gulp_nyi,
|
||||
string = Msg,
|
||||
extra = [{target, Nyi}, {tokens, Tokens}]},
|
||||
{error, Err}.
|
||||
@@ -60,35 +60,35 @@ gulp(Nyi, Tokens) ->
|
||||
% FIXME: payable and main need to be in that order i think
|
||||
gulp_ct(Ast = #ast_ct{payable = none}, Tokens) ->
|
||||
case Tokens of
|
||||
[#sfc_token{string = "payable", type = kwd} | NewTokens] ->
|
||||
[#gsc_token{string = "payable", type = kwd} | NewTokens] ->
|
||||
gulp_ct(Ast#ast_ct{payable = payable}, NewTokens);
|
||||
_ ->
|
||||
gulp_ct(Ast#ast_ct{payable = false}, Tokens)
|
||||
end;
|
||||
gulp_ct(Ast = #ast_ct{main = none}, Tokens) ->
|
||||
case Tokens of
|
||||
[#sfc_token{string = "main", type = kwd} | NewTokens] ->
|
||||
[#gsc_token{string = "main", type = kwd} | NewTokens] ->
|
||||
gulp_ct(Ast#ast_ct{main = main}, NewTokens);
|
||||
_ ->
|
||||
gulp_ct(Ast#ast_ct{main = false}, Tokens)
|
||||
end;
|
||||
gulp_ct(Ast = #ast_ct{contract = none}, Tokens) ->
|
||||
case Tokens of
|
||||
[#sfc_token{string = "contract", type = kwd} | NewTokens] ->
|
||||
[#gsc_token{string = "contract", type = kwd} | NewTokens] ->
|
||||
gulp_ct(Ast#ast_ct{contract = contract}, NewTokens);
|
||||
% FIXME: reject logic applies to choice of branch, therefore
|
||||
% should be contained in branchpoint code
|
||||
_ ->
|
||||
reject
|
||||
%[#sfc_token{pos = P, string = S} | _] ->
|
||||
% {error, #sfc_err{atom = no_kwd_contract,
|
||||
%[#gsc_token{pos = P, string = S} | _] ->
|
||||
% {error, #gsc_err{atom = no_kwd_contract,
|
||||
% extra = [{pos, P},
|
||||
% {expecting, "contract"},
|
||||
% {got, S},
|
||||
% {ast, Ast},
|
||||
% {tokens, Tokens}]}};
|
||||
%[] ->
|
||||
% {error, #sfc_err{atom = no_kwd_contract,
|
||||
% {error, #gsc_err{atom = no_kwd_contract,
|
||||
% extra = [{pos, none},
|
||||
% {expecting, "contract"},
|
||||
% {got, eof},
|
||||
@@ -97,7 +97,7 @@ gulp_ct(Ast = #ast_ct{contract = none}, Tokens) ->
|
||||
end;
|
||||
gulp_ct(Ast = #ast_ct{name = none}, Tokens) ->
|
||||
case Tokens of
|
||||
[#sfc_token{string = Name, type = con} | NewTokens] ->
|
||||
[#gsc_token{string = Name, type = con} | NewTokens] ->
|
||||
gulp_ct(Ast#ast_ct{name = Name}, NewTokens);
|
||||
_ ->
|
||||
reject
|
||||
@@ -112,27 +112,27 @@ gulp_ct(Ast = #ast_ct{implements = none}, Tokens) ->
|
||||
end;
|
||||
gulp_ct(Ast = #ast_ct{eq = none}, Tokens) ->
|
||||
case Tokens of
|
||||
[#sfc_token{string = "=", type = op} | NewTokens] ->
|
||||
[#gsc_token{string = "=", type = op} | NewTokens] ->
|
||||
gulp_ct(Ast#ast_ct{eq = '='}, NewTokens);
|
||||
_ ->
|
||||
{error, #sfc_err{atom = no_eq}}
|
||||
{error, #gsc_err{atom = no_eq}}
|
||||
end;
|
||||
gulp_ct(Ast = #ast_ct{decls = none}, Tokens) ->
|
||||
Decls = [gulp(decl, Item) || Item <- sfc_token_chunks:unsafe_block_to_items(Tokens)],
|
||||
Decls = [gulp(decl, Item) || Item <- gsc_token_chunks:unsafe_block_to_items(Tokens)],
|
||||
{gulp, Ast#ast_ct{decls = Decls}};
|
||||
gulp_ct(_, _) ->
|
||||
reject.
|
||||
|
||||
|
||||
slurp_ct_impls([#sfc_token{string = ":", type = op},
|
||||
#sfc_token{string = Con1, type = con}
|
||||
slurp_ct_impls([#gsc_token{string = ":", type = op},
|
||||
#gsc_token{string = Con1, type = con}
|
||||
| Rest]) ->
|
||||
slurp_ct_impls2(Rest, [Con1]);
|
||||
slurp_ct_impls(_) ->
|
||||
reject.
|
||||
|
||||
slurp_ct_impls2([#sfc_token{string = ",", type = punct},
|
||||
#sfc_token{string = Con1, type = con}
|
||||
slurp_ct_impls2([#gsc_token{string = ",", type = punct},
|
||||
#gsc_token{string = Con1, type = con}
|
||||
| Rest],
|
||||
Acc) ->
|
||||
slurp_ct_impls2(Rest, [Con1 | Acc]);
|
||||
@@ -144,28 +144,28 @@ slurp_ct_impls2(Rest, Names) ->
|
||||
|
||||
|
||||
-spec gulp_file(SigTokens) -> Perhaps
|
||||
when SigTokens :: [sfc_token()],
|
||||
when SigTokens :: [gsc_token()],
|
||||
Perhaps :: {gulp, #ast_file{}}
|
||||
| {error, sfc_err()}.
|
||||
| {error, gsc_err()}.
|
||||
% @private
|
||||
% `file` enforces that the entire SigTokens is one
|
||||
% block, chokes otherwise
|
||||
|
||||
gulp_file([]) ->
|
||||
{error, #sfc_err{atom = empty_file}};
|
||||
gulp_file(FileTokens = [#sfc_token{pos = FilePos} | _]) ->
|
||||
case sfc_token_chunks:barf(block, FileTokens) of
|
||||
{error, #gsc_err{atom = empty_file}};
|
||||
gulp_file(FileTokens = [#gsc_token{pos = FilePos} | _]) ->
|
||||
case gsc_token_chunks:barf(block, FileTokens) of
|
||||
% happy path: got the whole file back
|
||||
{barf, FileTokens, []} ->
|
||||
gulp_full_file(FileTokens);
|
||||
% sad path: block terminated
|
||||
{barf, _, [#sfc_token{pos = EndPos}]} ->
|
||||
{barf, _, [#gsc_token{pos = EndPos}]} ->
|
||||
Msg = io_lib:format("block starting at ~p ends at ~p instead of EOF",
|
||||
[FilePos, EndPos]),
|
||||
{error, #sfc_err{atom = bad_file,
|
||||
{error, #gsc_err{atom = bad_file,
|
||||
string = Msg}};
|
||||
Nyi ->
|
||||
{error, #sfc_err{atom = bad_file_nyi, extra = Nyi}}
|
||||
{error, #gsc_err{atom = bad_file_nyi, extra = Nyi}}
|
||||
end.
|
||||
|
||||
|
||||
@@ -174,7 +174,7 @@ gulp_file(FileTokens = [#sfc_token{pos = FilePos} | _]) ->
|
||||
|
||||
% file = block(top_decl)
|
||||
gulp_full_file(BlockTokens) ->
|
||||
ItemChunks = sfc_token_chunks:unsafe_block_to_items(BlockTokens),
|
||||
ItemChunks = gsc_token_chunks:unsafe_block_to_items(BlockTokens),
|
||||
gulp_file_decls([], [], ItemChunks).
|
||||
|
||||
|
||||
@@ -183,8 +183,8 @@ gulp_file_decls(Decls, Errs, [DeclTokens | Rest]) ->
|
||||
{gulp, NewDecl} ->
|
||||
gulp_file_decls([NewDecl | Decls], Errs, Rest);
|
||||
reject ->
|
||||
ErrPos = sfc_token_chunks:start_pos(DeclTokens),
|
||||
NewErr = #sfc_err{atom = bad_top_decl,
|
||||
ErrPos = gsc_token_chunks:start_pos(DeclTokens),
|
||||
NewErr = #gsc_err{atom = bad_top_decl,
|
||||
extra = [{tokens, DeclTokens},
|
||||
{pos, ErrPos}]},
|
||||
gulp_file_decls(Decls, [NewErr | Errs], Rest);
|
||||
@@ -195,5 +195,5 @@ gulp_file_decls(Decls, Errs, [DeclTokens | Rest]) ->
|
||||
gulp_file_decls(Decls, _Errs = [], _Input = []) ->
|
||||
{gulp, #ast_file{top_decls = lists:reverse(Decls)}};
|
||||
gulp_file_decls(_Decls, Errs, _Input = []) ->
|
||||
{error, #sfc_err{atom = many,
|
||||
{error, #gsc_err{atom = many,
|
||||
extra = Errs}}.
|
||||
|
||||
Reference in New Issue
Block a user