Commit 296b24c7efa3a4493e5590f955c768ef0a1b546d

Thomas de Grivel 2024-09-04T15:21:20

wip doc

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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
diff --git a/Makefile b/Makefile
index 5237633..9ef9ffc 100644
--- a/Makefile
+++ b/Makefile
@@ -464,6 +464,7 @@ kc3.index: sources.mk Makefile
 	for F in ${KC3_TEST_HTTPD_SOURCES}; do echo "$$F"; done >> kc3.index.tmp
 	for F in ${KC3_OTHER_SOURCES}; do echo "$$F"; done >> kc3.index.tmp
 	for F in ${KC3_EXTERNAL_SOURCES}; do echo "$$F"; done >> kc3.index.tmp
+	for F in ${KC3_DOC_SOURCES}; do echo "$$F"; done >> kc3.index.tmp
 	sort -u < kc3.index.tmp > kc3.index
 	rm kc3.index.tmp
 
diff --git a/doc/kc3/1_introduction.en.md b/doc/kc3/1_introduction.en.md
new file mode 100644
index 0000000..c4dcca6
--- /dev/null
+++ b/doc/kc3/1_introduction.en.md
@@ -0,0 +1,69 @@
+---
+title: 1. Introduction
+---
+
+# Introduction
+
+KC3 is currently a programming language project, inspired by C, Elixir
+and Common Lisp. It could be described as C with Elixir modules,
+pattern matching, and a semantic object system. The idea is to plug
+modules, closures, pattern matching, a graph database and
+metaprogramming into C99 with an extremely small set of dependencies.
+
+Supported operating systems (additionnal dependencies) :
+ - BSD
+ - Linux (libbsd, libmd)
+ - MacOS X (libmd)
+ - Windows (MSys2)
+
+Supported architectures :
+ - aarch64 (arm64, Apple M1, Apple M2)
+ - amd64
+ - i386
+ - sparc64
+
+
+## Modules
+
+Everything in KC3 is in a module. A module is a namespace,
+and is named with a symbol starting with a uppercase character.
+For instance `Sym` and `Str` are valid module names.
+
+Each module can define a type and a module name can also be a
+type name if the corresponding module defines a type.
+
+The module can also include definitions for functions for
+operating on the module type or other types.
+
+The default module is `KC3`, which is defined as facts (triples)
+in `lib/kc3/0.1/kc3.facts`.
+
+
+## Data types
+
+Basic data types in KC3 are :
+ - Strings : `Str`, e.g. `"Hello, world !"`
+ - Symbols : `Sym`, e.g. `:hello` or `Hello`
+ - Booleans : `Bool`, `true` or `false`
+ - Numbers
+   - Integers
+     - Small integers
+       - Signed small integers : `S8`, `S16`, `S32`, `S64`, `Sw`
+       - Unsigned small integers : `U8`, `U16`, `U32`, `U64`, `Uw`
+     - Large integers : `Integer`
+   - Rational numbers (fractions of integers) : `Ratio`, e.g. `-2/3`
+   - Floating point numbers : `F32`, `F64`, `F128`
+   - Complex numbers (i = √(-1)) : `Complex`, e.g. `1 +i 2`
+ - Lists : `List`, e.g. `[1, 2, 3]`
+ - Tuples : `Tuple`, e.g. `{:ok, 123}`
+ - Maps : `Map`, e.g. `%{id: 1, login: "dx"}`
+ - Structs : e.g. `%GL.Sphere{}`
+ - Quoted code : `Quote`, e.g. `quote 1 + 2`
+ - Identifiers : `Ident`, e.g. `quote hello`
+ - Function or operator call : `Call`, e.g. `quote sqrt(1)`, `quote 1 + 2`
+ - Code blocks : `Block`, e.g. `{ 1 + 2; 3 + 4 }`
+ - Function : `Fn`, e.g. `fn (x) { x * 2 }`
+ - C function : `Cfn`, e.g. `cfn Tag "tag_add" (Tag, Tag, Result)`
+ - Unquoted code: `Unquote`, e.g. `quote 1 + unquote(x)`
+ - Variables : `Var`, e.g. `?`
+ - Void : `Void`, e.g. `void`
diff --git a/doc/kc3/integer.en.md b/doc/kc3/integer.en.md
new file mode 100644
index 0000000..5ec89dc
--- /dev/null
+++ b/doc/kc3/integer.en.md
@@ -0,0 +1,132 @@
+---
+title: 2. Integers
+---
+
+# Integers
+
+## Small integers
+
+IKC3 supports all C integer type sizes from `U8` (matching the C type `uint8_t`)
+to `U64` (matching the C type `uint64_t`) for unsigned integers,
+and from `S8` to `S64` for signed integers.
+
+In addition to these 8 basic integer types there are 2 pointer-sized
+integer types :
+`Uw` for unsigned pointer-sized integers,
+and `Sw` for signed pointer-sized integers.
+
+Small integers take little space, are static, they are passed directly and
+not as a pointer, and for these reasons are fast.
+
+They do not need to be cleaned after use and thus can be used in arrays like
+is usually done in C.
+
+```
+ikc3> type(-1)
+S8
+ikc3> type(-128)
+S16
+ikc3> type(-32768)
+S32
+ikc3> type(-2147483648)
+S64
+ikc3> type(-9223372036854775807)
+S64
+ikc3> type(0)
+U8
+ikc3> type(256)
+U16
+ikc3> type(65536)
+U32
+ikc3> type(4294967296)
+U64
+ikc3> type(18446744073709551615)
+U64
+```
+
+## Large integers
+
+IKC3 supports large integers and they are compatible with small integers.
+Their type is `Integer` and can support numbers as large as memory allows.
+They are slow because they are allocated dynamically on the heap
+using malloc.
+
+```
+ikc3> type(1000000000000000000000000000000)
+Integer
+```
+
+
+## Operations on integers
+
+### Operator `~`
+
+Binary not.
+
+```
+ikc3> ~ 1
+254
+ikc3> ~ -1
+0
+ikc3> ~ 0
+255
+ikc3> ~ 255
+0
+ikc3> ~ (U16) 1
+65534
+ikc3> ~ (S16) 1
+-2
+```
+
+### Operator `+`
+
+Integer addition.
+
+All positive integers can be defined in terms of addition of :
+zero or a positive integer, and one. E.g.
+
+```
+1 = 0 + 1
+2 = 0 + 1 + 1
+3 = 0 + 1 + 1 + 1
+etc.
+```
+
+### Operator `-`
+
+Integer subtraction. Take an integer and remove another integer from it.
+
+### Operator `*`
+
+Integer multiplication. Init result to zero, add an integer `a` and
+repeat `b` times.
+
+### Operator `/`
+
+Integer division. The inverse of multiplication :
+for all integers `a` and `b` there is a couple `q` and `r` that satisfies
+`a = b * q + r`. Integer division returns `q`.
+
+### Operator `mod`
+
+Integer modulo. Returns `r` in the previous equation (see Operator `/`)
+
+### Operator `<<`
+
+Left shift
+
+
+# Examples
+
+```
+ikc3> type(1)
+U8
+ikc3> type(1000000000000000000000000000000)
+Integer
+ikc3> a = 1 + 100000000000000000000000000000000
+100000000000000000000000000000001
+ikc3> a * a
+10000000000000000000000000000000200000000000000000000000000000001
+ikc3> a * a / 1000000000000000000000000000000000000000000000000000
+10000000000000
+```
diff --git a/doc/kc3/list.md b/doc/kc3/list.md
new file mode 100644
index 0000000..adf816e
--- /dev/null
+++ b/doc/kc3/list.md
@@ -0,0 +1,27 @@
+# Module List
+
+Regular lists can be :
+ - an element and a list : `[1 | [2]]`
+ - multiple elements : `[1, 2, 3]`
+ - multiple elements and a list : `[1, 2 | [3, 4]]`
+ - the empty list : `[]`
+
+Regular lists end with the empty list : `[1] == [1 | []]`.
+
+You can also contruct dotted lists like in Common Lisp where
+the next list pointer is an arbitrary form. E.g. :
+ - an element and an element : `[1 | 2]`
+ - multiple elements and an element : `[1, 2, 3 | 4]`
+ - the empty list and an element : `[[] | 1]`
+
+All these list formats are supported in pattern matching.
+
+## Functions
+
+```
+List List.map (List, Fn)
+```
+
+```
+List List.reverse (List)
+```
diff --git a/doc/kc3/map.en.md b/doc/kc3/map.en.md
new file mode 100644
index 0000000..3c17511
--- /dev/null
+++ b/doc/kc3/map.en.md
@@ -0,0 +1,46 @@
+---
+title: 3. Map
+---
+
+# Maps
+
+KC3 maps are like Elixir maps, they are key-values enclosed in `%{}` :
+
+```
+ikc3> a = %{id: 1, title: "My title", message: "Hello, world !"}
+%{id: 1, title: "My title", message: "Hello, world !"}
+```
+
+Destructuring works with maps to extract values :
+
+```
+ikc3> %{id: id, title: "My title", message: message} = ^ a
+%{id: 1, title: "My title", message: "Hello, world !"}
+ikc3> id
+1
+ikc3> message
+"Hello, world !"
+```
+
+
+You can use the dot syntax to access map values from a `Sym` key :
+
+```
+ikc3> a = %{id: 1, title: "My title", message: "Hello, world !"}
+%{id: 1, title: "My title", message: "Hello, world !"}
+ikc3> a.id
+1
+ikc3> a.message
+"Hello, world !"
+```
+
+You can also use the `KC3.access` function for the same result :
+
+```
+ikc3> a = %{id: 1, title: "My title", message: "Hello, world !"}
+%{id: 1, title: "My title", message: "Hello, world !"}
+ikc3> access(a, :id)
+1
+ikc3> access(a, :message)
+"Hello, world !"
+```
diff --git a/doc/kc3/ratio.en.md b/doc/kc3/ratio.en.md
new file mode 100644
index 0000000..39f7c67
--- /dev/null
+++ b/doc/kc3/ratio.en.md
@@ -0,0 +1,21 @@
+---
+title: 4. Ratio
+---
+
+# Ratios
+
+Ratios are made with a couple of large integers : the numerator
+which can be any number, and the denominator which has to be positive.
+They represent fractions of integral numbers.
+They are written with a slash and no space.
+
+```
+ikc3> 1/2 + 2/3
+7/6
+ikc3> 1/2 * 2/3
+1/3
+ikc3> 1/2 / 2/3
+3/4
+ikc3> 1/2 - 2/3
+-1/6
+```
diff --git a/doc/kc3/variable.md b/doc/kc3/variable.md
new file mode 100644
index 0000000..5d12c8d
--- /dev/null
+++ b/doc/kc3/variable.md
@@ -0,0 +1,68 @@
+# Variables
+
+Variables in C3 can be defined using the litteral value for a variable
+which is always `?`. You can cast this litteral value and it will not
+really be casted but it will give you a typed variable litteral value.
+E.g. `(List) ?`.
+The typed variable litteral value will only accept to be set once to
+one value of the variable's type (in this example the type of a linked
+list).
+
+It's actually a syntax so you cannot rename `?` by mistake and
+so is an easy task to do static analysis of variable creation.
+
+The default type for a variable which you can also specify explicitly
+is `Tag` which is an enum-tagged union type of any other C3 types
+currently defined in the environment. So `?` is exactly equivalent to
+`(Tag) ?` and they will both accept to be set once to one value of any
+type.
+
+Actually all variables are allocated as tags and in the end the typing
+is dynamic but it could be made static through JIT compilation of
+functions.
+
+A variable is settable once and cannot be changed afterwards (there is
+an exception if you write C code and link to it but it is not easy nor
+silent).
+
+This way you do not need to lock or trust any behaviour, once your
+variable is set to a value the value of the variable will never change,
+it really is read-only.
+
+
+## Init and C interoperatbility
+
+To set the value of a variable in the end you need to call a C function
+that should accept this C function definition :
+`quote cfn unquote(type) unquote("init_#{variable_type}#{init_suffix}") (Result, ...)`.
+There are many functions for this, here is a quick list :
+  - `tag_init_1` takes a C string as an argument and returns a value of
+  any type currently defined in the C3 environment.
+  - `#{type}_init_1` C functions take a C string as an argument and return
+  a value of type `type`.
+  - `tag_init_copy` takes a tag as an argument and returns a deep copy
+  of it.
+
+You can also use the assignment operator which is `<-` which in turn calls
+`tag_init_copy`. It works like the C assignment operator (`=`).
+
+Examples :
+```
+# Declare a unsigned byte 8 bits variable "x".
+x = (U8) ?
+# Set the variable "x" to zero.
+x <- 0
+# Allocate again for the same binding name "x"
+x = (U8) ?
+# Also set the new variable "x" to zero with just one Unicode symbol
+# that is AltGr+Y on my keyboard.
+x ← 0
+```
+
+
+## So how do I change anything if it is read-only ?
+
+You can always reset an existing binding at will to another variable
+litteral and another variable will be created for the same name and it
+will be in a different memory location, settable once and then
+read-only again so you can use it without locking.
diff --git a/doc/list.md b/doc/list.md
deleted file mode 100644
index adf816e..0000000
--- a/doc/list.md
+++ /dev/null
@@ -1,27 +0,0 @@
-# Module List
-
-Regular lists can be :
- - an element and a list : `[1 | [2]]`
- - multiple elements : `[1, 2, 3]`
- - multiple elements and a list : `[1, 2 | [3, 4]]`
- - the empty list : `[]`
-
-Regular lists end with the empty list : `[1] == [1 | []]`.
-
-You can also contruct dotted lists like in Common Lisp where
-the next list pointer is an arbitrary form. E.g. :
- - an element and an element : `[1 | 2]`
- - multiple elements and an element : `[1, 2, 3 | 4]`
- - the empty list and an element : `[[] | 1]`
-
-All these list formats are supported in pattern matching.
-
-## Functions
-
-```
-List List.map (List, Fn)
-```
-
-```
-List List.reverse (List)
-```
diff --git a/doc/variable.md b/doc/variable.md
deleted file mode 100644
index 5d12c8d..0000000
--- a/doc/variable.md
+++ /dev/null
@@ -1,68 +0,0 @@
-# Variables
-
-Variables in C3 can be defined using the litteral value for a variable
-which is always `?`. You can cast this litteral value and it will not
-really be casted but it will give you a typed variable litteral value.
-E.g. `(List) ?`.
-The typed variable litteral value will only accept to be set once to
-one value of the variable's type (in this example the type of a linked
-list).
-
-It's actually a syntax so you cannot rename `?` by mistake and
-so is an easy task to do static analysis of variable creation.
-
-The default type for a variable which you can also specify explicitly
-is `Tag` which is an enum-tagged union type of any other C3 types
-currently defined in the environment. So `?` is exactly equivalent to
-`(Tag) ?` and they will both accept to be set once to one value of any
-type.
-
-Actually all variables are allocated as tags and in the end the typing
-is dynamic but it could be made static through JIT compilation of
-functions.
-
-A variable is settable once and cannot be changed afterwards (there is
-an exception if you write C code and link to it but it is not easy nor
-silent).
-
-This way you do not need to lock or trust any behaviour, once your
-variable is set to a value the value of the variable will never change,
-it really is read-only.
-
-
-## Init and C interoperatbility
-
-To set the value of a variable in the end you need to call a C function
-that should accept this C function definition :
-`quote cfn unquote(type) unquote("init_#{variable_type}#{init_suffix}") (Result, ...)`.
-There are many functions for this, here is a quick list :
-  - `tag_init_1` takes a C string as an argument and returns a value of
-  any type currently defined in the C3 environment.
-  - `#{type}_init_1` C functions take a C string as an argument and return
-  a value of type `type`.
-  - `tag_init_copy` takes a tag as an argument and returns a deep copy
-  of it.
-
-You can also use the assignment operator which is `<-` which in turn calls
-`tag_init_copy`. It works like the C assignment operator (`=`).
-
-Examples :
-```
-# Declare a unsigned byte 8 bits variable "x".
-x = (U8) ?
-# Set the variable "x" to zero.
-x <- 0
-# Allocate again for the same binding name "x"
-x = (U8) ?
-# Also set the new variable "x" to zero with just one Unicode symbol
-# that is AltGr+Y on my keyboard.
-x ← 0
-```
-
-
-## So how do I change anything if it is read-only ?
-
-You can always reset an existing binding at will to another variable
-litteral and another variable will be created for the same name and it
-will be in a different memory location, settable once and then
-read-only again so you can use it without locking.
diff --git a/kc3.index b/kc3.index
index f0bac1f..84ea84b 100644
--- a/kc3.index
+++ b/kc3.index
@@ -254,6 +254,8 @@ img/fly-dead.png
 img/fly-noto.png
 img/iris-kc3-004.jpeg
 img/kc3.1.xcf
