Skip to content

Commit 1368fd6

Browse files
committed
Rename atom to symbols
Symbols are a more common name for this type in other languages, though this does break with the Erlang/Elixir convention
1 parent eb3c562 commit 1368fd6

12 files changed

+78
-78
lines changed

src/aero_ast.erl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
-export([meta/1, metas/1]).
66

77
-export_type([t/0, source/0]).
8-
-export_type([int_lit/0, float_lit/0, atom_lit/0, str_lit/0]).
8+
-export_type([int_lit/0, float_lit/0, sym_lit/0, str_lit/0]).
99
-export_type([ident/0, type_param/0, blank/0, op/0]).
1010
-export_type([block/0, expand/0, args/0, tag/0, attr/0, inner_attr/0]).
1111

@@ -17,7 +17,7 @@
1717
-type t() :: source()
1818
| int_lit()
1919
| float_lit()
20-
| atom_lit()
20+
| sym_lit()
2121
| str_lit()
2222
| ident()
2323
| type_param()
@@ -36,7 +36,7 @@
3636
%% Literals.
3737
-type int_lit() :: {int_lit, meta(), integer()}.
3838
-type float_lit() :: {float_lit, meta(), float()}.
39-
-type atom_lit() :: {atom_lit, meta(), atom()}.
39+
-type sym_lit() :: {sym_lit, meta(), atom()}.
4040
-type str_lit() :: {str_lit, meta(), binary()}.
4141

4242
%% Names and operators.
@@ -65,7 +65,7 @@
6565
meta({source, Meta, _}) -> Meta;
6666
meta({int_lit, Meta, _}) -> Meta;
6767
meta({float_lit, Meta, _}) -> Meta;
68-
meta({atom_lit, Meta, _}) -> Meta;
68+
meta({sym_lit, Meta, _}) -> Meta;
6969
meta({str_lit, Meta, _}) -> Meta;
7070
meta({ident, Meta, _}) -> Meta;
7171
meta({type_param, Meta, _}) -> Meta;

src/aero_codegen.erl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,8 @@ gen_expr({c_int, _, Integer}) ->
128128
cerl:abstract(Integer);
129129
gen_expr({c_float, _, Float}) ->
130130
cerl:abstract(Float);
131-
gen_expr({c_atom, _, Atom}) ->
132-
cerl:abstract(Atom);
131+
gen_expr({c_sym, _, Symbol}) ->
132+
cerl:abstract(Symbol);
133133
gen_expr({c_str, _, String}) ->
134134
cerl:abstract(String);
135135

@@ -215,8 +215,8 @@ gen_pat({c_pat_int, _, Integer}) ->
215215
cerl:abstract(Integer);
216216
gen_pat({c_pat_float, _, Float}) ->
217217
cerl:abstract(Float);
218-
gen_pat({c_pat_atom, _, Atom}) ->
219-
cerl:abstract(Atom);
218+
gen_pat({c_pat_sym, _, Symbol}) ->
219+
cerl:abstract(Symbol);
220220
gen_pat({c_pat_str, _, String}) ->
221221
cerl:abstract(String);
222222

src/aero_core.erl

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -11,26 +11,26 @@
1111
-module(aero_core).
1212

