~repos /plum
git clone https://pyrossh.dev/repos/plum.git
A statically typed, imperative programming language inspired by rust, python
afb772e8
—
pyrossh 1 year ago
improve syntax
- libs/std/bool.plum +6 -3
- libs/std/float.plum +47 -0
- libs/std/http.plum +5 -4
- libs/std/int.plum +11 -56
- libs/std/list.plum +113 -164
- libs/std/map.plum +1 -1
- libs/std/os.mi +0 -48
- libs/std/os.plum +100 -0
- tooling/tree-sitter-plum/readme.md +6 -6
- tooling/vscode-plum/.vscodeignore +0 -4
- tooling/vscode-plum/CHANGELOG.md +0 -9
- tooling/vscode-plum/readme.md +0 -69
- tooling/vscode-plum/syntaxes/plum.tmLanguage.json +1 -1
- tooling/vscode-plum/vsc-extension-quickstart.md +0 -29
libs/std/bool.plum
CHANGED
|
@@ -6,17 +6,20 @@ Bool =
|
|
|
6
6
|
|
|
7
7
|
# Might not be needed
|
|
8
8
|
Bool\toStr() -> Str =
|
|
9
|
+
if this == True
|
|
9
|
-
|
|
10
|
+
"True"
|
|
11
|
+
else
|
|
12
|
+
"False"
|
|
10
13
|
|
|
11
14
|
Bool\and(other: Bool) -> Bool =
|
|
12
|
-
match
|
|
15
|
+
match this, other is
|
|
13
16
|
True, True => True
|
|
14
17
|
True, False => False
|
|
15
18
|
False, True => False
|
|
16
19
|
False, False => False
|
|
17
20
|
|
|
18
21
|
Bool\or(other: Bool) -> Bool =
|
|
19
|
-
match
|
|
22
|
+
match this, other is
|
|
20
23
|
True, True => True
|
|
21
24
|
True, False => True
|
|
22
25
|
False, True => True
|
libs/std/float.plum
CHANGED
|
@@ -1,3 +1,50 @@
|
|
|
1
|
+
module std/float
|
|
2
|
+
|
|
3
|
+
# Euler's number, the base of natural logarithms, e, https://oeis.org/A001113
|
|
4
|
+
E = 2.718f
|
|
5
|
+
|
|
6
|
+
# The natural logarithm of 10, https://oeis.org/A002392
|
|
7
|
+
LN10 = 2.302f
|
|
8
|
+
|
|
9
|
+
# The natural logarithm of 2 https://oeis.org/A002162
|
|
10
|
+
LN2 = 0.693f
|
|
11
|
+
|
|
12
|
+
# The base 10 logarithm of e # formula: 1 / LN10
|
|
13
|
+
LOG10E = 0.434f
|
|
14
|
+
|
|
15
|
+
# The base 2 logarithm of e # formula: 1 / LN2
|
|
16
|
+
LOG2E = 1.442f
|
|
17
|
+
|
|
18
|
+
# The ratio of the circumference of a circle to its diameter https://oeis.org/A000796
|
|
19
|
+
PI = 3.14159f
|
|
20
|
+
|
|
21
|
+
# https://oeis.org/A001622
|
|
22
|
+
PHI = 1.6180f
|
|
23
|
+
|
|
24
|
+
# The square root of 1/2
|
|
25
|
+
SQRT1_2 = 0.707f
|
|
26
|
+
|
|
27
|
+
# The square root of 2 https://oeis.org/A002193
|
|
28
|
+
SQRT2 = 1.414f
|
|
29
|
+
|
|
30
|
+
# https://oeis.org/A019774
|
|
31
|
+
SQRT_E = 1.64872f
|
|
32
|
+
|
|
33
|
+
# https://oeis.org/A002161
|
|
34
|
+
SQRT_PI = 1.77245f
|
|
35
|
+
|
|
36
|
+
# https://oeis.org/A139339
|
|
37
|
+
SQRT_PHI = 1.27201f
|
|
38
|
+
|
|
39
|
+
# The difference between 1 and the smallest floating point number greater than 1 formula: 7/3 - 4/3 - 1
|
|
40
|
+
EPSILON = 2.220446049250313e-16f
|
|
41
|
+
|
|
42
|
+
# Lowest value of float
|
|
43
|
+
MIN_FLOAT_VALUE = 4.9406564584124654417656879286822137236505980e-324
|
|
44
|
+
|
|
45
|
+
# Highest value of float
|
|
46
|
+
MAX_FLOAT_VALUE = 1.79769313486231570814527423731704356798070e+308
|
|
47
|
+
|
|
1
48
|
Float::PI=3.14
|
|
2
49
|
|
|
3
50
|
fn acosh(v: float): float =
|
libs/std/http.plum
CHANGED
|
@@ -5,20 +5,21 @@ import std/os
|
|
|
5
5
|
import std/http/content_type
|
|
6
6
|
|
|
7
7
|
Response = (
|
|
8
|
-
headers: Map
|
|
8
|
+
headers: Map(Str, Str)
|
|
9
9
|
body: Str | Buffer | IO
|
|
10
10
|
status: Int
|
|
11
11
|
)
|
|
12
12
|
|
|
13
13
|
createFileResponse(path: Str) -> Response | IOError =
|
|
14
|
-
content
|
|
14
|
+
content = content_type.fromExt(path.ext())
|
|
15
|
-
data
|
|
15
|
+
data = os.readFile(file)?
|
|
16
16
|
Response()
|
|
17
17
|
.header("Content-Type", content)
|
|
18
|
+
.contentType(.ApplicationJS)
|
|
18
19
|
.body(data)
|
|
19
20
|
.status(200)
|
|
20
21
|
|
|
21
|
-
index() -> Response
|
|
22
|
+
index() -> Response | IOError =
|
|
22
23
|
createFileResponse("index.html")
|
|
23
24
|
|
|
24
25
|
serveFile(file: Str) -> Response | IOError =
|
libs/std/int.plum
CHANGED
|
@@ -1,67 +1,22 @@
|
|
|
1
1
|
module std/int
|
|
2
2
|
|
|
3
|
-
# Euler's number, the base of natural logarithms, e, https://oeis.org/A001113
|
|
4
|
-
E = 2.718f
|
|
5
|
-
|
|
6
|
-
# The natural logarithm of 10, https://oeis.org/A002392
|
|
7
|
-
LN10 = 2.302f
|
|
8
|
-
|
|
9
|
-
# The natural logarithm of 2 https://oeis.org/A002162
|
|
10
|
-
LN2 = 0.693f
|
|
11
|
-
|
|
12
|
-
# The base 10 logarithm of e # formula: 1 / LN10
|
|
13
|
-
LOG10E = 0.434f
|
|
14
|
-
|
|
15
|
-
# The base 2 logarithm of e # formula: 1 / LN2
|
|
16
|
-
LOG2E = 1.442f
|
|
17
|
-
|
|
18
|
-
# The ratio of the circumference of a circle to its diameter https://oeis.org/A000796
|
|
19
|
-
PI = 3.14159f
|
|
20
|
-
|
|
21
|
-
# https://oeis.org/A001622
|
|
22
|
-
PHI = 1.6180f
|
|
23
|
-
|
|
24
|
-
|
|
3
|
+
Int: Comparable, ToStr = ByteArray
|
|
25
|
-
SQRT1_2 = 0.707f
|
|
26
|
-
|
|
27
|
-
# The square root of 2 https://oeis.org/A002193
|
|
28
|
-
SQRT2 = 1.414f
|
|
29
|
-
|
|
30
|
-
# https://oeis.org/A019774
|
|
31
|
-
SQRT_E = 1.64872f
|
|
32
|
-
|
|
33
|
-
# https://oeis.org/A002161
|
|
34
|
-
SQRT_PI = 1.77245f
|
|
35
|
-
|
|
36
|
-
# https://oeis.org/A139339
|
|
37
|
-
SQRT_PHI = 1.27201f
|
|
38
|
-
|
|
39
|
-
# The difference between 1 and the smallest floating point number greater than 1 formula: 7/3 - 4/3 - 1
|
|
40
|
-
EPSILON = 2.220446049250313e-16f
|
|
41
|
-
|
|
42
|
-
# Lowest value of int
|
|
43
|
-
MIN_INT_VALUE = -0x8000_0000_0000_0000
|
|
44
|
-
|
|
45
|
-
# Highest value of int
|
|
46
|
-
MAX_INT_VALUE = 0x7FFF_FFFF_FFFF_FFFF
|
|
47
4
|
|
|
48
|
-
# Lowest
|
|
5
|
+
# Lowest value of Int
|
|
49
|
-
|
|
6
|
+
Int::MIN_VALUE = -0x8000_0000_0000_0000
|
|
50
7
|
|
|
51
|
-
# Highest
|
|
8
|
+
# Highest value of Int
|
|
52
|
-
|
|
9
|
+
Int::MAX_VALUE = 0x7FFF_FFFF_FFFF_FFFF
|
|
53
10
|
|
|
54
11
|
# 2**28
|
|
55
|
-
LARGE = 1 << 28
|
|
12
|
+
Int::LARGE = 1 << 28
|
|
56
|
-
|
|
57
|
-
Int: Comparable, ToStr = ByteArray
|
|
58
13
|
|
|
59
14
|
Int::random(): Float =
|
|
60
|
-
|
|
15
|
+
todo
|
|
61
16
|
|
|
62
17
|
# returns the absolute value of the Int
|
|
63
18
|
Int\abs() -> Int =
|
|
64
|
-
|
|
19
|
+
this < 0 ? -this : this
|
|
65
20
|
|
|
66
21
|
Int\ceil() -> Float =
|
|
67
22
|
todo
|
|
@@ -88,16 +43,16 @@ Int\logb() -> Float =
|
|
|
88
43
|
todo
|
|
89
44
|
|
|
90
45
|
Int\pow(y: Float) -> Float =
|
|
91
|
-
|
|
46
|
+
LibM.pow(this, y)
|
|
92
47
|
|
|
93
48
|
Int\pow(y: Int) -> Float =
|
|
94
|
-
|
|
49
|
+
pow(y.toFloat())
|
|
95
50
|
|
|
96
51
|
Int\sqrt() -> Float =
|
|
97
52
|
if this < 0.0 then
|
|
98
53
|
_nan()
|
|
99
54
|
else
|
|
100
|
-
LibM.sqrt(
|
|
55
|
+
LibM.sqrt(this)
|
|
101
56
|
end
|
|
102
57
|
|
|
103
58
|
Int\asin(v: Float) =
|
libs/std/list.plum
CHANGED
|
@@ -1,227 +1,176 @@
|
|
|
1
1
|
module std
|
|
2
2
|
|
|
3
|
-
record List[V](
|
|
4
|
-
`A list is a data structure describing a contiguous section of an array stored separately from the slice variable itself.
|
|
5
|
-
|
|
3
|
+
# A node stores the data in a list and contains pointers to the previous and next sibling nodes
|
|
6
|
-
|
|
4
|
+
Node = {
|
|
7
|
-
tail: node[V]?
|
|
8
|
-
|
|
5
|
+
value: V
|
|
9
|
-
)
|
|
6
|
+
prev: Node(a) | Nil
|
|
10
|
-
|
|
7
|
+
next: Node(a) | Nil
|
|
11
|
-
}
|
|
12
8
|
}
|
|
13
9
|
|
|
14
|
-
|
|
10
|
+
# A list is a data structure describing a contiguous section of an array stored separately from the slice variable itself.
|
|
15
|
-
|
|
11
|
+
# It contains the pointers to the start and end nodes (head, tail) and maintains the size as well
|
|
16
|
-
|
|
12
|
+
List = {
|
|
17
|
-
prev: node[V]?
|
|
18
|
-
|
|
13
|
+
head: Node(a) | Nil
|
|
14
|
+
tail: Node(a) | Nil
|
|
15
|
+
size: Int
|
|
19
|
-
|
|
16
|
+
}
|
|
20
17
|
|
|
21
|
-
|
|
18
|
+
List(values: ...a) -> List(a) =
|
|
22
|
-
|
|
19
|
+
List().add(values)
|
|
23
20
|
|
|
24
|
-
fn (List) get(i: int) -> A =
|
|
25
|
-
|
|
21
|
+
# gets the element at i'th index of the list
|
|
22
|
+
List\get(i: Int) -> a =
|
|
26
|
-
current
|
|
23
|
+
current = l.head
|
|
27
|
-
index
|
|
24
|
+
index = 0
|
|
28
|
-
while current !=
|
|
25
|
+
while current != Nil
|
|
29
26
|
if index == i
|
|
30
27
|
current.value
|
|
31
28
|
else
|
|
32
29
|
current = current.next
|
|
33
30
|
index += 1
|
|
34
31
|
|
|
35
|
-
fn (List) set(i: int, v: V) -> A =
|
|
36
|
-
|
|
32
|
+
# sets the element at i'th index of the list
|
|
33
|
+
List\set(i: Int, v: a) -> a =
|
|
37
|
-
|
|
34
|
+
todo
|
|
38
35
|
|
|
39
|
-
fn (List) length() -> A =
|
|
40
|
-
|
|
36
|
+
# returns the no of elements in the list
|
|
37
|
+
List\length() -> a =
|
|
41
|
-
|
|
38
|
+
self.size
|
|
42
39
|
|
|
43
|
-
fn (List) add(values: ...V) =
|
|
44
|
-
|
|
40
|
+
# adds the specified elements to the start of the list
|
|
41
|
+
List\add(values: ...V) =
|
|
45
|
-
for v
|
|
42
|
+
for v in values
|
|
46
|
-
l.head =
|
|
43
|
+
l.head = Node(value: v, prev: Nil, next: l.head)
|
|
47
44
|
l.head.next.prev = l.head
|
|
48
|
-
l.
|
|
45
|
+
l.size += 1
|
|
49
46
|
|
|
50
|
-
fn (List) removeAt(i int) =
|
|
51
|
-
|
|
47
|
+
# removes the element at i'th index of the list
|
|
48
|
+
List\removeAt(i: Int) =
|
|
52
|
-
l.tail?.prev?.next =
|
|
49
|
+
l.tail?.prev?.next = Nil
|
|
53
|
-
|
|
50
|
+
# old tail node gets deallocated due to zero reference count
|
|
54
51
|
l.tail = list.tail?.prev
|
|
55
|
-
l.
|
|
52
|
+
l.size -= 1
|
|
56
53
|
|
|
57
|
-
fn (List) remove(v V) =
|
|
58
|
-
|
|
54
|
+
# removes the element v from list
|
|
55
|
+
List\remove(v: a) =
|
|
59
|
-
l.tail?.prev?.next =
|
|
56
|
+
l.tail?.prev?.next = Nil
|
|
60
|
-
|
|
57
|
+
# old tail node gets deallocated due to zero reference count
|
|
61
58
|
l.tail = list.tail?.prev
|
|
62
|
-
l.
|
|
59
|
+
l.size -= 1
|
|
63
60
|
|
|
64
|
-
fn (List) clear() =
|
|
65
|
-
|
|
61
|
+
# removes all objects from this list
|
|
62
|
+
List\clear() =
|
|
66
|
-
l.tail?.prev?.next =
|
|
63
|
+
l.tail?.prev?.next = Nil
|
|
67
64
|
`old tail node gets deallocated due to zero reference count
|
|
68
65
|
l.tail = list.tail?.prev
|
|
69
|
-
l.
|
|
66
|
+
l.size -= 1
|
|
70
|
-
|
|
71
67
|
|
|
72
|
-
fn (List) reverse(v: fn(v: V): true): list[A] =
|
|
73
|
-
`returns a new list with the elements in reverse order.
|
|
74
|
-
pass
|
|
75
68
|
|
|
76
|
-
fn (List) sort(sorter: fn(v: V): true): list[A] =
|
|
77
|
-
|
|
69
|
+
# returns a new list with the elements in reverse order.
|
|
70
|
+
List\reverse(v: fn(v: a) -> Bool) -> List[A] =
|
|
78
|
-
|
|
71
|
+
todo
|
|
79
72
|
|
|
80
|
-
fn (List) find(search: V): V?, int =
|
|
81
|
-
|
|
73
|
+
# returns a new list with the elements sorted by sorter
|
|
74
|
+
List\sort(sorter: fn(v: a) -> Bool) -> List(A) =
|
|
82
|
-
|
|
75
|
+
todo
|
|
83
76
|
|
|
84
|
-
fn (List) contains(v: V): bool =
|
|
85
|
-
|
|
77
|
+
# returns an item and index in the list if the item is is equal to search item
|
|
86
|
-
pass
|
|
87
|
-
|
|
88
|
-
fn (l: list[T]) op_range(yld: fn(v: T): bool): bool =
|
|
89
|
-
|
|
78
|
+
List\find(search: V): V | Nil =
|
|
90
|
-
current := l.head
|
|
91
|
-
while current != nil
|
|
92
|
-
if !yld(current.value)
|
|
93
|
-
return false
|
|
94
|
-
current = current.next
|
|
95
|
-
|
|
79
|
+
todo
|
|
96
80
|
|
|
97
|
-
fn (List) op_spread(other: list): list[A] =
|
|
98
|
-
|
|
81
|
+
# returns the index of an item in the list if present and comparable otherwise Nil
|
|
82
|
+
List\contains(v: a) -> Bool =
|
|
99
|
-
|
|
83
|
+
todo
|
|
100
84
|
|
|
101
|
-
fn (List) each(cb: fn(v: V)): void =
|
|
102
|
-
|
|
85
|
+
# calls f for each elem in the list
|
|
86
|
+
List\each(cb: fn(v: a)) -> Unit =
|
|
103
87
|
current := l.head
|
|
104
|
-
while current !=
|
|
88
|
+
while current != Nil
|
|
105
89
|
cb(current.value)
|
|
106
90
|
current = current.next
|
|
107
91
|
|
|
108
|
-
fn (List) map[B](cb: fn(v: V): B): list[A] =
|
|
109
|
-
|
|
92
|
+
# returns a list made up of B elements for each elem in the list
|
|
93
|
+
List\map(cb: fn(v: a) -> b) -> List(b) =
|
|
110
94
|
nl := []
|
|
111
95
|
current := l.head
|
|
112
|
-
while current !=
|
|
96
|
+
while current != Nil
|
|
113
97
|
item := cb(current.value)
|
|
114
98
|
nl.push(item)
|
|
115
99
|
nl
|
|
116
100
|
|
|
117
|
-
fn (List) flatMap() =
|
|
118
|
-
|
|
101
|
+
# returns a new list with all elements shuffled`
|
|
102
|
+
List\flatMap() =
|
|
119
|
-
|
|
103
|
+
todo
|
|
120
104
|
|
|
121
|
-
fn (List) retain(predicate: fn(v: V): A): list[A] =
|
|
122
|
-
|
|
105
|
+
# returns a new list with the elements that matched the predicate
|
|
106
|
+
List\retain(predicate: fn(v: a) -> A) -> List(A) =
|
|
123
|
-
|
|
107
|
+
todo
|
|
124
108
|
|
|
125
|
-
fn (List) reject(predicate: fn(v: V): A): list[A] =
|
|
126
|
-
|
|
109
|
+
# returns a new list with the elements that matched the predicate removed
|
|
110
|
+
List\reject(predicate: fn(v: a) -> A) -> List(A) =
|
|
127
|
-
|
|
111
|
+
todo
|
|
128
112
|
|
|
129
|
-
fn (List) any(predicate: fn(v: V): bool): bool =
|
|
130
|
-
|
|
113
|
+
# returns true if any element in the list satisfies the predicate
|
|
114
|
+
List\any(predicate: fn(v: a) -> Bool) -> Bool =
|
|
131
|
-
|
|
115
|
+
todo
|
|
132
116
|
|
|
133
|
-
fn (List) every(predicate: fn(v: V): bool): bool =
|
|
134
|
-
|
|
117
|
+
# returns true if all of the elements in the list satisfies the predicate
|
|
118
|
+
List\every(predicate: fn(v: a) -> Bool) -> Bool =
|
|
135
|
-
|
|
119
|
+
todo
|
|
136
120
|
|
|
137
|
-
fn (List) reduce[B](acc: B, cb: fn(v: V): A): B =
|
|
138
|
-
|
|
121
|
+
# returns the accumulated value of all the elements in the list
|
|
122
|
+
List\reduce[B](acc: B, cb: fn(v: a) -> A): B =
|
|
139
|
-
|
|
123
|
+
todo
|
|
140
124
|
|
|
141
|
-
fn (List) first(): A? =
|
|
142
|
-
|
|
125
|
+
# returns the first element in the list
|
|
126
|
+
List\first() -> a | Nil =
|
|
143
127
|
l.head?.value
|
|
144
128
|
|
|
145
|
-
fn (List) last(): A? =
|
|
146
|
-
|
|
129
|
+
# returns the last element in the list
|
|
130
|
+
List\last() -> a | Nil =
|
|
147
131
|
l.tail?.value
|
|
148
132
|
|
|
149
|
-
fn (List) sublist(start: int, end: int): list[A] =
|
|
150
|
-
|
|
133
|
+
# returns a list containing the first n elements of the given list
|
|
134
|
+
List\sublist(start: int, end: int) -> List(A) =
|
|
151
|
-
|
|
135
|
+
todo
|
|
152
136
|
|
|
153
|
-
fn (List) take(n: int): list[A] =
|
|
154
|
-
|
|
137
|
+
# returns a list containing the first n elements of the given list
|
|
138
|
+
List\take(n: int) -> List(A) =
|
|
155
|
-
|
|
139
|
+
todo
|
|
156
140
|
|
|
157
|
-
fn (List) skip(n: int): list[A] =
|
|
158
|
-
|
|
141
|
+
# returns a list containing the first n elements of the given list
|
|
142
|
+
List\skip(n: int) -> List(A) =
|
|
159
|
-
|
|
143
|
+
todo
|
|
160
144
|
|
|
161
|
-
fn (List) drop(n: int): list[A] =
|
|
162
|
-
|
|
145
|
+
`Returns a list containing the first n elements of the given list
|
|
146
|
+
List\drop(n: int) -> List(A) =
|
|
147
|
+
todo
|
|
163
148
|
|
|
164
|
-
fn (List) sample() =
|
|
165
|
-
|
|
149
|
+
# returns a new list with some of the elements taken randomly`
|
|
150
|
+
List\sample() =
|
|
166
|
-
|
|
151
|
+
todo
|
|
167
152
|
|
|
168
|
-
fn (List) shuffle() =
|
|
169
|
-
|
|
153
|
+
# returns a new list with all elements shuffled`
|
|
154
|
+
List\shuffle() =
|
|
170
|
-
|
|
155
|
+
todo
|
|
171
156
|
|
|
172
|
-
fn (List) partition() =
|
|
173
|
-
|
|
157
|
+
# returns a new list with all elements shuffled`
|
|
158
|
+
List\partition() =
|
|
174
|
-
|
|
159
|
+
todo
|
|
175
160
|
|
|
176
|
-
fn (List) chunk() =
|
|
177
|
-
|
|
161
|
+
# returns a new list with all elements shuffled`
|
|
162
|
+
List\chunk() =
|
|
178
|
-
|
|
163
|
+
todo
|
|
179
164
|
|
|
180
|
-
fn (List) groupBy() =
|
|
181
|
-
|
|
165
|
+
# returns a new list with all elements grouped`
|
|
166
|
+
List\groupBy() =
|
|
182
|
-
|
|
167
|
+
todo
|
|
183
168
|
|
|
184
|
-
|
|
169
|
+
List\join(sep: Str = ",") -> Str =
|
|
185
170
|
res := Buffer()
|
|
186
171
|
l.each() |v|
|
|
187
172
|
if @HasTrait(V, ToStr)
|
|
188
173
|
res.write(v.to_str(), sep)
|
|
189
174
|
else
|
|
190
175
|
res.write(@TypeToString(v), sep)
|
|
191
|
-
res.to_str()
|
|
176
|
+
res.to_str()
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
trait List[T] permits Empty, Link {
|
|
195
|
-
fn each(cb: fn(v: T))
|
|
196
|
-
fn length() -> Int
|
|
197
|
-
fn append(v: V) -> List[T]
|
|
198
|
-
fn prepend(v: V) -> List[T]
|
|
199
|
-
fn append(values: ...V) -> List[T]
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
fn listOf(values: ...T) -> List[T] {
|
|
203
|
-
return Link[T].append(values)
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
tuple Empty(): List[_] {
|
|
207
|
-
fn each(cb: fn(v: T)) {}
|
|
208
|
-
fn append(v: V) -> List[T] {
|
|
209
|
-
return Link(v, Empty)
|
|
210
|
-
}
|
|
211
|
-
fn prepend(v: V) -> List[T] {
|
|
212
|
-
return Link(v, Empty)
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
tuple Link[T](T, List[T]): List[T] {
|
|
217
|
-
fn each(cb: fn(v: T)) {
|
|
218
|
-
cb(a)
|
|
219
|
-
self.1.each(cb)
|
|
220
|
-
}
|
|
221
|
-
fn append(v: V) {
|
|
222
|
-
self.last().rest = Link(v, Empty)
|
|
223
|
-
}
|
|
224
|
-
fn prepend(v: V) {
|
|
225
|
-
self.first() = Link(v, self.1)
|
|
226
|
-
}
|
|
227
|
-
}
|
libs/std/map.plum
CHANGED
|
@@ -22,7 +22,7 @@ Map\add(kvs: ...Pair) =
|
|
|
22
22
|
|
|
23
23
|
# Get a value from the Map using key k
|
|
24
24
|
Map\get(k: a) -> b | Nil =
|
|
25
|
-
for k, v in
|
|
25
|
+
for k, v in items do
|
|
26
26
|
if k == k
|
|
27
27
|
return v
|
|
28
28
|
Nil
|
libs/std/os.mi
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
module std
|
|
2
|
-
|
|
3
|
-
fn printLn(): IOError =
|
|
4
|
-
`Writes the specified data, followed by the current line terminator, to the standard output stream.
|
|
5
|
-
pass
|
|
6
|
-
|
|
7
|
-
fn readFile(path: str): IO =
|
|
8
|
-
`Returns a stream to a file from the fs
|
|
9
|
-
pass
|
|
10
|
-
|
|
11
|
-
fn writeFile(path: str, data: IO)
|
|
12
|
-
pass
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
fn access(path[, mode])
|
|
16
|
-
fn appendFile(path, data[, options])
|
|
17
|
-
fn chmod(path, mode)
|
|
18
|
-
fn chown(path, uid, gid)
|
|
19
|
-
fn copyFile(src, dest[, mode])
|
|
20
|
-
fn cp(src, dest[, options])
|
|
21
|
-
fn lchmod(path, mode)
|
|
22
|
-
fn lchown(path, uid, gid)
|
|
23
|
-
fn lutimes(path, atime, mtime)
|
|
24
|
-
fn link(existingPath, newPath)
|
|
25
|
-
fn lstat(path[, options])
|
|
26
|
-
fn mkdir(path[, options])
|
|
27
|
-
fn mkdtemp(prefix[, options])
|
|
28
|
-
fn open(path, flags[, mode])
|
|
29
|
-
fn opendir(path[, options])
|
|
30
|
-
fn readdir(path[, options])
|
|
31
|
-
fn readFile(path[, options])
|
|
32
|
-
fn readlink(path[, options])
|
|
33
|
-
fn realpath(path[, options])
|
|
34
|
-
fn rename(oldPath, newPath)
|
|
35
|
-
fn rmdir(path[, options])
|
|
36
|
-
fn rm(path[, options])
|
|
37
|
-
fn stat(path[, options])
|
|
38
|
-
fn statfs(path[, options])
|
|
39
|
-
fn symlink(target, path[, type])
|
|
40
|
-
fn truncate(path[, len])
|
|
41
|
-
fn unlink(path)
|
|
42
|
-
fn utimes(path, atime, mtime)
|
|
43
|
-
fn watch(filename[, options])
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
O_RDWR,
|
|
47
|
-
O_CREAT,
|
|
48
|
-
O_EXCL,
|
libs/std/os.plum
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
module std/os
|
|
2
|
+
|
|
3
|
+
stdin = File("/dev/stdin")
|
|
4
|
+
stdout = File("/dev/stdout")
|
|
5
|
+
stderr = File("/dev/stderr")
|
|
6
|
+
|
|
7
|
+
# Writes the specified data, followed by the current line terminator, to the standard output stream.
|
|
8
|
+
printLn(s: Str) -> IOError =
|
|
9
|
+
writeFile(stdout, s)
|
|
10
|
+
|
|
11
|
+
# Returns a stream to a file from the fs
|
|
12
|
+
readFile(path: str) -> IO =
|
|
13
|
+
todo
|
|
14
|
+
|
|
15
|
+
writeFile(path: str, data: IO)
|
|
16
|
+
todo
|
|
17
|
+
|
|
18
|
+
access(path[, mode]) =
|
|
19
|
+
todo
|
|
20
|
+
|
|
21
|
+
appendFile(path, data[, options]) =
|
|
22
|
+
todo
|
|
23
|
+
|
|
24
|
+
chmod(path, mode) =
|
|
25
|
+
todo
|
|
26
|
+
|
|
27
|
+
chown(path, uid, gid) =
|
|
28
|
+
todo
|
|
29
|
+
|
|
30
|
+
copyFile(src, dest[, mode]) =
|
|
31
|
+
todo
|
|
32
|
+
|
|
33
|
+
cp(src, dest[, options]) =
|
|
34
|
+
todo
|
|
35
|
+
|
|
36
|
+
lchmod(path, mode) =
|
|
37
|
+
todo
|
|
38
|
+
|
|
39
|
+
lchown(path, uid, gid) =
|
|
40
|
+
todo
|
|
41
|
+
|
|
42
|
+
lutimes(path, atime, mtime) =
|
|
43
|
+
todo
|
|
44
|
+
|
|
45
|
+
link(existingPath, newPath) =
|
|
46
|
+
todo
|
|
47
|
+
|
|
48
|
+
lstat(path[, options]) =
|
|
49
|
+
todo
|
|
50
|
+
|
|
51
|
+
mkdir(path[, options]) =
|
|
52
|
+
todo
|
|
53
|
+
|
|
54
|
+
mkdtemp(prefix[, options]) =
|
|
55
|
+
todo
|
|
56
|
+
|
|
57
|
+
open(path, flags[, mode]) =
|
|
58
|
+
todo
|
|
59
|
+
|
|
60
|
+
opendir(path[, options]) =
|
|
61
|
+
todo
|
|
62
|
+
|
|
63
|
+
readdir(path[, options]) =
|
|
64
|
+
todo
|
|
65
|
+
|
|
66
|
+
readlink(path[, options]) =
|
|
67
|
+
todo
|
|
68
|
+
|
|
69
|
+
realpath(path[, options]) =
|
|
70
|
+
todo
|
|
71
|
+
|
|
72
|
+
rename(oldPath, newPath) =
|
|
73
|
+
todo
|
|
74
|
+
|
|
75
|
+
rmdir(path[, options]) =
|
|
76
|
+
todo
|
|
77
|
+
|
|
78
|
+
rm(path[, options]) =
|
|
79
|
+
todo
|
|
80
|
+
|
|
81
|
+
stat(path[, options]) =
|
|
82
|
+
todo
|
|
83
|
+
|
|
84
|
+
statfs(path[, options]) =
|
|
85
|
+
todo
|
|
86
|
+
|
|
87
|
+
symlink(target, path[, type]) =
|
|
88
|
+
todo
|
|
89
|
+
|
|
90
|
+
truncate(path[, len]) =
|
|
91
|
+
todo
|
|
92
|
+
|
|
93
|
+
unlink(path) =
|
|
94
|
+
todo
|
|
95
|
+
|
|
96
|
+
utimes(path, atime, mtime) =
|
|
97
|
+
todo
|
|
98
|
+
|
|
99
|
+
watch(filename[, options]) =
|
|
100
|
+
todo
|
tooling/tree-sitter-plum/readme.md
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
# tree-sitter-
|
|
1
|
+
# tree-sitter-plum
|
|
2
2
|
|
|
3
|
-
[](https://github.com/pyrossh/tree-sitter-plum/actions/workflows/ci.yml)
|
|
4
|
-
[](https://crates.io/crates/tree-sitter-plum)
|
|
5
|
-
[](https://www.npmjs.com/package/tree-sitter-plum)
|
|
6
6
|
|
|
7
|
-
👾
|
|
7
|
+
👾 plum Programming Language
|
|
8
8
|
|
|
9
|
-
Tree sitter grammar for [
|
|
9
|
+
Tree sitter grammar for [plum programming language](https://github.com/pyrossh/plum.sh)
|
tooling/vscode-plum/.vscodeignore
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
.vscode/**
|
|
2
|
-
.vscode-test/**
|
|
3
|
-
.gitignore
|
|
4
|
-
vsc-extension-quickstart.md
|
tooling/vscode-plum/CHANGELOG.md
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
# Change Log
|
|
2
|
-
|
|
3
|
-
All notable changes to the "pacos" extension will be documented in this file.
|
|
4
|
-
|
|
5
|
-
Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file.
|
|
6
|
-
|
|
7
|
-
## [Unreleased]
|
|
8
|
-
|
|
9
|
-
- Initial release
|
tooling/vscode-plum/readme.md
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
# vscode-kestrel
|
|
2
|
-
|
|
3
|
-
👾 Kestrel Programming Language
|
|
4
|
-
|
|
5
|
-
VScode extension for [kestrel programming language](https://github.com/pyrossh/kestrel.sh)
|
|
6
|
-
|
|
7
|
-
This is the README for your extension "kestrel". After writing up a brief description, we recommend including the following sections.
|
|
8
|
-
|
|
9
|
-
## Features
|
|
10
|
-
|
|
11
|
-
Describe specific features of your extension including screenshots of your extension in action. Image paths are relative to this README file.
|
|
12
|
-
|
|
13
|
-
For example if there is an image subfolder under your extension project workspace:
|
|
14
|
-
|
|
15
|
-
\!\[feature X\]\(images/feature-x.png\)
|
|
16
|
-
|
|
17
|
-
> Tip: Many popular extensions utilize animations. This is an excellent way to show off your extension! We recommend short, focused animations that are easy to follow.
|
|
18
|
-
|
|
19
|
-
## Requirements
|
|
20
|
-
|
|
21
|
-
If you have any requirements or dependencies, add a section describing those and how to install and configure them.
|
|
22
|
-
|
|
23
|
-
## Extension Settings
|
|
24
|
-
|
|
25
|
-
Include if your extension adds any VS Code settings through the `contributes.configuration` extension point.
|
|
26
|
-
|
|
27
|
-
For example:
|
|
28
|
-
|
|
29
|
-
This extension contributes the following settings:
|
|
30
|
-
|
|
31
|
-
- `myExtension.enable`: Enable/disable this extension.
|
|
32
|
-
- `myExtension.thing`: Set to `blah` to do something.
|
|
33
|
-
|
|
34
|
-
## Known Issues
|
|
35
|
-
|
|
36
|
-
Calling out known issues can help limit users opening duplicate issues against your extension.
|
|
37
|
-
|
|
38
|
-
## Release Notes
|
|
39
|
-
|
|
40
|
-
Users appreciate release notes as you update your extension.
|
|
41
|
-
|
|
42
|
-
### 1.0.0
|
|
43
|
-
|
|
44
|
-
Initial release of ...
|
|
45
|
-
|
|
46
|
-
### 1.0.1
|
|
47
|
-
|
|
48
|
-
Fixed issue #.
|
|
49
|
-
|
|
50
|
-
### 1.1.0
|
|
51
|
-
|
|
52
|
-
Added features X, Y, and Z.
|
|
53
|
-
|
|
54
|
-
---
|
|
55
|
-
|
|
56
|
-
## Working with Markdown
|
|
57
|
-
|
|
58
|
-
You can author your README using Visual Studio Code. Here are some useful editor keyboard shortcuts:
|
|
59
|
-
|
|
60
|
-
- Split the editor (`Cmd+\` on macOS or `Ctrl+\` on Windows and Linux).
|
|
61
|
-
- Toggle preview (`Shift+Cmd+V` on macOS or `Shift+Ctrl+V` on Windows and Linux).
|
|
62
|
-
- Press `Ctrl+Space` (Windows, Linux, macOS) to see a list of Markdown snippets.
|
|
63
|
-
|
|
64
|
-
## For more information
|
|
65
|
-
|
|
66
|
-
- [Visual Studio Code's Markdown Support](http://code.visualstudio.com/docs/languages/markdown)
|
|
67
|
-
- [Markdown Syntax Reference](https://help.github.com/articles/markdown-basics/)
|
|
68
|
-
|
|
69
|
-
**Enjoy!**
|
tooling/vscode-plum/syntaxes/plum.tmLanguage.json
CHANGED
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"patterns": [
|
|
27
27
|
{
|
|
28
28
|
"name": "keyword.control.plum",
|
|
29
|
-
"match": "\\b(return|continue|break|match|if|else|while|for|module|as|is|import|assert|todo|crash)\\b"
|
|
29
|
+
"match": "\\b(do|in|this|return|continue|break|match|if|else|while|for|module|as|is|import|assert|todo|crash)\\b"
|
|
30
30
|
},
|
|
31
31
|
{
|
|
32
32
|
"name": "keyword.operator.arrow.plum",
|
tooling/vscode-plum/vsc-extension-quickstart.md
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
# Welcome to your VS Code Extension
|
|
2
|
-
|
|
3
|
-
## What's in the folder
|
|
4
|
-
|
|
5
|
-
* This folder contains all of the files necessary for your extension.
|
|
6
|
-
* `package.json` - this is the manifest file in which you declare your language support and define the location of the grammar file that has been copied into your extension.
|
|
7
|
-
* `syntaxes/pacos.tmLanguage.json` - this is the Text mate grammar file that is used for tokenization.
|
|
8
|
-
* `language-configuration.json` - this is the language configuration, defining the tokens that are used for comments and brackets.
|
|
9
|
-
|
|
10
|
-
## Get up and running straight away
|
|
11
|
-
|
|
12
|
-
* Make sure the language configuration settings in `language-configuration.json` are accurate.
|
|
13
|
-
* Press `F5` to open a new window with your extension loaded.
|
|
14
|
-
* Create a new file with a file name suffix matching your language.
|
|
15
|
-
* Verify that syntax highlighting works and that the language configuration settings are working.
|
|
16
|
-
|
|
17
|
-
## Make changes
|
|
18
|
-
|
|
19
|
-
* You can relaunch the extension from the debug toolbar after making changes to the files listed above.
|
|
20
|
-
* You can also reload (`Ctrl+R` or `Cmd+R` on Mac) the VS Code window with your extension to load your changes.
|
|
21
|
-
|
|
22
|
-
## Add more language features
|
|
23
|
-
|
|
24
|
-
* To add features such as IntelliSense, hovers and validators check out the VS Code extenders documentation at https://code.visualstudio.com/docs
|
|
25
|
-
|
|
26
|
-
## Install your extension
|
|
27
|
-
|
|
28
|
-
* To start using your extension with Visual Studio Code copy it into the `<user home>/.vscode/extensions` folder and restart Code.
|
|
29
|
-
* To share your extension with the world, read on https://code.visualstudio.com/docs about publishing an extension.
|