-
Notifications
You must be signed in to change notification settings - Fork 0
/
hello.erl
140 lines (127 loc) · 6.27 KB
/
hello.erl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
%% |
-module(hello).
-export([
main/0,
]).
-include_lib("somelib",).
-ifdef(TEST).
-else.
-endif.
-type some_type(Var,) :: integer() | string().
-opaque opaque_type() :: integer() | string().
-record(some_record, {field1,
field2 = field2,
field3 :: fieled3,
field4 = field4 :: field4,}).
%% ハローワールド
-spec main(Var) -> Var when Var :: Var, Var :: Var,;
(1 + 2) -> (bnot 3 * +4 .. 5);
(foobar) -> fun((12345678901234567890) -> 12345678901234567890);
(integer()) -> fun((hello:some_type()) -> hello:another_type(integer()));
() -> {[], [], [integer()], [integer(), ...],};
() -> {#{foo := bar, integer() => string(),}, #some_record{field1 :: integer(),},};
() -> {<<>>, <<_:42>>, <<_:_*57>>, <<_:42, _:_*57>>,};
(?VAR) -> ?VAR when ?VAR :: ?VAR, ?VAR :: ?VAR,;.
-spec(main(Var) -> Var when Var :: Var, Var :: Var,;
(?VAR) -> ?VAR when ?VAR :: ?VAR, ?VAR :: ?VAR,;).
-spec long_fun_name(LongVariableName, ALittleBitLongVariableName) -> integer() when LongVariableName :: long_variable_name.
main(Parameter1 = 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 0 + 1 + 2 + 3,
Parameter2 = 12345678901234567890 + 12345678901234567890,
Parameter3 = [1, [2, [3, [4, [5, [6, [7, [8, [9, [10, [11, [12]]]]]]]]]]]]
++ [1, [2, [3, [4, [5, [6, [7, [8, [9, [10, [11, [12]]]]]]]]]]]],
Parameter4 =
+12345678901234567890 * -12345678901234567890,
Parameter5 =
bnot 12345678901234567890 >= 12345678901234567890,
Parameter6 = [1, 2 | 3] ++ [],
Parameter7 = <<X:4/little-signed-integer-unit:8, Y:4/little-signed-integer-unit:8,>>,
Parameter8 = ({1234567890123456789012345678901234567890,
1234567890123456789012345678901234567890,}),
Parameter9 = #{foo => 1234567890123456789012345678901234567890, 42 => 1234567890123456789012345678901234567890,}#{42 := 42,},
Parameter10 = #record.foo,
Parameter11 = #record{foo = 1234567890123456789012345678901234567890, Var = 1234567890123456789012345678901234567890,},
) when 1234567890123456789012345678901234567890,
1234567890123456789012345678901234567890,;
1234567890123456789012345678901234567890,
1234567890123456789012345678901234567890,; ->
%% line comment 1
Result1 =
1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 0 + 1 + 2 + 3,
Result2 =
12345678901234567890 + 12345678901234567890,
Result3 = process ! 11111111111111111111111111,
Result4 = [1, [2, [3, [4, [5, [6, [7, [8, [9, [10, [11, [12]]]]]]]]]]]]
++ [1, [2, [3, [4, [5, [6, [7, [8, [9, [10, [11, [12]]]]]]]]]]]],
Result5 =
+12345678901234567890 * -12345678901234567890,
Result6 =
12345678901234567890 >= 12345678901234567890,
Result7 = 12345678901234567890 andalso 12345678901234567890 orelse 12345678901234567890,
Result8 = catch 1234567890123456789012345678901234567890,
Result9 = [1, 2 | 3] ++ [],
Result10 = <<X:4/little-signed-integer-unit:8, Y:4/little-signed-integer-unit:8,>>,
Result11 = ({1234567890123456789012345678901234567890,
1234567890123456789012345678901234567890,}),
Result12 = begin
1234567890123456789012345678901234567890,
1234567890123456789012345678901234567890,
end,
Result13 = Map#{foo := 1234567890123456789012345678901234567890, 42 := 1234567890123456789012345678901234567890,}#{42 := 42,},
Result14 = Record#record.foo#record.bar,
Result15 = Record#record{foo = 1234567890123456789012345678901234567890, Var = 1234567890123456789012345678901234567890,}#record{foo = 42,},
Result16 = fun Hoge(1) when true -> ok,; Hoge(2) when false -> error,; end,
Result17 = fun(1) when true -> ok,; (2) when false -> error,; end,
Result18 = {fun foo/0, fun Var1:Var2/Var3,},
Result19 = [1, 2, [3 / % comment
4]],
Result20 = if
1234567890123456789012345678901234567890,
1234567890123456789012345678901234567890,;
1234567890123456789012345678901234567890,
1234567890123456789012345678901234567890,; -> true;
true -> true;
end,
Result21 = case Result1 of
true when 1234567890123456789012345678901234567890,
1234567890123456789012345678901234567890,;
1234567890123456789012345678901234567890,
1234567890123456789012345678901234567890,; -> true,;
false -> false,;
end,
Result22 = 1 + 1_1 + 001 + 1_6#F_F + 1.1 + 1_1.1_1e1_1,
receive
true when 1234567890123456789012345678901234567890,
1234567890123456789012345678901234567890,;
1234567890123456789012345678901234567890,
1234567890123456789012345678901234567890,; -> true,;
false -> false,;
end,
receive
true when 1234567890123456789012345678901234567890,
1234567890123456789012345678901234567890,;
1234567890123456789012345678901234567890,
1234567890123456789012345678901234567890,; -> true,;
false -> false,;
after
1234567890123456789012345678901234567890 -> true
end,
try
ok,
of
ok -> 1234567890123456789012345678901234567890,;
catch
Catch1 -> 1234567890123456789012345678901234567890,;
Catch1:Catch2 -> 1234567890123456789012345678901234567890,;
Catch1:Catch2:Catch3 -> 1234567890123456789012345678901234567890,;
end,
[1234567890123456789012345678901234567890 || X <- [1234567890123456789012345678901234567890], Y <- [1234567890123456789012345678901234567890], foo:is_valid(X),],
<<1234567890123456789012345678901234567890 || <<X>> <= <<1234567890123456789012345678901234567890>>, <<Y>> <= <<1234567890123456789012345678901234567890>>, foo:is_valid(X),>>,
_ = foo(),
[
%% comment
],
"This is a string literal. \b \d \e \f \e \r \s \t \v \123 \23 \3 \xFE \^C \^V \' \" \\",
io:format("Lorem ipsum dolor sit amet") % comment 1
, % comment 2
; % comment 3
. % comment 4