s/sfc/gsc/g

'
This commit is contained in:
2026-10-20 18:42:11 -07:00
parent 2e062bb8c9
commit 70a853ae99
27 changed files with 291 additions and 291 deletions
@@ -1,11 +1,11 @@
% @doc experiment centering around the file syntax node using ntree approach
-module(gsc_test_file).
-module(sfc_test_file).
-export([
main/0
]).
-include("$gsc_include/gsc.hrl").
-include("$sfc_include/sfc.hrl").
-record(ct,
@@ -64,7 +64,7 @@ main() ->
HelloN = "hello.aes",
HelloP = ts_utils:ct_file_abspath(HelloN),
{ok, HelloS} = file:read_file(HelloP),
S0 = gsc:unsafe_signal_from_file(HelloP),
S0 = sfc:unsafe_signal_from_file(HelloP),
T1 = s2t(file, S0),
io:format("hello.aes:~n", []),
io:format("```~n", []),
@@ -103,7 +103,7 @@ s2t(file, Signal) ->
% | Using
s2t(top_decl, Signal) ->
NewTarget =
case gsc_tokens:strings(3, Signal) of
case sfc_tokens:strings(3, Signal) of
["payable", "contract", "interface"] -> iface;
["contract", "interface" | _] -> iface;
["payable", "main", "contract"] -> ct;
@@ -127,7 +127,7 @@ s2t(ct, S0) ->
% | Using
s2t(decl, S0) ->
NewTarget =
case gsc_tokens:strings(3, S0) of
case sfc_tokens:strings(3, S0) of
["type" | _] -> decl_type;
["record" | _] -> decl_record;
["datatype" | _] -> decl_datatype;
@@ -161,7 +161,7 @@ s2t(NYI, Signal) ->
Forest :: asf().
s2f({block_of, TreeTarget}, S0) ->
{gulp, Items} = gsc_signal:gulp_block_items(S0),
{gulp, Items} = sfc_signal:gulp_block_items(S0),
[s2t(TreeTarget, I) || I <- Items].
@@ -209,7 +209,7 @@ s2s_sm_ct(Ct = #ct{con = none}, S0) ->
error({no_contract_name, Ct, S0})
end;
s2s_sm_ct(Ct = #ct{impls = none}, S0) ->
case gsc_tokens:strings(1, S0) of
case sfc_tokens:strings(1, S0) of
[":"] ->
{slurp, Impls, S1} = s2f_slurp_impls(S0),
s2s_sm_ct(Ct#ct{impls = Impls}, S1);
@@ -1,10 +1,10 @@
-module(gsc_test_ntree).
-module(sfc_test_ntree).
-export([
main/0
]).
-include("$gsc_include/gsc.hrl").
-include("$sfc_include/sfc.hrl").
% just parsing type expressions right now, so only need
% to worry about round parens
@@ -37,8 +37,8 @@ x00() ->
% sample type expr, tokens, signal
x00_src() -> "(foo => (bar) * baz)".
x00_tks() -> gsc:unsafe_tokens_from_string(x00_src()).
x00_sgl() -> gsc:filter_signal(x00_tks()).
x00_tks() -> sfc:unsafe_tokens_from_string(x00_src()).
x00_sgl() -> sfc:filter_signal(x00_tks()).
x00_fst() -> parse(x00_sgl()).
@@ -1,11 +1,11 @@
% gsc tokenizer tests
-module(gsc_test_tokens).
% sfc tokenizer tests
-module(sfc_test_tokens).
-export([
main/0, ct_dir/0
%tokens_match/1
]).
-include("$gsc_include/gsc.hrl").
-include("$sfc_include/sfc.hrl").
-include_lib("eunit/include/eunit.hrl").
main() ->
@@ -24,13 +24,13 @@ agreement_tests_dir() ->
ct_dir() ++ "/tokenizers_agree".
% the divergences claude found between gsc tokenizer and so tokenizer
% the divergences claude found between sfc tokenizer and so tokenizer
%
% mostly stupid corner cases like a string crossing a line boundary
% or unterminated block comment
%
% divergence files: "divergence" means so_scan disagrees with
% gsc_so_scan in one of the following ways:
% sfc_so_scan in one of the following ways:
%
% - one succeeds when the other errors
% - disagree on success case
@@ -117,12 +117,12 @@ tokstr_concat_test_() ->
concat_property(FileName, FilePath) ->
%?debugFmt("concat_property(~p, _)", [FileName]),
FileChars = gsc:very_stable_file(FilePath),
FileChars = sfc:very_stable_file(FilePath),
{FileName ++ ": file = sum(tokens)",
fun() ->
case gsc:tokens_from_file(FileChars) of
{ok, GscTokens} ->
ConcatStr = concat_token_strs(GscTokens, []),
case sfc:tokens_from_file(FileChars) of
{ok, SfcTokens} ->
ConcatStr = concat_token_strs(SfcTokens, []),
?assertEqual(FileChars, ConcatStr);
_Error ->
ok
@@ -147,7 +147,7 @@ tokens_match(FileName, FilePath) ->
% extracting data to be tested
% i hate this so much but lazy and this is test code so who really cares.
SoTokens = so_tokens_from_file(FilePath),
SfTokens = gsc:gso_tokens_from_file(FilePath),
SfTokens = sfc:gso_tokens_from_file(FilePath),
{FileName ++ ": tokenizers_agree",
fun() ->
case {SoTokens, SfTokens} of
@@ -1,7 +1,7 @@
-module(gsc_test_ytree).
-module(sfc_test_ytree).
-export([main/0]).
-include("$gsc_include/gsc.hrl").
-include("$sfc_include/sfc.hrl").
main() ->
Src =
@@ -51,7 +51,7 @@ main() ->
handle_src_str(SrcStr) ->
Sig = gsc:unsafe_signal_from_string(SrcStr),
Sig = sfc:unsafe_signal_from_string(SrcStr),
Result = gulp(file, Sig),
io:format("~tp~n", [Result]).
@@ -64,7 +64,7 @@ handle_src_str(SrcStr) ->
gulp(file, Sig) ->
gulp({block_of, top_decl}, Sig);
gulp({block_of, X}, Sig) ->
{gulp, BlockItems} = gsc_signal:gulp_block_items(Sig),
{gulp, BlockItems} = sfc_signal:gulp_block_items(Sig),
#ys{target = {block_of, X},
signal = Sig,
stem_meta = none,
@@ -77,7 +77,7 @@ gulp(top_decl, Sig) ->
% | 'include' String
% | Using
NewTarget =
case gsc_tokens:strings(3, Sig) of
case sfc_tokens:strings(3, Sig) of
["namespace", _, _] -> namespace;
["@compiler", _, _] -> '@compiler';
["include", _, _] -> include;
@@ -93,7 +93,7 @@ gulp(top_decl, Sig) ->
gulp(NewTarget, Sig);
gulp(contract, Sig) ->
{slurp, CtMeta, BlockSignal} = slurp(#ct{}, Sig),
{gulp, BlockItems} = gsc_signal:gulp_block_items(BlockSignal),
{gulp, BlockItems} = sfc_signal:gulp_block_items(BlockSignal),
Forest = [gulp(decl, Item) || Item <- BlockItems],
#ys{target = contract,
signal = Sig,
@@ -124,7 +124,7 @@ gulp(NyiTarget, Sig) ->
slurp(Meta = #ct{payable = none, main = none}, Sig) ->
%% nato phonetic alphabet
{Pa, Mi, No} =
case gsc_tokens:strings(2, Sig) of
case sfc_tokens:strings(2, Sig) of
["payable", "main"] -> {true, true, 2};
["main", "payable"] -> {true, true, 2};
["payable", _] -> {true, false, 1};
@@ -186,7 +186,7 @@ slurp_sep1_ii(Stk, TkShape, SepByStr, Sig) ->
end.
strings(N, Tks) ->
gsc_tokens:strings(N, Tks).
sfc_tokens:strings(N, Tks).
take(N, [_ | Rest]) when N >= 1 -> take(N-1, Rest);
+15 -15
View File
@@ -1,5 +1,5 @@
% dynamic hacky module that loads all the tests
-module(gsc_tests).
-module(sfc_tests).
-export([
main/0,
@@ -21,26 +21,26 @@ cli_args(TestNames) ->
end,
% this loads the test deps and then cleans up any
% beam files afterwards
ts_utils:tidily(fun() -> do_gsc_test(TestNames) end).
ts_utils:tidily(fun() -> do_sfc_test(TestNames) end).
%do_gsc_test(["-h" | _]) -> do_help();
%do_gsc_test(["--help" | _]) -> do_help();
do_gsc_test(["-l" | _]) -> do_list();
do_gsc_test(["--list" | _]) -> do_list();
do_gsc_test(["-a" | _]) -> do_all();
do_gsc_test(["--all" | _]) -> do_all();
do_gsc_test(["so_tokens", X]) -> do_so_tokens(X);
do_gsc_test(["so", "tokens", X]) -> do_so_tokens(X);
do_gsc_test(["tokenizers_agree", X]) ->
%do_sfc_test(["-h" | _]) -> do_help();
%do_sfc_test(["--help" | _]) -> do_help();
do_sfc_test(["-l" | _]) -> do_list();
do_sfc_test(["--list" | _]) -> do_list();
do_sfc_test(["-a" | _]) -> do_all();
do_sfc_test(["--all" | _]) -> do_all();
do_sfc_test(["so_tokens", X]) -> do_so_tokens(X);
do_sfc_test(["so", "tokens", X]) -> do_so_tokens(X);
do_sfc_test(["tokenizers_agree", X]) ->
do_tokenizers_agree(X);
do_gsc_test([TestName]) ->
do_sfc_test([TestName]) ->
case ts_utils:test_exists_by_name(TestName) of
true -> ts_utils:run_test_by_name(TestName);
false -> gsc_cli:do_help()
false -> sfc_cli:do_help()
end;
do_gsc_test(_) ->
gsc_cli:do_help().
do_sfc_test(_) ->
sfc_cli:do_help().
+13 -13
View File
@@ -32,7 +32,7 @@ tokenizers_agree(Relpath) ->
% extracting data to be tested
% i hate this so much but lazy and this is test code so who really cares.
SoTokens = so_tokens(FilePath),
SfTokens = gsc:gso_tokens_from_file(FilePath),
SfTokens = sfc:gso_tokens_from_file(FilePath),
case {SoTokens, SfTokens} of
{{ok, So}, {ok, Sf}} -> So =:= Sf;
{{error, _}, {error, _}} -> true;
@@ -82,7 +82,7 @@ load_dep(D) ->
Result :: any().
% @doc
% run Fun(), delete gsc/test/*.beam afterward even if
% run Fun(), delete sfc/test/*.beam afterward even if
% Fun() errors
% @end
clean_after(Fun) ->
@@ -156,7 +156,7 @@ rmm(Mod) ->
find_test_by_name(Name) ->
C1 = list_to_atom(Name),
C2 = list_to_atom("gsc_test_" ++ Name),
C2 = list_to_atom("sfc_test_" ++ Name),
{Gd, Bd} = runnable_test_mods(),
C1Gd = lists:member(C1, Gd),
C2Gd = lists:member(C2, Gd),
@@ -185,7 +185,7 @@ rtns(Acc, [TestMod | Rest]) ->
rtns([{TestName, TestMod} | Acc], Rest).
test_mod_name(TestModAtom) ->
"gsc_test_" ++ Name = atom_to_list(TestModAtom),
"sfc_test_" ++ Name = atom_to_list(TestModAtom),
Name.
@@ -206,7 +206,7 @@ runnable_test_mods() ->
is_runnable(ModAtom) ->
case atom_to_list(ModAtom) of
"gsc_test_" ++ _ -> true;
"sfc_test_" ++ _ -> true;
_ -> false
end.
@@ -253,9 +253,9 @@ abspath_to_name(FP) ->
-spec ls_test_erls() -> AbsPaths when
AbsPaths :: [string()].
% @doc ["/path/to/gsc/test/foo.erl",
% "/path/to/gsc/test/bar.erl",
% "/path/to/gsc/test/baz.erl"]
% @doc ["/path/to/sfc/test/foo.erl",
% "/path/to/sfc/test/bar.erl",
% "/path/to/sfc/test/baz.erl"]
ls_test_erls() ->
lists:filter(fun is_erl/1, ls_test()).
@@ -306,9 +306,9 @@ is_erl(Filename) ->
% @doc
% Includes junk/irrelevant files:
%
% ["/path/to/gsc/test/foo.erl",
% "/path/to/gsc/test/.foo.erl.swp",
% "/path/to/gsc/test/bar.erl"]
% ["/path/to/sfc/test/foo.erl",
% "/path/to/sfc/test/.foo.erl.swp",
% "/path/to/sfc/test/bar.erl"]
ls_test() ->
TD = test_dir(),
@@ -324,7 +324,7 @@ ls_pwd() ->
-spec test_dir() -> AbsPath when
AbsPath :: string().
% @doc "/path/to/gsc/test"
% @doc "/path/to/sfc/test"
test_dir() ->
zx_daemon:get_home() ++ "/test".
@@ -334,7 +334,7 @@ test_dir() ->
-spec ct_dir() -> AbsPath when
AbsPath :: string().
% @doc "/path/to/gsc/test/ct"
% @doc "/path/to/sfc/test/ct"
%
% directory containing the tests for the tokenizer
ct_dir() ->