@fraczak/k 5.1.2 → 6.0.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.
Files changed (115) hide show
  1. package/.codex +0 -0
  2. package/Code-derivation-tests/blowup.mjs +3 -3
  3. package/Code-derivation-tests/bnat.mjs +2 -2
  4. package/Code-derivation-tests/codec-witness-pattern.mjs +50 -0
  5. package/Code-derivation-tests/convergence-strategy.mjs +24 -0
  6. package/Code-derivation-tests/dot.mjs +12 -9
  7. package/Code-derivation-tests/filter-syntax.mjs +21 -0
  8. package/Code-derivation-tests/loop.mjs +8 -2
  9. package/Code-derivation-tests/nat.mjs +1 -1
  10. package/Code-derivation-tests/not-not.mjs +3 -3
  11. package/Code-derivation-tests/pattern-envelope.mjs +68 -0
  12. package/Code-derivation-tests/rlz.mjs +2 -2
  13. package/{BIG_PICTURE.md → DOCS/BIG_PICTURE.md} +103 -50
  14. package/DOCS/REPL.md +191 -0
  15. package/DOCS/a.html +398 -0
  16. package/DOCS/book/01-introduction.md +51 -0
  17. package/DOCS/book/02-syntax-and-values.md +111 -0
  18. package/DOCS/book/03-types-as-finite-automata.md +156 -0
  19. package/DOCS/book/04-partial-functions-and-composition.md +146 -0
  20. package/DOCS/book/05-typing-filters-and-normalization.md +111 -0
  21. package/DOCS/book-combined.html +3798 -0
  22. package/DOCS/book-combined.md +3745 -0
  23. package/DOCS/book-combined.pdf +0 -0
  24. package/DOCS/book-combined.tex +5682 -0
  25. package/DOCS/book.html +65 -0
  26. package/DOCS/book.md +54 -0
  27. package/DOCS/book.pdf +0 -0
  28. package/DOCS/book.tex +150 -0
  29. package/NAT.k~ +452 -0
  30. package/README.md +204 -508
  31. package/TypeGraph.mjs +43 -0
  32. package/TypePatternGraph.mjs +251 -0
  33. package/Value.mjs +192 -0
  34. package/augmentation.mjs +198 -0
  35. package/codecs/BINARY_FORMAT.html +471 -0
  36. package/codecs/BINARY_FORMAT.md +53 -0
  37. package/codecs/POLYMORPHIC_BINARY_FORMAT.html +355 -0
  38. package/codecs/POLYMORPHIC_BINARY_FORMAT.md +303 -0
  39. package/codecs/README.md +215 -0
  40. package/codecs/example-pipeline.mjs +149 -0
  41. package/codecs/ieee.mjs +140 -0
  42. package/codecs/int.mjs +104 -0
  43. package/codecs/json-codec.mjs +215 -0
  44. package/codecs/json.mjs +40 -0
  45. package/codecs/k-parse.mjs +90 -0
  46. package/codecs/k-pattern.mjs +75 -0
  47. package/codecs/k-print.mjs +46 -0
  48. package/codecs/runtime/codec.mjs +768 -0
  49. package/codecs/runtime/ieee-pattern.mjs +30 -0
  50. package/codecs/runtime/pattern-json.mjs +96 -0
  51. package/codecs/runtime/prefix-codec.mjs +425 -0
  52. package/codecs/runtime/show-value.mjs +68 -0
  53. package/codecs/runtime/typeFromValue.mjs +34 -0
  54. package/codecs/runtime/unicode-string.mjs +220 -0
  55. package/codecs/show.mjs +41 -0
  56. package/codecs/string-codec.mjs +80 -0
  57. package/codecs/unit.mjs +51 -0
  58. package/codecs/utf16.mjs +66 -0
  59. package/codecs/utf8.mjs +37 -0
  60. package/codes.mjs +146 -44
  61. package/compiler.mjs +111 -0
  62. package/convergence.mjs +197 -0
  63. package/core.k +197 -0
  64. package/export.mjs +22 -32
  65. package/hash.mjs +29 -31
  66. package/ieee.klib +0 -0
  67. package/index.mjs +41 -15
  68. package/k-vscode/.vscode/launch.json +14 -0
  69. package/k-vscode/README.md +65 -0
  70. package/k-vscode/language-configuration.json +42 -0
  71. package/k-vscode/package-lock.json +4176 -0
  72. package/k-vscode/package.json +57 -0
  73. package/k-vscode/snippets/k.json +92 -0
  74. package/k-vscode/syntaxes/k.tmLanguage.json +243 -0
  75. package/k.mjs +56 -54
  76. package/object.mjs +517 -0
  77. package/objects/README.md +38 -0
  78. package/objects/compile-lib.mjs +42 -0
  79. package/objects/compile.mjs +42 -0
  80. package/objects/decompile.mjs +32 -0
  81. package/package.json +13 -6
  82. package/parser.jison +27 -46
  83. package/parser.mjs +68 -100
  84. package/pretty.mjs +21 -40
  85. package/repl2.mjs +662 -0
  86. package/run.mjs +264 -231
  87. package/symbol-table.mjs +3 -17
  88. package/test-fingerprint.mjs +7 -7
  89. package/test-hash-fuzz.mjs +107 -0
  90. package/test-hash-normalization.mjs +134 -0
  91. package/test-k-object.mjs +74 -0
  92. package/test-repl2.mjs +106 -0
  93. package/test.mjs +45 -70
  94. package/tests.sh +10 -1
  95. package/type_registry/registry.mjs~ +105 -0
  96. package/type_registry/typeParser.jison~ +132 -0
  97. package/typing.mjs +129 -676
  98. package/unification.mjs +157 -0
  99. package/valueIO.mjs +54 -0
  100. package/valueParser.jison +143 -0
  101. package/valueParser.mjs +713 -0
  102. package/Code-derivation-tests/built-in.mjs +0 -19
  103. package/Code-derivation-tests/vector.mjs +0 -19
  104. package/Filters/bug.k +0 -3
  105. package/Filters/composing.k +0 -15
  106. package/Filters/filter.k +0 -9
  107. package/TODO.md +0 -53
  108. package/TYPING.md +0 -365
  109. package/k-repl.cast +0 -1913
  110. package/k.cast +0 -618
  111. package/my-objects.json +0 -6
  112. package/patterns.mjs +0 -543
  113. package/repl.mjs +0 -213
  114. package/test-filters.mjs +0 -45
  115. package/typing-test.mjs +0 -40
