@effekt-lang/effekt 0.2.1 → 0.2.2

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 (91) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +36 -0
  3. package/bin/effekt +0 -0
  4. package/bin/effekt.sh +2 -0
  5. package/libraries/chez/THIRD-PARTY.txt +11 -0
  6. package/libraries/chez/callcc/datatype.ss +188 -0
  7. package/libraries/chez/callcc/effekt.effekt +221 -0
  8. package/libraries/chez/callcc/effekt.ss +31 -0
  9. package/libraries/chez/callcc/seq.ss +44 -0
  10. package/libraries/chez/callcc/seq0.ss +69 -0
  11. package/libraries/chez/callcc/tail.ss +76 -0
  12. package/libraries/chez/callcc/tail0.ss +89 -0
  13. package/libraries/chez/common/effekt_matching.ss +100 -0
  14. package/libraries/chez/common/effekt_primitives.ss +97 -0
  15. package/libraries/chez/common/immutable/cslist.effekt +31 -0
  16. package/libraries/chez/common/immutable/dequeue.effekt +78 -0
  17. package/libraries/chez/common/immutable/list.effekt +643 -0
  18. package/libraries/chez/common/immutable/option.effekt +39 -0
  19. package/libraries/chez/common/immutable/result.effekt +29 -0
  20. package/libraries/chez/common/io/args.effekt +20 -0
  21. package/libraries/chez/common/mutable/array.effekt +27 -0
  22. package/libraries/chez/common/mutable/dict.effekt +30 -0
  23. package/libraries/chez/common/mutable/heap.effekt +12 -0
  24. package/libraries/chez/common/test.effekt +59 -0
  25. package/libraries/chez/common/text/pregexp.scm +772 -0
  26. package/libraries/chez/common/text/regex.effekt +33 -0
  27. package/libraries/chez/common/text/string.effekt +46 -0
  28. package/libraries/chez/lift/effekt.effekt +217 -0
  29. package/libraries/chez/lift/effekt.ss +118 -0
  30. package/libraries/chez/monadic/effekt.effekt +218 -0
  31. package/libraries/chez/monadic/effekt.ss +84 -0
  32. package/libraries/chez/monadic/seq0.ss +76 -0
  33. package/libraries/js/effekt.effekt +284 -0
  34. package/libraries/js/effekt_builtins.js +26 -0
  35. package/libraries/js/effekt_matching.js +79 -0
  36. package/libraries/js/effekt_runtime.js +385 -0
  37. package/libraries/js/immutable/dequeue.effekt +78 -0
  38. package/libraries/js/immutable/list.effekt +643 -0
  39. package/libraries/js/immutable/option.effekt +49 -0
  40. package/libraries/js/immutable/result.effekt +29 -0
  41. package/libraries/js/io/args.effekt +9 -0
  42. package/libraries/js/io/async.effekt +28 -0
  43. package/libraries/js/io/async.js +2 -0
  44. package/libraries/js/io/file.effekt +50 -0
  45. package/libraries/js/io/file_include.js +13 -0
  46. package/libraries/js/mutable/array.effekt +98 -0
  47. package/libraries/js/mutable/heap.effekt +32 -0
  48. package/libraries/js/mutable/map.effekt +32 -0
  49. package/libraries/js/test.effekt +59 -0
  50. package/libraries/js/text/regex.effekt +34 -0
  51. package/libraries/js/text/string.effekt +64 -0
  52. package/libraries/js/unsafe/cont.effekt +11 -0
  53. package/libraries/js/web/dom.effekt +45 -0
  54. package/libraries/llvm/buffer.c +181 -0
  55. package/libraries/llvm/effekt.effekt +243 -0
  56. package/libraries/llvm/forward-declare-c.ll +24 -0
  57. package/libraries/llvm/hole.c +11 -0
  58. package/libraries/llvm/immutable/list.effekt +678 -0
  59. package/libraries/llvm/immutable/option.effekt +53 -0
  60. package/libraries/llvm/immutable/result.effekt +29 -0
  61. package/libraries/llvm/io/args.effekt +24 -0
  62. package/libraries/llvm/io.c +24 -0
  63. package/libraries/llvm/main.c +39 -0
  64. package/libraries/llvm/rts.ll +619 -0
  65. package/libraries/llvm/sanity.c +16 -0
  66. package/libraries/llvm/text/string.effekt +179 -0
  67. package/libraries/llvm/types.c +20 -0
  68. package/libraries/ml/effekt.effekt +267 -0
  69. package/libraries/ml/effekt.sml +63 -0
  70. package/libraries/ml/immutable/dequeue.effekt +81 -0
  71. package/libraries/ml/immutable/list.effekt +674 -0
  72. package/libraries/ml/immutable/option.effekt +53 -0
  73. package/libraries/ml/immutable/result.effekt +29 -0
  74. package/libraries/ml/immutable/seq.effekt +903 -0
  75. package/libraries/ml/internal/option.effekt +18 -0
  76. package/libraries/ml/io/args.effekt +41 -0
  77. package/libraries/ml/mutable/array.effekt +43 -0
  78. package/libraries/ml/random.effekt +85 -0
  79. package/libraries/ml/test.effekt +60 -0
  80. package/libraries/ml/text/regex.effekt +107 -0
  81. package/libraries/ml/text/string.effekt +81 -0
  82. package/licenses/THIRD-PARTY.txt +21 -0
  83. package/licenses/apache-2.0 - license-2.0.txt +202 -0
  84. package/licenses/eclipse public license, version 2.0 - epl-2.0.html +61 -0
  85. package/licenses/kiama-license.txt +373 -0
  86. package/licenses/kiama-readme.txt +186 -0
  87. package/licenses/mit license - mit-license.html +769 -0
  88. package/licenses/the apache software license, version 2.0 - license-2.0.txt +202 -0
  89. package/licenses/the bsd license - bsd-license.html +762 -0
  90. package/licenses/the mit license - mit.html +769 -0
  91. package/package.json +26 -18