+img/kc3.1080.jpg
+img/kc3.1080.png
 img/kc3.128.jpg
 img/kc3.128.png
 img/kc3.16.jpg
@@ -266,6 +268,12 @@ img/kc3.512.jpg
 img/kc3.512.png
 img/kc3.64.jpg
 img/kc3.64.png
+img/kc3.640.jpg
+img/kc3.640.png
+img/kc3.720.jpg
+img/kc3.720.png
+img/kc3.96.jpg
+img/kc3.96.png
 img/kc3.iconset/icon_128x128.png
 img/kc3.iconset/icon_16x16.png
 img/kc3.iconset/icon_256x256.png
diff --git a/sources.mk b/sources.mk
index 3f5b0ec..04e9c9a 100644
--- a/sources.mk
+++ b/sources.mk
@@ -1503,3 +1503,11 @@ KC3_EXTERNAL_SOURCES = \
 	"ucd2c/UCD/extracted/DerivedNumericType.txt" \
 	"ucd2c/UCD/extracted/DerivedNumericValues.txt" \
 
+KC3_DOC_SOURCES = \
+	"doc/kc3/1_introduction.en.md" \
+	"doc/kc3/integer.en.md" \
+	"doc/kc3/list.md" \
+	"doc/kc3/map.en.md" \
+	"doc/kc3/ratio.en.md" \
+	"doc/kc3/variable.md" \
+
diff --git a/sources.sh b/sources.sh
index a2088ef..2765539 100644
--- a/sources.sh
+++ b/sources.sh
@@ -13,3 +13,4 @@ KC3_TEST_HTTP_SOURCES='test/http/01_socket_buf.kc3 test/http/01_socket_buf.out.e
 KC3_TEST_HTTPD_SOURCES='test/httpd/.keep '
 KC3_OTHER_SOURCES='AUTHORS Makefile README.md config.subr configure env kc3.index kc3.version libkc3/tag_init.rb license.h sources.mk sources.sh '
 KC3_EXTERNAL_SOURCES='libtommath/LICENSE libtommath/README.md libtommath/bn_cutoffs.c libtommath/bn_deprecated.c libtommath/bn_mp_2expt.c libtommath/bn_mp_abs.c libtommath/bn_mp_add.c libtommath/bn_mp_add_d.c libtommath/bn_mp_addmod.c libtommath/bn_mp_and.c libtommath/bn_mp_clamp.c libtommath/bn_mp_clear.c libtommath/bn_mp_clear_multi.c libtommath/bn_mp_cmp.c libtommath/bn_mp_cmp_d.c libtommath/bn_mp_cmp_mag.c libtommath/bn_mp_cnt_lsb.c libtommath/bn_mp_complement.c libtommath/bn_mp_copy.c libtommath/bn_mp_count_bits.c libtommath/bn_mp_decr.c libtommath/bn_mp_div.c libtommath/bn_mp_div_2.c libtommath/bn_mp_div_2d.c libtommath/bn_mp_div_3.c libtommath/bn_mp_div_d.c libtommath/bn_mp_dr_is_modulus.c libtommath/bn_mp_dr_reduce.c libtommath/bn_mp_dr_setup.c libtommath/bn_mp_error_to_string.c libtommath/bn_mp_exch.c libtommath/bn_mp_expt_u32.c libtommath/bn_mp_exptmod.c libtommath/bn_mp_exteuclid.c libtommath/bn_mp_fread.c libtommath/bn_mp_from_sbin.c libtommath/bn_mp_from_ubin.c libtommath/bn_mp_fwrite.c libtommath/bn_mp_gcd.c libtommath/bn_mp_get_double.c libtommath/bn_mp_get_i32.c libtommath/bn_mp_get_i64.c libtommath/bn_mp_get_l.c libtommath/bn_mp_get_ll.c libtommath/bn_mp_get_mag_u32.c libtommath/bn_mp_get_mag_u64.c libtommath/bn_mp_get_mag_ul.c libtommath/bn_mp_get_mag_ull.c libtommath/bn_mp_grow.c libtommath/bn_mp_incr.c libtommath/bn_mp_init.c libtommath/bn_mp_init_copy.c libtommath/bn_mp_init_i32.c libtommath/bn_mp_init_i64.c libtommath/bn_mp_init_l.c libtommath/bn_mp_init_ll.c libtommath/bn_mp_init_multi.c libtommath/bn_mp_init_set.c libtommath/bn_mp_init_size.c libtommath/bn_mp_init_u32.c libtommath/bn_mp_init_u64.c libtommath/bn_mp_init_ul.c libtommath/bn_mp_init_ull.c libtommath/bn_mp_invmod.c libtommath/bn_mp_is_square.c libtommath/bn_mp_iseven.c libtommath/bn_mp_isodd.c libtommath/bn_mp_kronecker.c libtommath/bn_mp_lcm.c libtommath/bn_mp_log_u32.c libtommath/bn_mp_lshd.c libtommath/bn_mp_mod.c libtommath/bn_mp_mod_2d.c libtommath/bn_mp_mod_d.c libtommath/bn_mp_montgomery_calc_normalization.c libtommath/bn_mp_montgomery_reduce.c libtommath/bn_mp_montgomery_setup.c libtommath/bn_mp_mul.c libtommath/bn_mp_mul_2.c libtommath/bn_mp_mul_2d.c libtommath/bn_mp_mul_d.c libtommath/bn_mp_mulmod.c libtommath/bn_mp_neg.c libtommath/bn_mp_or.c libtommath/bn_mp_pack.c libtommath/bn_mp_pack_count.c libtommath/bn_mp_prime_fermat.c libtommath/bn_mp_prime_frobenius_underwood.c libtommath/bn_mp_prime_is_prime.c libtommath/bn_mp_prime_miller_rabin.c libtommath/bn_mp_prime_next_prime.c libtommath/bn_mp_prime_rabin_miller_trials.c libtommath/bn_mp_prime_rand.c libtommath/bn_mp_prime_strong_lucas_selfridge.c libtommath/bn_mp_radix_size.c libtommath/bn_mp_radix_smap.c libtommath/bn_mp_rand.c libtommath/bn_mp_read_radix.c libtommath/bn_mp_reduce.c libtommath/bn_mp_reduce_2k.c libtommath/bn_mp_reduce_2k_l.c libtommath/bn_mp_reduce_2k_setup.c libtommath/bn_mp_reduce_2k_setup_l.c libtommath/bn_mp_reduce_is_2k.c libtommath/bn_mp_reduce_is_2k_l.c libtommath/bn_mp_reduce_setup.c libtommath/bn_mp_root_u32.c libtommath/bn_mp_rshd.c libtommath/bn_mp_sbin_size.c libtommath/bn_mp_set.c libtommath/bn_mp_set_double.c libtommath/bn_mp_set_i32.c libtommath/bn_mp_set_i64.c libtommath/bn_mp_set_l.c libtommath/bn_mp_set_ll.c libtommath/bn_mp_set_u32.c libtommath/bn_mp_set_u64.c libtommath/bn_mp_set_ul.c libtommath/bn_mp_set_ull.c libtommath/bn_mp_shrink.c libtommath/bn_mp_signed_rsh.c libtommath/bn_mp_sqr.c libtommath/bn_mp_sqrmod.c libtommath/bn_mp_sqrt.c libtommath/bn_mp_sqrtmod_prime.c libtommath/bn_mp_sub.c libtommath/bn_mp_sub_d.c libtommath/bn_mp_submod.c libtommath/bn_mp_to_radix.c libtommath/bn_mp_to_sbin.c libtommath/bn_mp_to_ubin.c libtommath/bn_mp_ubin_size.c libtommath/bn_mp_unpack.c libtommath/bn_mp_xor.c libtommath/bn_mp_zero.c libtommath/bn_prime_tab.c libtommath/bn_s_mp_add.c libtommath/bn_s_mp_balance_mul.c libtommath/bn_s_mp_exptmod.c libtommath/bn_s_mp_exptmod_fast.c libtommath/bn_s_mp_get_bit.c libtommath/bn_s_mp_invmod_fast.c libtommath/bn_s_mp_invmod_slow.c libtommath/bn_s_mp_karatsuba_mul.c libtommath/bn_s_mp_karatsuba_sqr.c libtommath/bn_s_mp_montgomery_reduce_fast.c libtommath/bn_s_mp_mul_digs.c libtommath/bn_s_mp_mul_digs_fast.c libtommath/bn_s_mp_mul_high_digs.c libtommath/bn_s_mp_mul_high_digs_fast.c libtommath/bn_s_mp_prime_is_divisible.c libtommath/bn_s_mp_rand_jenkins.c libtommath/bn_s_mp_rand_platform.c libtommath/bn_s_mp_reverse.c libtommath/bn_s_mp_sqr.c libtommath/bn_s_mp_sqr_fast.c libtommath/bn_s_mp_sub.c libtommath/bn_s_mp_toom_mul.c libtommath/bn_s_mp_toom_sqr.c libtommath/demo/mtest_opponent.c libtommath/demo/shared.c libtommath/demo/shared.h libtommath/demo/test.c libtommath/demo/timing.c libtommath/etc/2kprime.c libtommath/etc/drprime.c libtommath/etc/mersenne.c libtommath/etc/mont.c libtommath/etc/pprime.c libtommath/etc/tune.c libtommath/mtest/logtab.h libtommath/mtest/mpi-config.h libtommath/mtest/mpi-types.h libtommath/mtest/mpi.c libtommath/mtest/mpi.h libtommath/mtest/mtest.c libtommath/tommath.h libtommath/tommath_class.h libtommath/tommath_cutoffs.h libtommath/tommath_private.h libtommath/tommath_superclass.h linenoise/LICENSE linenoise/README.markdown linenoise/example.c linenoise/linenoise.c linenoise/linenoise.h ucd2c/UCD.zip ucd2c/UCD/ArabicShaping.txt ucd2c/UCD/BidiBrackets.txt ucd2c/UCD/BidiCharacterTest.txt ucd2c/UCD/BidiMirroring.txt ucd2c/UCD/BidiTest.txt ucd2c/UCD/Blocks.txt ucd2c/UCD/CJKRadicals.txt ucd2c/UCD/CaseFolding.txt ucd2c/UCD/CompositionExclusions.txt ucd2c/UCD/DerivedAge.txt ucd2c/UCD/DerivedCoreProperties.txt ucd2c/UCD/DerivedNormalizationProps.txt ucd2c/UCD/EastAsianWidth.txt ucd2c/UCD/EmojiSources.txt ucd2c/UCD/EquivalentUnifiedIdeograph.txt ucd2c/UCD/HangulSyllableType.txt ucd2c/UCD/Index.txt ucd2c/UCD/IndicPositionalCategory.txt ucd2c/UCD/IndicSyllabicCategory.txt ucd2c/UCD/Jamo.txt ucd2c/UCD/LineBreak.txt ucd2c/UCD/NameAliases.txt ucd2c/UCD/NamedSequences.txt ucd2c/UCD/NamedSequencesProv.txt ucd2c/UCD/NamesList.txt ucd2c/UCD/NormalizationCorrections.txt ucd2c/UCD/NormalizationTest.txt ucd2c/UCD/NushuSources.txt ucd2c/UCD/PropList.txt ucd2c/UCD/PropertyAliases.txt ucd2c/UCD/PropertyValueAliases.txt ucd2c/UCD/ReadMe.txt ucd2c/UCD/ScriptExtensions.txt ucd2c/UCD/Scripts.txt ucd2c/UCD/SpecialCasing.txt ucd2c/UCD/StandardizedVariants.txt ucd2c/UCD/TangutSources.txt ucd2c/UCD/USourceData.txt ucd2c/UCD/USourceGlyphs.pdf ucd2c/UCD/USourceRSChart.pdf ucd2c/UCD/UnicodeData.txt ucd2c/UCD/VerticalOrientation.txt ucd2c/UCD/auxiliary/GraphemeBreakProperty.txt ucd2c/UCD/auxiliary/GraphemeBreakTest.txt ucd2c/UCD/auxiliary/LineBreakTest.txt ucd2c/UCD/auxiliary/SentenceBreakProperty.txt ucd2c/UCD/auxiliary/SentenceBreakTest.txt ucd2c/UCD/auxiliary/WordBreakProperty.txt ucd2c/UCD/auxiliary/WordBreakTest.txt ucd2c/UCD/emoji/ReadMe.txt ucd2c/UCD/emoji/emoji-data.txt ucd2c/UCD/emoji/emoji-variation-sequences.txt ucd2c/UCD/extracted/DerivedBidiClass.txt ucd2c/UCD/extracted/DerivedBinaryProperties.txt ucd2c/UCD/extracted/DerivedCombiningClass.txt ucd2c/UCD/extracted/DerivedDecompositionType.txt ucd2c/UCD/extracted/DerivedEastAsianWidth.txt ucd2c/UCD/extracted/DerivedGeneralCategory.txt ucd2c/UCD/extracted/DerivedJoiningGroup.txt ucd2c/UCD/extracted/DerivedJoiningType.txt ucd2c/UCD/extracted/DerivedLineBreak.txt ucd2c/UCD/extracted/DerivedName.txt ucd2c/UCD/extracted/DerivedNumericType.txt ucd2c/UCD/extracted/DerivedNumericValues.txt '
+KC3_DOC_SOURCES='doc/kc3/1_introduction.en.md doc/kc3/integer.en.md doc/kc3/list.md doc/kc3/map.en.md doc/kc3/ratio.en.md doc/kc3/variable.md '
diff --git a/update_sources b/update_sources
index 5da4a4a..a5eb9d1 100755
--- a/update_sources
+++ b/update_sources
@@ -76,6 +76,9 @@ ucd2c/UCD.zip
 $(find ucd2c/UCD -type f)"
 sources KC3_EXTERNAL_SOURCES "$KC3_EXTERNAL_SOURCES"
 
+KC3_DOC_SOURCES="$(find doc -name '*.md')"
+sources KC3_DOC_SOURCES "$KC3_DOC_SOURCES"
+
 update_sources_mk
 update_sources_sh