package/DOCS/book.html ADDED
@@ -0,0 +1,65 @@
1
+ <div data-align="center">
2
+ <pre><code> { } { }
3
+ / \ {.lang name} |
4
+ lang by --&gt; name
5
+ | | |
6
+ &#39;k&#39; &#39;wojtek&#39; &#39;k&#39;</code></pre>
7
+ </div>
8
+ <h1 id="the-k-language-book">The k-language Book</h1>
9
+ <p>This book describes the k programming language - a minimal functional
10
+ language for transforming tree-structured data using partial functions
11
+ and algebraic data types.</p>
12
+ <h2 id="table-of-contents">Table of Contents</h2>
13
+ <ol type="1">
14
+ <li><a href="book/01-introduction.md">Introduction</a></li>
15
+ <li><a href="book/02-syntax-and-values.md">Syntax and Values</a><br />
16
+ </li>
17
+ <li><a href="book/03-types-as-finite-automata.md">Types as Finite
18
+ Automata</a></li>
19
+ <li><a href="book/04-partial-functions-and-composition.md">Partial
20
+ Functions and Composition</a></li>
21
+ <li><a href="book/05-typing-filters-and-normalization.md">Typing,
22
+ Filters, and Normalization</a></li>
23
+ <li><a href="book/06-values-in-memory.md">Values in Memory</a></li>
24
+ <li><a href="book/07-the-partial-function-abi.md">The Partial Function
25
+ ABI</a></li>
26
+ <li><a href="book/08-operational-semantics-and-execution.md">Operational
27
+ Semantics and Execution</a></li>
28
+ <li><a href="book/09-compiler-architecture.md">Compiler
29
+ Architecture</a></li>
30
+ <li><a href="book/10-from-ast-to-intermediate-representation.md">From
31
+ AST to Intermediate Representation</a></li>
32
+ <li><a href="book/11-llvm-basics.md">LLVM Basics</a></li>
33
+ <li><a href="book/12-code-generation.md">Code Generation</a></li>
34
+ <li><a href="book/13-linking-and-execution.md">Linking and
35
+ Execution</a></li>
36
+ <li><a href="book/14-canonical-serialization.md">Canonical
37
+ Serialization</a></li>
38
+ <li><a href="book/15-optimization-and-folding.md">Optimization and
39
+ Folding</a></li>
40
+ <li><a href="book/16-toward-a-universal-schema-registry.md">Toward a
41
+ Universal Schema Registry</a></li>
42
+ </ol>
43
+ <h2 id="appendices">Appendices</h2>
44
+ <ul>
45
+ <li><a
46
+ href="book/appendix-a-implementing-a-prototype-compiler-in-python.md">Appendix
47
+ A: Implementing a Prototype Compiler in Python</a></li>
48
+ <li><a
49
+ href="book/appendix-b-incorporating-external-predefined-types-and-functions.md">Appendix
50
+ B: Incorporating External Predefined Types and Functions</a></li>
51
+ </ul>
52
+ <hr />
53
+ <p><em>Note: This is the master file. Individual chapters are stored in
54
+ the <code>book/</code> directory for easier editing and maintenance.
55
+ Each chapter can be edited independently and the changes will be
56
+ reflected when the individual files are viewed.</em></p>
57
+ <h2 id="usage">Usage</h2>
58
+ <ul>
59
+ <li><strong>For reading</strong>: Click on any chapter link above to
60
+ read individual chapters</li>
61
+ <li><strong>For editing</strong>: Edit the individual chapter files in
62
+ the <code>book/</code> directory</li>
63
+ <li><strong>For publishing</strong>: Combine chapters as needed for
64
+ different output formats</li>
65
+ </ul>
package/DOCS/book.md ADDED
@@ -0,0 +1,54 @@
1
+ ---
2
+ title: "k-language"
3
+ author: "W. Fraczak"
4
+ ---
5
+
6
+ <div align="center">
7
+
8
+ ```
9
+ { } { }
10
+ / \ {.lang name} |
11
+ lang by --> name
12
+ | | |
13
+ 'k' 'wojtek' 'k'
14
+ ```
15
+
16
+ </div>
17
+
18
+ # The k-language Book
19
+
20
+ This book describes the k programming language - a minimal functional language for transforming tree-structured data using partial functions and algebraic data types.
21
+
22
+ ## Table of Contents
23
+
24
+ 1. [Introduction](book/01-introduction.md)
25
+ 2. [Syntax and Values](book/02-syntax-and-values.md)
26
+ 3. [Types as Finite Automata](book/03-types-as-finite-automata.md)
27
+ 4. [Partial Functions and Composition](book/04-partial-functions-and-composition.md)
28
+ 5. [Typing, Filters, and Normalization](book/05-typing-filters-and-normalization.md)
29
+ 6. [Values in Memory](book/06-values-in-memory.md)
30
+ 7. [The Partial Function ABI](book/07-the-partial-function-abi.md)
31
+ 8. [Operational Semantics and Execution](book/08-operational-semantics-and-execution.md)
32
+ 9. [Compiler Architecture](book/09-compiler-architecture.md)
33
+ 10. [From AST to Intermediate Representation](book/10-from-ast-to-intermediate-representation.md)
34
+ 11. [LLVM Basics](book/11-llvm-basics.md)
35
+ 12. [Code Generation](book/12-code-generation.md)
36
+ 13. [Linking and Execution](book/13-linking-and-execution.md)
37
+ 14. [Canonical Serialization](book/14-canonical-serialization.md)
38
+ 15. [Optimization and Folding](book/15-optimization-and-folding.md)
39
+ 16. [Toward a Universal Schema Registry](book/16-toward-a-universal-schema-registry.md)
40
+
41
+ ## Appendices
42
+
43
+ - [Appendix A: Implementing a Prototype Compiler in Python](book/appendix-a-implementing-a-prototype-compiler-in-python.md)
44
+ - [Appendix B: Incorporating External Predefined Types and Functions](book/appendix-b-incorporating-external-predefined-types-and-functions.md)
45
+
46
+ ---
47
+
48
+ *Note: This is the master file. Individual chapters are stored in the `book/` directory for easier editing and maintenance. Each chapter can be edited independently and the changes will be reflected when the individual files are viewed.*
49
+
50
+ ## Usage
51
+
52
+ - **For reading**: Click on any chapter link above to read individual chapters
53
+ - **For editing**: Edit the individual chapter files in the `book/` directory
54
+ - **For publishing**: Combine chapters as needed for different output formats
package/DOCS/book.pdf ADDED
Binary file
package/DOCS/book.tex ADDED
@@ -0,0 +1,150 @@
1
+ % Options for packages loaded elsewhere
2
+ \PassOptionsToPackage{unicode}{hyperref}
3
+ \PassOptionsToPackage{hyphens}{url}
4
+ \documentclass[
5
+ ]{article}
6
+ \usepackage{xcolor}
7
+ \usepackage{amsmath,amssymb}
8
+ \setcounter{secnumdepth}{-\maxdimen} % remove section numbering
9
+ \usepackage{iftex}
10
+ \ifPDFTeX
11
+ \usepackage[T1]{fontenc}
12
+ \usepackage[utf8]{inputenc}
13
+ \usepackage{textcomp} % provide euro and other symbols
14
+ \else % if luatex or xetex
15
+ \usepackage{unicode-math} % this also loads fontspec
16
+ \defaultfontfeatures{Scale=MatchLowercase}
17
+ \defaultfontfeatures[\rmfamily]{Ligatures=TeX,Scale=1}
18
+ \fi
19
+ \usepackage{lmodern}
20
+ \ifPDFTeX\else
21
+ % xetex/luatex font selection
22
+ \fi
23
+ % Use upquote if available, for straight quotes in verbatim environments
24
+ \IfFileExists{upquote.sty}{\usepackage{upquote}}{}
25
+ \IfFileExists{microtype.sty}{% use microtype if available
26
+ \usepackage[]{microtype}
27
+ \UseMicrotypeSet[protrusion]{basicmath} % disable protrusion for tt fonts
28
+ }{}
29
+ \makeatletter
30
+ \@ifundefined{KOMAClassName}{% if non-KOMA class
31
+ \IfFileExists{parskip.sty}{%
32
+ \usepackage{parskip}
33
+ }{% else
34
+ \setlength{\parindent}{0pt}
35
+ \setlength{\parskip}{6pt plus 2pt minus 1pt}}
36
+ }{% if KOMA class
37
+ \KOMAoptions{parskip=half}}
38
+ \makeatother
39
+ \setlength{\emergencystretch}{3em} % prevent overfull lines
40
+ \providecommand{\tightlist}{%
41
+ \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
42
+ \usepackage{bookmark}
43
+ \IfFileExists{xurl.sty}{\usepackage{xurl}}{} % add URL line breaks if available
44
+ \urlstyle{same}
45
+ \hypersetup{
46
+ pdftitle={k-language},
47
+ pdfauthor={W. Fraczak},
48
+ hidelinks,
49
+ pdfcreator={LaTeX via pandoc}}
50
+
51
+ \title{k-language}
52
+ \author{W. Fraczak}
53
+ \date{}
54
+
55
+ \begin{document}
56
+ \maketitle
57
+
58
+ \begin{verbatim}
59
+ { } { }
60
+ / \ {.lang name} |
61
+ lang by --> name
62
+ | | |
63
+ 'k' 'wojtek' 'k'
64
+ \end{verbatim}
65
+
66
+ \section{The k-language Book}\label{the-k-language-book}
67
+
68
+ This book describes the k programming language - a minimal functional
69
+ language for transforming tree-structured data using partial functions
70
+ and algebraic data types.
71
+
72
+ \subsection{Table of Contents}\label{table-of-contents}
73
+
74
+ \begin{enumerate}
75
+ \def\labelenumi{\arabic{enumi}.}
76
+ \tightlist
77
+ \item
78
+ \href{book/01-introduction.md}{Introduction}
79
+ \item
80
+ \href{book/02-syntax-and-values.md}{Syntax and Values}\\
81
+ \item
82
+ \href{book/03-types-as-finite-automata.md}{Types as Finite Automata}
83
+ \item
84
+ \href{book/04-partial-functions-and-composition.md}{Partial Functions
85
+ and Composition}
86
+ \item
87
+ \href{book/05-typing-filters-and-normalization.md}{Typing, Filters,
88
+ and Normalization}
89
+ \item
90
+ \href{book/06-values-in-memory.md}{Values in Memory}
91
+ \item
92
+ \href{book/07-the-partial-function-abi.md}{The Partial Function ABI}
93
+ \item
94
+ \href{book/08-operational-semantics-and-execution.md}{Operational
95
+ Semantics and Execution}
96
+ \item
97
+ \href{book/09-compiler-architecture.md}{Compiler Architecture}
98
+ \item
99
+ \href{book/10-from-ast-to-intermediate-representation.md}{From AST to
100
+ Intermediate Representation}
101
+ \item
102
+ \href{book/11-llvm-basics.md}{LLVM Basics}
103
+ \item
104
+ \href{book/12-code-generation.md}{Code Generation}
105
+ \item
106
+ \href{book/13-linking-and-execution.md}{Linking and Execution}
107
+ \item
108
+ \href{book/14-canonical-serialization.md}{Canonical Serialization}
109
+ \item
110
+ \href{book/15-optimization-and-folding.md}{Optimization and Folding}
111
+ \item
112
+ \href{book/16-toward-a-universal-schema-registry.md}{Toward a
113
+ Universal Schema Registry}
114
+ \end{enumerate}
115
+
116
+ \subsection{Appendices}\label{appendices}
117
+
118
+ \begin{itemize}
119
+ \tightlist
120
+ \item
121
+ \href{book/appendix-a-implementing-a-prototype-compiler-in-python.md}{Appendix
122
+ A: Implementing a Prototype Compiler in Python}
123
+ \item
124
+ \href{book/appendix-b-incorporating-external-predefined-types-and-functions.md}{Appendix
125
+ B: Incorporating External Predefined Types and Functions}
126
+ \end{itemize}
127
+
128
+ \begin{center}\rule{0.5\linewidth}{0.5pt}\end{center}
129
+
130
+ \emph{Note: This is the master file. Individual chapters are stored in
131
+ the \texttt{book/} directory for easier editing and maintenance. Each
132
+ chapter can be edited independently and the changes will be reflected
133
+ when the individual files are viewed.}
134
+
135
+ \subsection{Usage}\label{usage}
136
+
137
+ \begin{itemize}
138
+ \tightlist
139
+ \item
140
+ \textbf{For reading}: Click on any chapter link above to read
141
+ individual chapters
142
+ \item
143
+ \textbf{For editing}: Edit the individual chapter files in the
144
+ \texttt{book/} directory
145
+ \item
146
+ \textbf{For publishing}: Combine chapters as needed for different
147
+ output formats
148
+ \end{itemize}
149
+
150
+ \end{document}