@@ -0,0 +1,186 @@
1
+
2
+ # Kiama
3
+
4
+ > This is a fork of the Kiama library. An excerpt of the original README is attached below.
5
+ >
6
+ > For more information, please refer to the original repository:
7
+ > <https://github.com/inkytonik/kiama>
8
+
9
+ ---
10
+
11
+ [![License: MPL v2.0](https://img.shields.io/badge/License-MPL%20v2-blue.svg)](http://mozilla.org/MPL/2.0/)
12
+
13
+ Kiama is a Scala library for language processing.
14
+ In the Kiama project we are investigating embedding of language processing formalisms such as grammars, parsers, rewriters and analysers into general-purpose programming languages.
15
+ Learn about Kiama by reading our [research papers](https://inkytonik.github.io/kiama/Research) starting with [Lightweight Language Processing in Kiama](https://doi.org/10.1007/978-3-642-18023-1_12).
16
+
17
+ IMPORTANT NOTE: Kiama is a research project, so many details will change. Consult with us before you rely on it for serious work. We make no guarantees about the features or performance of the Kiama library if you do choose to use it.
18
+
19
+ ## Contact
20
+
21
+ Tony Sloane
22
+
23
+ inkytonik@gmail.com
24
+
25
+ https://github.com/inkytonik
26
+
27
+ ## Documentation
28
+
29
+ Documentation about how to build, install and use Kiama can be found on the [Kiama docs pages](https://inkytonik.github.io/kiama).
30
+
31
+ The main documentation for Kiama takes the form of pages covering library features and examples. The [User Manual](https://inkytonik.github.io/kiama/UserManual) is a good place to start.
32
+
33
+ See the [Research page](https://inkytonik.github.io/kiama/Research) for links to papers and presentations about Kiama.
34
+
35
+ For summary information about Kiama releases, including dependencies on other software and links to API documentation, see the [Releases page](https://inkytonik.github.io/kiama/Releases).
36
+
37
+ See the [Installation page](https://inkytonik.github.io/kiama/Installation) for instructions on how to install Kiama.
38
+
39
+ ## Licensing
40
+
41
+ Kiama is distributed under the Mozilla Public License, v. 2.0. See the file LICENSE for details of the license. More information can be obtained from [Mozilla](http://mozilla.org/MPL/2.0/).
42
+
43
+ ## Some Examples
44
+
45
+ A traditional approach to language processing is to represent the data to be processed as a hierarchical structure (a tree). Kiama provides different ways to operate on such trees to carry out typical language processing tasks.
46
+
47
+ * [Context-sensitive attribute equations](https://inkytonik.github.io/kiama/Attribution)
48
+
49
+ Attribute equations define properties of tree nodes in terms of constants or the properties of other nodes. In this example, the local and global minima of a binary tree (`locmin` and `globmin`) are defined using simple local equations. Accessing an attribute (property) of a node is just a function call (also accessible via the arrow notation in Kiama 1.x). The `attr` function provides caching and circularity checking to the equations.
50
+
51
+ Kiama version 1.x:
52
+
53
+ val locmin : Tree ==> Int =
54
+ attr {
55
+ case Fork(l, r) => (l->locmin) min (r->locmin)
56
+ case Leaf(v) => v
57
+ }
58
+
59
+ val globmin : Tree ==> Int =
60
+ attr {
61
+ case t if t isRoot => t->locmin
62
+ case t => t.parent[Tree]->globmin
63
+ }
64
+
65
+ Kiama version 2.x:
66
+
67
+ val locmin : RepminTree => Int =
68
+ attr {
69
+ case Fork(l, r) => locmin(l).min(locmin(r))
70
+ case Leaf(v) => v
71
+ }
72
+
73
+ val globmin : RepminTree => Int =
74
+ attr {
75
+ case tree.parent(p) => globmin(p)
76
+ case t => locmin(t)
77
+ }
78
+
79
+ * [Dataflow Circular attribute equations](https://inkytonik.github.io/kiama/Dataflow)
80
+
81
+ Sometimes it is useful to define attributes using a mutual dependency. With `attr` this approach would lead to an error since it would not be possible to calculate the values of such attributes. The `circular` function goes further by implementing mutually dependent attributes via an iteration to a fixed point. In this example, we are calculating variable liveness information for a imperative language statements using the standard data flow equations.
82
+
83
+ Kiama 1.x:
84
+
85
+ val in : Stm ==> Set[Var] =
86
+ circular(Set[Var]()) {
87
+ case s => uses(s) ++ (out(s) -- defines(s))
88
+ }
89
+
90
+ val out : Stm ==> Set[Var] =
91
+ circular(Set[Var]()) {
92
+ case s => (s->succ) flatMap (in)
93
+ }
94
+
95
+ Kiama 2.x:
96
+
97
+ val in : Stm => Set[Var] =
98
+ circular(Set[Var]())(
99
+ s => uses(s) ++ (out(s) -- defines(s))
100
+ )
101
+
102
+ val out : Stm => Set[Var] =
103
+ circular(Set[Var]())(
104
+ s => succ(s) flatMap (in)
105
+ )
106
+
107
+ * [Rewrite rules and higher-order rewriting strategies](https://inkytonik.github.io/kiama/Lambda2)
108
+
109
+ While attributes provide a way to decorate a tree with information, rewriting is concerned with transforming trees, perhaps for translation or for optimisation. Kiama contains a strategy-based rewriting library heavily inspired by the [http://strategoxt.org/ Stratego] program transformation language. In this example, we are implementing an evaluation strategy for lambda calculus, using generic strategies such as innermost rewriting.
110
+
111
+ Kiama 1.x:
112
+
113
+ val beta =
114
+ rule {
115
+ case App(Lam(x, t, e1), e2) => Let(x, t, e2, e1)
116
+ }
117
+
118
+ Kiama 2.x:
119
+
120
+ val beta =
121
+ rule[Exp] {
122
+ case App(Lam(x, t, e1), e2) => substitute(x, e2, e1)
123
+ }
124
+
125
+ Kiama 1.x and 2.x:
126
+
127
+ val lambda =
128
+ beta + arithop + subsNum + subsVar + subsApp + subsLam + subsOpn
129
+
130
+ def innermost (s : => Strategy) : Strategy =
131
+ all(innermost(s) <* attempt(s <* innermost(s)))
132
+
133
+ val s : Strategy =
134
+ innermost(lambda)
135
+
136
+ * [Pretty-printing](https://inkytonik.github.io/kiama/PrettyPrinting)
137
+
138
+ Kiama's pretty-printing library provides a flexible way to describe how you want your output to be produced within constraint of line length. For example, the following describes how to pretty-print the constructs of a simple imperative language, where `group`, `nest` and `line` cooperate to produce nicely indented code that breaks lines at sensible place when needed.
139
+
140
+ Kiama 1.x and 2.x:
141
+
142
+ def toDoc(t : ImperativeNode) : Doc =
143
+ t match {
144
+ case Num(d) => value(d)
145
+ case Var(s) => s
146
+ case Neg(e) => parens("-" <> toDoc(e))
147
+ case Add(l, r) => binToDoc(l, "+", r)
148
+ case Sub(l, r) => binToDoc(l, "-", r)
149
+ case Mul(l, r) => binToDoc(l, "*", r)
150
+ case Div(l, r) => binToDoc(l, "/", r)
151
+ case Null() => semi
152
+ case Seqn(ss) => group(braces (nest (line <> ssep (ss map toDoc, line)) <> line))
153
+ case Asgn(v, e) => toDoc(v) <+> "=" <+> toDoc(e) <> semi
154
+ case While(e, b) => "while" <+> parens(toDoc(e)) <> group(nest(line <> toDoc(b)))
155
+ }
156
+
157
+ def binToDoc(l : ImperativeNode, op : String, r : Im****perativeNode) : Doc =
158
+ parens(toDoc(l) <+> op <+> toDoc (r))
159
+
160
+ ## Mailing lists
161
+
162
+ * kiama (General announcements and discussions)
163
+
164
+ * `http://groups.google.com/group/kiama`
165
+ * `kiama@googlegroups.com`
166
+
167
+ ## Acknowledgements
168
+
169
+ The main Kiama Project team is:
170
+
171
+ * Tony Sloane
172
+ * Matthew Roberts
173
+ * Dominic Verity
174
+
175
+ Other contributors have been:
176
+
177
+ * Len Hamey
178
+ * Lennart Kats and Eelco Visser (some aspects of attribution)
179
+ * Ben Mockler (the first version of the Oberon-0 example)
180
+
181
+ Kiama is currently concentrating on incorporating existing language processing
182
+ formalisms, so credit goes to the original developers of those formalisms. See
183
+ the code for details of the sources of ideas that come from elsewhere.
184
+
185
+ Many of the library rewriting strategies are based on the Stratego library.
186
+ See http://releases.strategoxt.org/docs/api/libstratego-lib/stable/docs/.