1313
-export([c_pkg/3, c_mod/4, c_def_func/4, c_def_const/5, c_def_mod/3]).
14-
-export([c_block/2, c_bool/2, c_int/2, c_float/2, c_atom/2, c_str/2, c_unit/1, c_tuple/2,
14+
-export([c_block/2, c_bool/2, c_int/2, c_float/2, c_sym/2, c_str/2, c_unit/1, c_tuple/2,
1515
c_cons/3, c_nil/1, c_dict/2, c_func/5, c_call/3, c_apply/3, c_var/2, c_path/2, c_let/4,
1616
c_letrec/4, c_match/3, c_args/2]).
17-
-export([c_pat_bool/2, c_pat_int/2, c_pat_float/2, c_pat_atom/2, c_pat_str/2, c_pat_unit/1,
17+
-export([c_pat_bool/2, c_pat_int/2, c_pat_float/2, c_pat_sym/2, c_pat_str/2, c_pat_unit/1,
1818
c_pat_tuple/2, c_pat_cons/3, c_pat_nil/1, c_pat_dict/2, c_pat_var/2, c_pat_args/2]).
19-
-export([c_type_bool/1, c_type_int/1, c_type_float/1, c_type_atom/1, c_type_str/1, c_type_bytes/1,
19+
-export([c_type_bool/1, c_type_int/1, c_type_float/1, c_type_sym/1, c_type_str/1, c_type_bytes/1,
2020
c_type_bits/1, c_type_ref/1, c_type_unit/1, c_type_tuple/2, c_type_list/2, c_type_dict/3,
2121
c_type_func/3, c_type_uniq/2, c_type_dyn/2, c_type_any/1, c_type_never/1, c_type_wld/1,
2222
c_type_mbox/2, c_type_addr/2, c_type_var/2, c_type_path/2, c_type_tag/2, c_type_struct/3,
2323
c_type_proto/3, c_type_union/2, c_type_inter/2, c_type_where/3]).
2424

2525
-export_type([c_any/0]).
2626
-export_type([c_pkg/0, c_mod/0, c_def/0, c_def_func/0, c_def_const/0, c_def_mod/0, c_vis/0]).
27-
-export_type([c_expr/0, c_block/0, c_bool/0, c_int/0, c_float/0, c_atom/0, c_str/0, c_unit/0,
27+
-export_type([c_expr/0, c_block/0, c_bool/0, c_int/0, c_float/0, c_sym/0, c_str/0, c_unit/0,
2828
c_tuple/0, c_cons/0, c_nil/0, c_dict/0, c_func/0, c_call/0, c_apply/0, c_var/0,
2929
c_path/0, c_let/0, c_letrec/0, c_match/0, c_args/0]).
30-
-export_type([c_pat/0, c_pat_bool/0, c_pat_int/0, c_pat_float/0, c_pat_atom/0, c_pat_str/0,
30+
-export_type([c_pat/0, c_pat_bool/0, c_pat_int/0, c_pat_float/0, c_pat_sym/0, c_pat_str/0,
3131
c_pat_unit/0, c_pat_tuple/0, c_pat_cons/0, c_pat_nil/0, c_pat_dict/0, c_pat_var/0,
3232
c_pat_args/0]).
33-
-export_type([c_type/0, c_type_bool/0, c_type_int/0, c_type_float/0, c_type_atom/0, c_type_str/0,
33+
-export_type([c_type/0, c_type_bool/0, c_type_int/0, c_type_float/0, c_type_sym/0, c_type_str/0,
3434
c_type_bytes/0, c_type_bits/0, c_type_ref/0, c_type_unit/0, c_type_tuple/0,
3535
c_type_list/0, c_type_dict/0, c_type_func/0, c_type_uniq/0, c_type_dyn/0,
3636
c_type_any/0, c_type_never/0, c_type_wld/0, c_type_mbox/0, c_type_addr/0,
@@ -54,7 +54,7 @@
5454

5555
%% Modules.
5656
-type c_mod() :: {c_mod, meta(), c_path(), c_mod_attrs(), [c_def()]}.
57-
-type c_mod_attrs() :: [{c_atom(), c_expr()}].
57+
-type c_mod_attrs() :: [{c_sym(), c_expr()}].
5858

5959
%% Definitions.
6060
-type c_def() :: c_def_func()
@@ -74,7 +74,7 @@
7474
| c_bool()
7575
| c_int()
7676
| c_float()
77-
| c_atom()
77+
| c_sym()
7878
| c_str()
7979
| c_unit()
8080
| c_tuple()
@@ -98,7 +98,7 @@
9898
-type c_bool() :: {c_bool, meta(), boolean()}.
9999
-type c_int() :: {c_int, meta(), integer()}.
100100
-type c_float() :: {c_float, meta(), float()}.
101-
-type c_atom() :: {c_atom, meta(), atom()}.
101+
-type c_sym() :: {c_sym, meta(), atom()}.
102102
-type c_str() :: {c_str, meta(), binary()}.
103103

104104
%% Unit value.
@@ -152,7 +152,7 @@
152152
-type c_pat() :: c_pat_bool()
153153
| c_pat_int()
154154
| c_pat_float()
155-
| c_pat_atom()
155+
| c_pat_sym()
156156
| c_pat_str()
157157
| c_pat_unit()
158158
| c_pat_tuple()
@@ -166,7 +166,7 @@
166166
-type c_pat_bool() :: {c_pat_bool, meta(), boolean()}.
167167
-type c_pat_int() :: {c_pat_int, meta(), integer()}.
168168
-type c_pat_float() :: {c_pat_float, meta(), float()}.
169-
-type c_pat_atom() :: {c_pat_atom, meta(), atom()}.
169+
-type c_pat_sym() :: {c_pat_sym, meta(), atom()}.
170170
-type c_pat_str() :: {c_pat_str, meta(), binary()}.
171171

172172
%% Unit pattern.
@@ -188,7 +188,7 @@
188188
-type c_type() :: c_type_bool()
189189
| c_type_int()
190190
| c_type_float()
191-
| c_type_atom()
191+
| c_type_sym()
192192
| c_type_str()
193193
| c_type_bytes()
194194
| c_type_bits()
@@ -217,7 +217,7 @@
217217
-type c_type_bool() :: {c_type_bool, meta()}.
218218
-type c_type_int() :: {c_type_int, meta()}.
219219
-type c_type_float() :: {c_type_float, meta()}.
220-
-type c_type_atom() :: {c_type_atom, meta()}.
220+
-type c_type_sym() :: {c_type_sym, meta()}.
221221
-type c_type_str() :: {c_type_str, meta()}.
222222

223223
%% Bytes and bits types.
@@ -320,9 +320,9 @@ c_float(Meta, Float) ->
320320
{c_float, Meta, Float}.
321321

322322
%% Create an atom expression.
323-
-spec c_atom(meta(), atom()) -> c_atom().
324-
c_atom(Meta, Atom) ->
325-
{c_atom, Meta, Atom}.
323+
-spec c_sym(meta(), atom()) -> c_sym().
324+
c_sym(Meta, Symbol) ->
325+
{c_sym, Meta, Symbol}.
326326

327327
%% Create a string expression.
328328
-spec c_str(meta(), binary()) -> c_str().
@@ -415,9 +415,9 @@ c_pat_float(Meta, Float) ->
415415
{c_pat_float, Meta, Float}.
416416

417417
%% Create an atom pattern.
418-
-spec c_pat_atom(meta(), atom()) -> c_pat_atom().
419-
c_pat_atom(Meta, Atom) ->
420-
{c_pat_atom, Meta, Atom}.
418+
-spec c_pat_sym(meta(), atom()) -> c_pat_sym().
419+
c_pat_sym(Meta, Symbol) ->
420+
{c_pat_sym, Meta, Symbol}.
421421

422422
%% Create a string pattern.
423423
-spec c_pat_str(meta(), binary()) -> c_pat_str().
@@ -475,9 +475,9 @@ c_type_float(Meta) ->
475475
{c_type_float, Meta}.
476476

477477
%% Create an atom type.
478-
-spec c_type_atom(meta()) -> c_type_atom().
479-
c_type_atom(Meta) ->
480-
{c_type_atom, Meta}.
478+
-spec c_type_sym(meta()) -> c_type_sym().
479+
c_type_sym(Meta) ->
480+
{c_type_sym, Meta}.
481481

482482
%% Create a string type.
483483
-spec c_type_str(meta()) -> c_type_str().

src/aero_core_pprint.erl

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ pprint({c_int, _, Integer}, _Level) ->
4848
integer_to_list(Integer);
4949
pprint({c_float, _, Float}, _Level) ->
5050
float_to_list(Float);
51-
pprint({c_atom, _, Atom}, _Level) ->
52-
[$:, printable_atom(Atom)];
51+
pprint({c_sym, _, Symbol}, _Level) ->
52+
[$:, printable_symbol(Symbol)];
5353
pprint({c_str, _, String}, _Level) ->
5454
[$", printable_string(String), $"];
5555

@@ -80,10 +80,10 @@ pprint({c_apply, _, Callee, Args}, Level) ->
8080
format([apply, Callee | pprint_args(arg, Args, Level)], Level);
8181

8282
pprint({c_var, _, Name}, _Level) ->
83-
[$%, printable_atom(Name)];
83+
[$%, printable_symbol(Name)];
8484

8585
pprint({c_path, _, Vars}, _Level) ->
86-
[$$ | lists:join("::", [printable_atom(Name) || {c_var, _, Name} <- Vars])];
86+
[$$ | lists:join("::", [printable_symbol(Name) || {c_var, _, Name} <- Vars])];
8787

8888
pprint({c_let, _, Left, Type, Right}, Level) ->
8989
format(['let', Left, Type, Right], Level);
@@ -109,8 +109,8 @@ pprint({c_pat_int, _, Integer}, _Level) ->
109109
integer_to_list(Integer);
110110
pprint({c_pat_float, _, Float}, _Level) ->
111111
float_to_list(Float);
112-
pprint({c_pat_atom, _, Atom}, _Level) ->
113-
[$:, printable_atom(Atom)];
112+
pprint({c_pat_sym, _, Symbol}, _Level) ->
113+
[$:, printable_symbol(Symbol)];
114114
pprint({c_pat_str, _, String}, _Level) ->
115115
[$", printable_string(String), $"];
116116

@@ -130,7 +130,7 @@ pprint({c_pat_dict, _, Pairs}, Level) ->
130130
format([dict, PairStrs], Level);
131131

132132
pprint({c_pat_var, _, Name}, _Level) ->
133-
[$%, printable_atom(Name)];
133+
[$%, printable_symbol(Name)];
134134

135135
%% Types.
136136

@@ -140,7 +140,7 @@ pprint({c_type_int, _}, _Level) ->
140140
"int";
141141
pprint({c_type_float, _}, _Level) ->
142142
"float";
143-
pprint({c_type_atom, _}, _Level) ->
143+
pprint({c_type_sym, _}, _Level) ->
144144
"atom";
145145
pprint({c_type_str, _}, _Level) ->
146146
"str";
@@ -177,11 +177,11 @@ pprint({c_type_addr, _, T}, Level) ->
177177
format([addr, T], Level);
178178

179179
pprint({c_type_var, _, Name}, _Level) ->
180-
[$', printable_atom(Name)];
180+
[$', printable_symbol(Name)];
181181
pprint({c_type_path, _, TypeVars}, _Level) ->
182-
[$$ | lists:join("::", [printable_atom(Name) || {c_type_var, _, Name} <- TypeVars])];
182+
[$$ | lists:join("::", [printable_symbol(Name) || {c_type_var, _, Name} <- TypeVars])];
183183
pprint({c_type_tag, _, Name}, _Level) ->
184-
[$:, printable_atom(Name)];
184+
[$:, printable_symbol(Name)];
185185

186186
pprint({c_type_struct, _, Path, TArgs}, Level) ->
187187
format([struct, Path | pprint_args(arg, TArgs, Level)], Level);
@@ -232,24 +232,24 @@ format_inner(Nodes, Level) ->
232232
spaces(Level) ->
233233
lists:duplicate(Level, $\s).
234234

235-
printable_atom(Atom) ->
236-
Str = atom_to_list(Atom),
237-
case lists:all(fun unquoted_atom_char/1, Str) of
235+
printable_symbol(Symbol) ->
236+
Str = atom_to_list(Symbol),
237+
case lists:all(fun unquoted_symbol_char/1, Str) of
238238
true -> Str;
239239
false -> [$\", printable_string(Str), $\"]
240240
end.
241241

242-
%% Core Aero atoms also allow "-" and "." where Aero ones do not and can start
242+
%% Core Aero symbols also allow "-" and "." where Aero ones do not and can start
243243
%% with a number as well.
244-
unquoted_atom_char($_) ->
244+
unquoted_symbol_char($_) ->
245245
true;
246-
unquoted_atom_char($-) ->
246+
unquoted_symbol_char($-) ->
247247
true;
248-
unquoted_atom_char($.) ->
248+
unquoted_symbol_char($.) ->
249249
true;
250-
unquoted_atom_char(C) when C >= $a, C =< $z; C >= $A, C =< $Z; C >= $0, C =< $9 ->
250+
unquoted_symbol_char(C) when C >= $a, C =< $z; C >= $A, C =< $Z; C >= $0, C =< $9 ->
251251
true;
252-
unquoted_atom_char(_) ->
252+
unquoted_symbol_char(_) ->
253253
false.
254254

255255
%% Convert to printable ASCII and escape characters.

src/aero_expand_expr.erl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,8 @@ expand_expr({int_lit, _, Integer}, _Env) ->
102102
aero_core:c_int([], Integer);
103103
expand_expr({float_lit, _, Float}, _Env) ->
104104
aero_core:c_float([], Float);
105-
expand_expr({atom_lit, _, Atom}, _Env) ->
106-
aero_core:c_atom([], Atom);
105+
expand_expr({sym_lit, _, Symbol}, _Env) ->
106+
aero_core:c_sym([], Symbol);
107107
expand_expr({str_lit, _, String}, _Env) ->
108108
aero_core:c_str([], String);
109109

@@ -132,7 +132,7 @@ expand_expr({expand, _, {op, _, '#{_}'}, [{args, _, Args}]}, Env) ->
132132
% We can have a tag in a dictionary for #{ atom: expr } syntax.
133133
% Needing to corece the left side into an atom.
134134
{tag, _, {ident, _, Key}, Value} ->
135-
{aero_core:c_atom([], Key), expand_expr(Value, Env)}
135+
{aero_core:c_sym([], Key), expand_expr(Value, Env)}
136136
end
137137
end, Args),
138138
aero_core:c_dict([], Pairs);
@@ -388,10 +388,10 @@ expand_expr({expand, Meta, {ident, _, 'if'}, [Cond, Next]}, Env) ->
388388
{block, _, _} = Then ->
389389
Cases = [
390390
{aero_core:c_pat_bool([], true), aero_core:c_tuple([], [
391-
aero_core:c_atom([], some),
391+
aero_core:c_sym([], some),
392392
expand_expr(Then, Env)
393393
])},
394-
{aero_env:wildcard_pat_var(Env), aero_core:c_atom([], none)}
394+
{aero_env:wildcard_pat_var(Env), aero_core:c_sym([], none)}
395395
],
396396
aero_core:c_match([], expand_expr(Cond, Env), Cases);
397397

@@ -405,7 +405,7 @@ expand_expr({expand, Meta, {ident, _, 'if'}, _}, _Env) ->
405405
%% Logs.
406406
expand_expr({expand, _, {ident, _, log}, [Message]}, Env) ->
407407
Args = [
408-
aero_core:c_atom([], standard_io),
408+
aero_core:c_sym([], standard_io),
409409
aero_core:c_cons([],
410410
expand_expr(Message, Env),
411411
aero_core:c_cons([],

src/aero_expand_pat.erl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ expand_pat_inner({int_lit, _, Integer}, Env) ->
4040
{aero_core:c_pat_int([], Integer), Env};
4141
expand_pat_inner({float_lit, _, Float}, Env) ->
4242
{aero_core:c_pat_float([], Float), Env};
43-
expand_pat_inner({atom_lit, _, Atom}, Env) ->
44-
{aero_core:c_pat_atom([], Atom), Env};
43+
expand_pat_inner({sym_lit, _, Symbol}, Env) ->
44+
{aero_core:c_pat_sym([], Symbol), Env};
4545
expand_pat_inner({str_lit, _, String}, Env) ->
4646
{aero_core:c_pat_str([], String), Env};
4747

@@ -82,7 +82,7 @@ expand_pat_inner({expand, _, {op, _, '#{_}'}, [{args, _, Args}]}, Env) ->
8282
% We can have a tag in a dictionary pattern for #{ atom: pat } syntax.
8383
% Needing to corece the left side into an atom.
8484
{tag, _, {ident, _, Key}, Value} ->
85-
KeyPat = aero_core:c_pat_atom([], Key),
85+
KeyPat = aero_core:c_pat_sym([], Key),
8686
{ValuePat, ValueEnv} = expand_pat_inner(Value, AccEnv),
8787

8888
{[{KeyPat, ValuePat} | Acc], ValueEnv}

src/aero_expand_type.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ expand_type({ident, _, int}, Env) ->
1919
expand_type({ident, _, float}, Env) ->
2020
{aero_core:c_type_float([]), Env};
2121
expand_type({ident, _, atom}, Env) ->
22-
{aero_core:c_type_atom([]), Env};
22+
{aero_core:c_type_sym([]), Env};
2323
expand_type({ident, _, str}, Env) ->
2424
{aero_core:c_type_str([]), Env};
2525
expand_type({ident, _, bytes}, Env) ->

src/aero_lift.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ is_simple(Expr) ->
189189
is_literal({c_bool, _, _}) -> true;
190190
is_literal({c_int, _, _}) -> true;
191191
is_literal({c_float, _, _}) -> true;
192-
is_literal({c_atom, _, _}) -> true;
192+
is_literal({c_sym, _, _}) -> true;
193193
is_literal({c_str, _, _}) -> true;
194194
is_literal({c_nil, _}) -> true;
195195
is_literal({c_unit, _}) -> true;

src/aero_parse.erl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,8 +227,8 @@ expr_single({type_param, Meta, TypeParam}, _Mode) ->
227227
{type_param, Meta, TypeParam};
228228
expr_single({blank, Meta}, _Mode) ->
229229
{blank, Meta};
230-
expr_single({atom_lit, Meta, Atom}, _Mode) ->
231-
{atom_lit, Meta, Atom};
230+
expr_single({sym_lit, Meta, Symbol}, _Mode) ->
231+
{sym_lit, Meta, Symbol};
232232
expr_single({str_lit, Meta, String}, _Mode) ->
233233
{str_lit, Meta, String};
234234
expr_single({int_lit, Meta, Integer}, _Mode) ->

0 commit comments

Comments
 (0)