@fraczak/k 6.1.0 → 6.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.idea/codeStyles/codeStyleConfig.xml +5 -0
- package/.idea/copilot.data.migration.agent.xml +6 -0
- package/.idea/copilot.data.migration.ask.xml +6 -0
- package/.idea/copilot.data.migration.ask2agent.xml +6 -0
- package/.idea/copilot.data.migration.edit.xml +6 -0
- package/.idea/k.iml +9 -0
- package/.idea/misc.xml +6 -0
- package/.idea/modules.xml +8 -0
- package/.idea/vcs.xml +6 -0
- package/k_compiler/runtime.c +205 -0
- package/k_compiler/runtime.h +34 -0
- package/package.json +1 -1
- package/repl.mjs +28 -9
- package/test-repl.mjs +12 -1
- package/.codex +0 -0
- package/DOCS/a.html +0 -398
- package/NAT.k~ +0 -452
- package/UU/ta.k +0 -1
- package/UU/ta.k~ +0 -0
- package/UU/tb.k +0 -0
- package/UU/tc.k +0 -0
- package/codecs/BINARY_FORMAT.html +0 -471
- package/codecs/POLYMORPHIC_BINARY_FORMAT.html +0 -355
- package/core.json +0 -1
- package/core.klib +0 -1
- package/core.klib~ +0 -0
- package/ieee.klib +0 -0
- package/k-vscode/package-lock.json +0 -4176
- package/kkk.k +0 -197
- package/kkk.klib +0 -0
- package/kkk.klib~ +0 -0
- package/p.json +0 -5475
- package/type_registry/registry.mjs~ +0 -105
- package/type_registry/typeParser.jison~ +0 -132
package/kkk.k
DELETED
|
@@ -1,197 +0,0 @@
|
|
|
1
|
-
-- core.k — the k standard core library
|
|
2
|
-
--
|
|
3
|
-
-- Defines:
|
|
4
|
-
-- 1. $bits — the canonical binary number / bit-path type
|
|
5
|
-
-- 2. $string — unicode strings (used for labels)
|
|
6
|
-
-- 3. $pattern — the type of pattern graphs
|
|
7
|
-
-- 4. Basic $bits arithmetic: succ, plus, times
|
|
8
|
-
|
|
9
|
-
---------------------------------------------------------------
|
|
10
|
-
-- §1. Bits
|
|
11
|
-
---------------------------------------------------------------
|
|
12
|
-
|
|
13
|
-
$ bit = < {} 0, {} 1 >;
|
|
14
|
-
b0 = {}|0 $bit;
|
|
15
|
-
b1 = {}|1 $bit;
|
|
16
|
-
|
|
17
|
-
$ bits = < {} _, bits 0, bits 1 >;
|
|
18
|
-
|
|
19
|
-
_ = {}|_;
|
|
20
|
-
|
|
21
|
-
0 = _ |0;
|
|
22
|
-
1 = _ |1;
|
|
23
|
-
|
|
24
|
-
inv = {() x, _ r} _inv;
|
|
25
|
-
_inv = ${bits x, bits r} < {.x /0 x, .r |0 r} _inv, {.x /1 x, .r |1 r} _inv, .r >;
|
|
26
|
-
|
|
27
|
-
concat = ${bits x, bits y} {.x inv x, .y y} concat_;
|
|
28
|
-
concat_ = ${bits x, bits y}
|
|
29
|
-
<
|
|
30
|
-
{.x /0 x, .y |0 y} concat_,
|
|
31
|
-
{.x /1 x, .y |1 y} concat_,
|
|
32
|
-
.y
|
|
33
|
-
>;
|
|
34
|
-
|
|
35
|
-
---------------------------------------------------------------
|
|
36
|
-
-- §2. Bits arithmetic
|
|
37
|
-
---------------------------------------------------------------
|
|
38
|
-
|
|
39
|
-
-- successor (increment by 1)
|
|
40
|
-
succ = {inv x, _ y} _inc;
|
|
41
|
-
|
|
42
|
-
_inc = ${bits x, bits y} <
|
|
43
|
-
{.x /0 x, .y |1 y} concat_,
|
|
44
|
-
{.x /1 x, .y |0 y} _inc,
|
|
45
|
-
.y |1
|
|
46
|
-
>;
|
|
47
|
-
|
|
48
|
-
-- constants
|
|
49
|
-
2 = 1 succ;
|
|
50
|
-
3 = 2 succ;
|
|
51
|
-
4 = 3 succ;
|
|
52
|
-
5 = 4 succ;
|
|
53
|
-
6 = 5 succ;
|
|
54
|
-
7 = 6 succ;
|
|
55
|
-
8 = 7 succ;
|
|
56
|
-
9 = 8 succ;
|
|
57
|
-
10 = 9 succ;
|
|
58
|
-
|
|
59
|
-
-- addition on $bits (unsigned, LSB-first with carry)
|
|
60
|
-
plus = ${bits x, bits y} {.x inv x, .y inv y, b0 c} _plus;
|
|
61
|
-
_plus = ${bits x, bits y, bit c}
|
|
62
|
-
<
|
|
63
|
-
{.x /_ if, .y /_ and, <.c/0 0, 1> then} .then,
|
|
64
|
-
{.x /_ if, .c/0 and, .y then} .then,
|
|
65
|
-
{.x y, .y /_|_ x, .c c} _plus,
|
|
66
|
-
{<.c/0 0, 1> x, .y y, .x /_ b0 c} _plus,
|
|
67
|
-
{.x /0 x, .y /0 y, .c/0 b0 c} _plus |0,
|
|
68
|
-
{.x /0 x, .y /0 y, .c/1 b0 c} _plus |1,
|
|
69
|
-
{.x /0 x, .y /1 y, .c/0 b0 c} _plus |1,
|
|
70
|
-
{.x /0 x, .y /1 y, .c/1 b1 c} _plus |0,
|
|
71
|
-
{.x /1 x, .y /0 y, .c/0 b0 c} _plus |1,
|
|
72
|
-
{.x /1 x, .y /0 y, .c/1 b1 c} _plus |0,
|
|
73
|
-
{.x /1 x, .y /1 y, .c/0 b1 c} _plus |0,
|
|
74
|
-
{.x /1 x, .y /1 y, .c/1 b1 c} _plus |1
|
|
75
|
-
>;
|
|
76
|
-
|
|
77
|
-
-- multiplication on $bits (unsigned, shift-and-add)
|
|
78
|
-
times = ${bits x, bits y} {0 result, .x inv _x, .y y} _times;
|
|
79
|
-
_times = ${bits result, bits _x, bits y}
|
|
80
|
-
<
|
|
81
|
-
{ .y /_ if, .result then } .then,
|
|
82
|
-
{
|
|
83
|
-
.result |0 result,
|
|
84
|
-
._x _x,
|
|
85
|
-
.y /0 y
|
|
86
|
-
} _times,
|
|
87
|
-
{
|
|
88
|
-
{._x x, .result |0 y, b0 c} _plus result,
|
|
89
|
-
._x _x,
|
|
90
|
-
.y /1 y
|
|
91
|
-
} _times
|
|
92
|
-
>;
|
|
93
|
-
|
|
94
|
-
---------------------------------------------------------------
|
|
95
|
-
-- §3. Unicode and String
|
|
96
|
-
---------------------------------------------------------------
|
|
97
|
-
|
|
98
|
-
-- 8-bit octet used as a building block for UTF-8 payload pieces.
|
|
99
|
-
$ byte = {
|
|
100
|
-
bit 0, bit 1, bit 2, bit 3,
|
|
101
|
-
bit 4, bit 5, bit 6, bit 7
|
|
102
|
-
};
|
|
103
|
-
|
|
104
|
-
-- 7-bit ASCII code point payload (U+0000..U+007F).
|
|
105
|
-
$ ascii = { bit 6, bit 5, bit 4, bit 3, bit 2, bit 1, bit 0 };
|
|
106
|
-
|
|
107
|
-
-- 11-bit payload used for Plane 0 code points U+0080..U+07FF.
|
|
108
|
-
-- Plane 0 is the Basic Multilingual Plane (BMP): U+0000..U+FFFF.
|
|
109
|
-
$ u0080_07FF = { bit 10, bit 9, bit 8, bit 7, bit 6, bit 5, bit 4, bit 3, bit 2, bit 1, bit 0 };
|
|
110
|
-
|
|
111
|
-
-- High-byte classes for common BMP ranges, excluding surrogate/private-use partitions.
|
|
112
|
-
-- BMP (Basic Multilingual Plane) is Plane 0: the first 65,536 code points.
|
|
113
|
-
$ bmp_hi_common = <
|
|
114
|
-
{ bit 2, bit 1, bit 0 } h08_0F,
|
|
115
|
-
{ bit 6, bit 5, bit 4, bit 3, bit 2, bit 1, bit 0 } h10_7F,
|
|
116
|
-
{ bit 6, bit 5, bit 4, bit 3, bit 2, bit 1, bit 0 } h80_CF,
|
|
117
|
-
{ bit 2, bit 1, bit 0 } hD0_D7,
|
|
118
|
-
{} hF9,
|
|
119
|
-
{ bit 0 } hFA_FB,
|
|
120
|
-
{ bit 0 } hFC_FD,
|
|
121
|
-
{ bit 0 } hFE_FF
|
|
122
|
-
>;
|
|
123
|
-
|
|
124
|
-
-- High-byte classes for BMP private-use/high-reserved slices.
|
|
125
|
-
-- These partitions keep Plane 0 subsets explicit in the type encoding.
|
|
126
|
-
$ bmp_hi_private_use = <
|
|
127
|
-
{ bit 3, bit 2, bit 1, bit 0 } hE0_EF,
|
|
128
|
-
{ bit 2, bit 1, bit 0 } hF0_F7,
|
|
129
|
-
{} hF8
|
|
130
|
-
>;
|
|
131
|
-
|
|
132
|
-
-- Plane selector for supplementary code points in Planes 2..16.
|
|
133
|
-
-- Supplementary planes are all planes above BMP (Plane 0).
|
|
134
|
-
$ plane_02_10 = <
|
|
135
|
-
{ bit 0 } p02_03,
|
|
136
|
-
{ bit 1, bit 0 } p04_07,
|
|
137
|
-
{ bit 2, bit 1, bit 0 } p08_0F,
|
|
138
|
-
{} p10
|
|
139
|
-
>;
|
|
140
|
-
|
|
141
|
-
-- Canonical Unicode scalar-value partition used by string encoding.
|
|
142
|
-
-- Branch meaning:
|
|
143
|
-
-- - ascii: U+0000..U+007F (subset of BMP / Plane 0)
|
|
144
|
-
-- - plane0: U+0080..U+07FF (still Plane 0)
|
|
145
|
-
-- - bmp_common, bmp_private_use: U+0800..U+FFFF partitions (Plane 0)
|
|
146
|
-
-- - supplementary_plane1: U+10000..U+1FFFF (Plane 1)
|
|
147
|
-
-- - supplementary_planes2_16: U+20000..U+10FFFF (Planes 2..16)
|
|
148
|
-
$ unicode = <
|
|
149
|
-
ascii ascii,
|
|
150
|
-
u0080_07FF plane0,
|
|
151
|
-
{ bmp_hi_common hi, byte lo } bmp_common,
|
|
152
|
-
{ bmp_hi_private_use hi, byte lo } bmp_private_use,
|
|
153
|
-
{ byte mid, byte lo } supplementary_plane1,
|
|
154
|
-
{ plane_02_10 plane, byte mid, byte lo } supplementary_planes2_16
|
|
155
|
-
>;
|
|
156
|
-
|
|
157
|
-
-- Linked-list string: nil or (unicode car, string cdr).
|
|
158
|
-
$ string = < {} nil, { unicode car, string cdr } cons >;
|
|
159
|
-
|
|
160
|
-
---------------------------------------------------------------
|
|
161
|
-
-- §4. Pattern
|
|
162
|
-
---------------------------------------------------------------
|
|
163
|
-
|
|
164
|
-
-- Edge: a labeled edge in a pattern graph.
|
|
165
|
-
-- 'label' is the field name or tag name.
|
|
166
|
-
-- 'target' is the index (as $bits) of the target node in the pattern list.
|
|
167
|
-
|
|
168
|
-
$ edge = { string label, bits target };
|
|
169
|
-
|
|
170
|
-
-- Edge list: the edges of a pattern node, sorted by label.
|
|
171
|
-
|
|
172
|
-
$ edges = < {} nil, { edge car, edges cdr } cons >;
|
|
173
|
-
|
|
174
|
-
-- Pattern node: one of five kinds.
|
|
175
|
-
-- "any" is the unconstrained position (...), carrying no edges.
|
|
176
|
-
-- The four others carry their edge list directly.
|
|
177
|
-
|
|
178
|
-
$ pattern-node = <
|
|
179
|
-
{} any,
|
|
180
|
-
edges open-product,
|
|
181
|
-
edges open-union,
|
|
182
|
-
edges closed-product,
|
|
183
|
-
edges closed-union
|
|
184
|
-
>;
|
|
185
|
-
|
|
186
|
-
-- Pattern: a cons-list of pattern nodes.
|
|
187
|
-
-- Node 0 (first element) is the root.
|
|
188
|
-
-- Edges reference nodes by their index in this list, encoded as $bits.
|
|
189
|
-
--
|
|
190
|
-
-- The singleton pattern of $pattern itself is a fixed constant.
|
|
191
|
-
-- That constant is the implicit framing for all k wire formats:
|
|
192
|
-
-- to decode any value, first decode a $pattern under that constant,
|
|
193
|
-
-- then decode the value under the pattern just obtained.
|
|
194
|
-
|
|
195
|
-
$ pattern = < {} nil, { pattern-node car, pattern cdr } cons >;
|
|
196
|
-
|
|
197
|
-
$pattern
|
package/kkk.klib
DELETED
|
Binary file
|
package/kkk.klib~
DELETED
|
Binary file
|