stuff
This commit is contained in:
+38
-38
@@ -8,7 +8,7 @@
|
|||||||
-include("$gsc_include/gsc.hrl").
|
-include("$gsc_include/gsc.hrl").
|
||||||
|
|
||||||
|
|
||||||
-record(td_ct,
|
-record(ct,
|
||||||
{payable = none :: none | false | {true, tk()},
|
{payable = none :: none | false | {true, tk()},
|
||||||
main = none :: none | false | {true, tk()},
|
main = none :: none | false | {true, tk()},
|
||||||
contract = none :: none | tk(),
|
contract = none :: none | tk(),
|
||||||
@@ -16,7 +16,7 @@
|
|||||||
impls = none :: none | [tk()],
|
impls = none :: none | [tk()],
|
||||||
eq = none :: none | tk()}).
|
eq = none :: none | tk()}).
|
||||||
|
|
||||||
-type td_meta() :: #td_ct{}.
|
-type meta() :: #ct{}.
|
||||||
|
|
||||||
-record(decl_type,
|
-record(decl_type,
|
||||||
{type = none :: none | tk(),
|
{type = none :: none | tk(),
|
||||||
@@ -28,26 +28,26 @@
|
|||||||
|
|
||||||
|
|
||||||
-type ast_meta() :: file
|
-type ast_meta() :: file
|
||||||
| td_meta()
|
| meta()
|
||||||
| decl_meta()
|
| decl_meta()
|
||||||
| nyi
|
| nyi
|
||||||
| {nyi, any()}
|
| {nyi, any()}
|
||||||
.
|
.
|
||||||
|
|
||||||
|
|
||||||
-type td_target()
|
-type target()
|
||||||
:: td_ct
|
:: ct
|
||||||
| td_iface
|
| iface
|
||||||
| td_ns
|
| ns
|
||||||
| td_pragma
|
| pragma
|
||||||
| td_include
|
| include
|
||||||
| using
|
| using
|
||||||
.
|
.
|
||||||
|
|
||||||
-type s2t_target()
|
-type s2t_target()
|
||||||
:: file
|
:: file
|
||||||
| top_decl
|
| top_decl
|
||||||
| td_target()
|
| target()
|
||||||
| nyi
|
| nyi
|
||||||
| {nyi, any()}
|
| {nyi, any()}
|
||||||
.
|
.
|
||||||
@@ -104,20 +104,20 @@ s2t(file, Signal) ->
|
|||||||
s2t(top_decl, Signal) ->
|
s2t(top_decl, Signal) ->
|
||||||
NewTarget =
|
NewTarget =
|
||||||
case gsc_tokens:strings(3, Signal) of
|
case gsc_tokens:strings(3, Signal) of
|
||||||
["payable", "contract", "interface"] -> td_iface;
|
["payable", "contract", "interface"] -> iface;
|
||||||
["contract", "interface" | _] -> td_iface;
|
["contract", "interface" | _] -> iface;
|
||||||
["payable", "main", "contract"] -> td_ct;
|
["payable", "main", "contract"] -> ct;
|
||||||
["payable", "contract" | _] -> td_ct;
|
["payable", "contract" | _] -> ct;
|
||||||
["contract" | _] -> td_ct;
|
["contract" | _] -> ct;
|
||||||
["namespace" | _] -> td_namespace;
|
["namespace" | _] -> namespace;
|
||||||
["@compiler" | _] -> td_pragma;
|
["@compiler" | _] -> pragma;
|
||||||
["include" | _] -> td_include;
|
["include" | _] -> include;
|
||||||
["using" | _] -> using
|
["using" | _] -> using
|
||||||
end,
|
end,
|
||||||
s2t(NewTarget, Signal);
|
s2t(NewTarget, Signal);
|
||||||
% ['payable'] ['main'] 'contract' Con [Implement] '=' Block(Decl)
|
% ['payable'] ['main'] 'contract' Con [Implement] '=' Block(Decl)
|
||||||
s2t(td_ct, S0) ->
|
s2t(ct, S0) ->
|
||||||
{slurp, CtMeta, S1} = s2s_slurp_meta(#td_ct{}, S0),
|
{slurp, CtMeta, S1} = s2s_slurp_meta(#ct{}, S0),
|
||||||
{ns, CtMeta, s2f({block_of, decl}, S1)};
|
{ns, CtMeta, s2f({block_of, decl}, S1)};
|
||||||
% Decl ::= 'type' Id ['(' TVar* ')'] '=' TypeAlias
|
% Decl ::= 'type' Id ['(' TVar* ')'] '=' TypeAlias
|
||||||
% | 'record' Id ['(' TVar* ')'] '=' RecordType
|
% | 'record' Id ['(' TVar* ')'] '=' RecordType
|
||||||
@@ -172,58 +172,58 @@ s2f({block_of, TreeTarget}, S0) ->
|
|||||||
Meta :: ast_meta(),
|
Meta :: ast_meta(),
|
||||||
NewSignal :: Signal.
|
NewSignal :: Signal.
|
||||||
|
|
||||||
s2s_slurp_meta(M = #td_ct{}, S) ->
|
s2s_slurp_meta(M = #ct{}, S) ->
|
||||||
s2s_sm_td_ct(M, S);
|
s2s_sm_ct(M, S);
|
||||||
s2s_slurp_meta(M = #decl_type{}, S) ->
|
s2s_slurp_meta(M = #decl_type{}, S) ->
|
||||||
s2s_sm_decl_type(M, S);
|
s2s_sm_decl_type(M, S);
|
||||||
s2s_slurp_meta(M, S) ->
|
s2s_slurp_meta(M, S) ->
|
||||||
error({s2s_slurp_meta, M, S}).
|
error({s2s_slurp_meta, M, S}).
|
||||||
|
|
||||||
|
|
||||||
s2s_sm_td_ct(Ct = #td_ct{payable = none}, S0) ->
|
s2s_sm_ct(Ct = #ct{payable = none}, S0) ->
|
||||||
case S0 of
|
case S0 of
|
||||||
[#tk{str = "payable"} = T0 | S1] ->
|
[#tk{str = "payable"} = T0 | S1] ->
|
||||||
s2s_sm_td_ct(Ct#td_ct{payable = {true, T0}}, S1);
|
s2s_sm_ct(Ct#ct{payable = {true, T0}}, S1);
|
||||||
_ ->
|
_ ->
|
||||||
s2s_sm_td_ct(Ct#td_ct{payable = false}, S0)
|
s2s_sm_ct(Ct#ct{payable = false}, S0)
|
||||||
end;
|
end;
|
||||||
s2s_sm_td_ct(Ct = #td_ct{main = none}, S0) ->
|
s2s_sm_ct(Ct = #ct{main = none}, S0) ->
|
||||||
case S0 of
|
case S0 of
|
||||||
[#tk{str = "main"} = T0 | S1] ->
|
[#tk{str = "main"} = T0 | S1] ->
|
||||||
s2s_sm_td_ct(Ct#td_ct{main = {true, T0}}, S1);
|
s2s_sm_ct(Ct#ct{main = {true, T0}}, S1);
|
||||||
_ ->
|
_ ->
|
||||||
s2s_sm_td_ct(Ct#td_ct{main = false}, S0)
|
s2s_sm_ct(Ct#ct{main = false}, S0)
|
||||||
end;
|
end;
|
||||||
s2s_sm_td_ct(Ct = #td_ct{contract = none}, S0) ->
|
s2s_sm_ct(Ct = #ct{contract = none}, S0) ->
|
||||||
case S0 of
|
case S0 of
|
||||||
[#tk{str = "contract"} = T0 | S1] ->
|
[#tk{str = "contract"} = T0 | S1] ->
|
||||||
s2s_sm_td_ct(Ct#td_ct{contract = T0}, S1);
|
s2s_sm_ct(Ct#ct{contract = T0}, S1);
|
||||||
_ ->
|
_ ->
|
||||||
error({no_kwd_contract, Ct, S0})
|
error({no_kwd_contract, Ct, S0})
|
||||||
end;
|
end;
|
||||||
s2s_sm_td_ct(Ct = #td_ct{con = none}, S0) ->
|
s2s_sm_ct(Ct = #ct{con = none}, S0) ->
|
||||||
case S0 of
|
case S0 of
|
||||||
[#tk{shape = con} = T0 | S1] ->
|
[#tk{shape = con} = T0 | S1] ->
|
||||||
s2s_sm_td_ct(Ct#td_ct{con = T0}, S1);
|
s2s_sm_ct(Ct#ct{con = T0}, S1);
|
||||||
_ ->
|
_ ->
|
||||||
error({no_contract_name, Ct, S0})
|
error({no_contract_name, Ct, S0})
|
||||||
end;
|
end;
|
||||||
s2s_sm_td_ct(Ct = #td_ct{impls = none}, S0) ->
|
s2s_sm_ct(Ct = #ct{impls = none}, S0) ->
|
||||||
case gsc_tokens:strings(1, S0) of
|
case gsc_tokens:strings(1, S0) of
|
||||||
[":"] ->
|
[":"] ->
|
||||||
{slurp, Impls, S1} = s2f_slurp_impls(S0),
|
{slurp, Impls, S1} = s2f_slurp_impls(S0),
|
||||||
s2s_sm_td_ct(Ct#td_ct{impls = Impls}, S1);
|
s2s_sm_ct(Ct#ct{impls = Impls}, S1);
|
||||||
_ ->
|
_ ->
|
||||||
s2s_sm_td_ct(Ct#td_ct{impls = []}, S0)
|
s2s_sm_ct(Ct#ct{impls = []}, S0)
|
||||||
end;
|
end;
|
||||||
s2s_sm_td_ct(Ct = #td_ct{eq = none}, S0) ->
|
s2s_sm_ct(Ct = #ct{eq = none}, S0) ->
|
||||||
case S0 of
|
case S0 of
|
||||||
[#tk{str = "="} = T0 | S1] ->
|
[#tk{str = "="} = T0 | S1] ->
|
||||||
s2s_sm_td_ct(Ct#td_ct{eq = T0}, S1);
|
s2s_sm_ct(Ct#ct{eq = T0}, S1);
|
||||||
_ ->
|
_ ->
|
||||||
error({no_equal_sign, Ct, S0})
|
error({no_equal_sign, Ct, S0})
|
||||||
end;
|
end;
|
||||||
s2s_sm_td_ct(Ct, S0) ->
|
s2s_sm_ct(Ct, S0) ->
|
||||||
{slurp, Ct, S0}.
|
{slurp, Ct, S0}.
|
||||||
|
|
||||||
s2f_slurp_impls([#tk{str = ":"}, #tk{shape = con} = I0 | S0]) ->
|
s2f_slurp_impls([#tk{str = ":"}, #tk{shape = con} = I0 | S0]) ->
|
||||||
|
|||||||
Reference in New Issue
Block a user