wip name cleanups

This commit is contained in:
Peter Harpending
2026-06-01 18:00:37 -07:00
parent f548c7d88d
commit 9da6dbf18d
12 changed files with 804 additions and 281 deletions
+25 -25
View File
@@ -4,15 +4,15 @@
% based on original sophia compiler
%
% parse layers:
% 1. sfc_tokenizer: SrcStr -> (Tokens | SigTokens)
% 1. gsc_tokenizer: SrcStr -> (Tokens | SigTokens)
%
% SigTokens = not comment/whitespace
%
% layers:
% a. sfc_strmatch : matches string shapes
% b. sfc_so_scan : converts to so_scan shapes
% a. gsc_strmatch : matches string shapes
% b. gsc_so_scan : converts to so_scan shapes
%
% 2. sfc_ast: SigTokens -> AST
% 2. gsc_ast: SigTokens -> AST
%
% terminology:
%
@@ -36,8 +36,8 @@
% - too fuzzy right now
% - possibly:
% - rename parser layers sequentially:
% - sfc_
-module(sfc).
% - gsc_
-module(gsc).
-export_type([
@@ -54,13 +54,13 @@
ast_from_tokens/1
]).
-include("$sfc_include/sfc.hrl").
-include("$gsc_include/gsc.hrl").
%-----------------------------------------
% types
%-----------------------------------------
-type token() :: sfc_token().
-type token() :: tk().
%-----------------------------------------
% functions
@@ -68,13 +68,13 @@
sigtokens_from_file(X) ->
case tokens_from_file(X) of
{ok, Y} -> {ok, sfc_tokens:filter_significant(Y)};
{ok, Y} -> {ok, gsc_tokens:filter_significant(Y)};
Err -> Err
end.
sigtokens_from_string(X) ->
case tokens_from_string(X) of
{ok, Y} -> {ok, sfc_tokens:filter_significant(Y)};
{ok, Y} -> {ok, gsc_tokens:filter_significant(Y)};
Err -> Err
end.
@@ -82,8 +82,8 @@ sigtokens_from_string(X) ->
-spec tokens_from_file(FilePath) -> Perhaps
when FilePath :: string(),
Perhaps :: {ok, Tokens}
| {error, sfc_err() | any()},
Tokens :: [sfc_token()].
| {error, gsc_err() | any()},
Tokens :: [tk()].
tokens_from_file(FilePath) ->
case file:read_file(FilePath) of
@@ -97,18 +97,18 @@ tokens_from_file(FilePath) ->
-spec tokens_from_string(SrcStr) -> Result
when SrcStr :: string(),
Result :: {ok, Tokens}
| {error, sfc_err()},
Tokens :: [sfc_token()].
| {error, gsc_err()},
Tokens :: [tk()].
tokens_from_string(SrcStr) ->
sfc_tokens:tokens(SrcStr).
gsc_tokens:tokens(SrcStr).
-spec ast_from_file(FilePath) -> Perhaps
when FilePath :: string(),
Perhaps :: {ok, AST} | {error, sfc_err()},
AST :: sfc_ast().
Perhaps :: {ok, AST} | {error, gsc_err()},
AST :: gsc_ast().
ast_from_file(FilePath) ->
case file:read_file(FilePath) of
@@ -120,11 +120,11 @@ ast_from_file(FilePath) ->
-spec ast_from_string(SrcStr) -> Perhaps
when SrcStr :: string(),
Perhaps :: {ok, AST} | {error, sfc_err()},
AST :: sfc_ast().
Perhaps :: {ok, AST} | {error, gsc_err()},
AST :: gsc_ast().
ast_from_string(SrcStr) ->
case sfc_tokens:significant_tokens(SrcStr) of
case gsc_tokens:significant_tokens(SrcStr) of
{ok, SigTks} -> ast_from_tokens(SigTks);
Error -> Error
end.
@@ -132,13 +132,13 @@ ast_from_string(SrcStr) ->
-spec ast_from_tokens(SrcTokens) -> Perhaps
when SrcTokens :: [sfc_token()],
Perhaps :: {ok, AST} | {error, sfc_err()},
AST :: sfc_ast().
when SrcTokens :: [tk()],
Perhaps :: {ok, AST} | {error, gsc_err()},
AST :: gsc_ast().
ast_from_tokens(Tks) ->
SigTks = sfc_tokens:filter_significant(Tks),
case sfc_ast:gulp_file(SigTks) of
SigTks = gsc_tokens:filter_significant(Tks),
case gsc_ast:gulp_file(SigTks) of
{gulp, AST} -> {ok, AST};
Error -> Error
end.