blob: b7de379e7596f3166a28248fcd2998c6c71d89f2 (
plain)
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
|
# neb
### an attempt at a language
## ideas
- **Lisp-y**: I hope you like parentheses!
- **Strongly typed**: types are Good, and could enable future compilation
- **We <3 Linux**: strong support for pipelines and shell-ing out
- **Immutable variables**: mutability is scary and makes for strange bugs
- **Pure functions**: side effects are also scary
## things that (hopefully) work
### housekeeping
- TODO `(exit [[status :int]]) => :bool`
### io
- `(print [out :string]) => :bool ; print to stdout`
- TODO `(print-all [strings :list]) => :bool ; a list of strings`
### file system
- `(glob [regex :string]) => :list`
- `(read-lines [filename :string]) => :list`
- `(unlink [filename :string]) => :list ; returns empty list on success`
### comparison and boolean
- `(and [arg :bool] [many :bool]) => :bool`
- `(or [arg :bool] [many :bool]) => :bool`
- `(eq? [arg1 :literal] [arg2 :literal]) => :bool`
- `(> [left :number] [right :number]) => :bool`
- `(>= [left :number] [right :number]) => :bool`
- `(< [left :number] [right :number]) => :bool`
- `(<= [left :number] [right :number]) => :bool`
- `(not [arg :bool]) => :bool`
### math
- `(+ [arg :number] [many :number]) => :number`
- `(- [arg :number] [many :number]) => :number`
- `(* [arg :number] [many :number]) => :number`
- `(/ [num :number] [denom :number]) => :number`
### string
- `(concat [arg :string] [many :string]) => :string`
- `(split [arg :string] [split-val :string]) => :list`
- `(strip [arg :string]) => :string`
### flow control
- `(if [cond :bool] [t-branch :any|:expr] [[f-branch :any|:expr]]) => :any`
- `(for-count [count :int] [many :expr]) => :any ; creates 'idx' variable with loop count`
- `(for-each [items :list] [many :expr]) => :any ; creates '_item_' variable with current item`
- `(| [first :expr] [many :expr]) => :any ; creates 'items' variable`
- `(branch ([cond1 :bool] [expr1 :any]) [([condN: :bool] [exprN :any])]) => :any`
- `(block [expr1 :any] ... [exprN :any]) => :any`
### type checking
- TODO `(string? [arg :any]) => :bool`
- TODO `(int? [arg :any]) => :bool`
- TODO `(float? [arg :any]) => :bool`
- TODO `(number? [arg :any]) => :bool ; returns #true for :int or :float`
- TODO `(bool? [arg :any]) => :bool`
- `(list? [arg :any]) => :bool`
### type conversion
- TODO `(int->string [arg :int]) => :string`
- TODO `(float->string [arg :float]) => :string`
- TODO `(number->string [arg :number]) => :string`
- TODO `(bool->string [arg :bool]) => :string`
- `(->string [arg :literal]) => :string ; works for all literals`
- `(string->int [arg :string]) => :int`
### variables
- `(def [name :string] [value :expr]) => ? ; lexically scoped`
- `(redef [name :string] [value :expr]) => ? ; must already be defined`
### shell
- `($ [command :string]) => :list ; doesn't support pipes, first item is return code`
- TODO `($| [commands :list]) => :bool ; pipes together multiple shell commands`
### functions
- `(lambda (args) (expr1) (expr2) ... (exprN)) => :any`
- `(func name (args) (expr1) (expr2) ... (exprN)) => :any`
### lists
- `(empty? [arg :list]) => :bool`
- `(first [arg :list]) => :any ; car`
- `(list [arg :any] [many :any]) => :list`
- `(list-length [arg :list]) => :int`
- `(list-reverse [arg :list]) => :int`
- `(rest [arg :list]) => :any ; cdr`
- `(shuf [arg :list]) => :list ; shuffle the elements of the list`
- `(zip [arg1 :list] [arg2 :list]) => :list`
### "higher order"
- `(apply [func :symbol] [target :list]) => :any`
- `(map [func :symbol] [target :list]) => :list`
### other
- pretty much nothing else
## TODO (this section may be incomplete)
### types
- [ ] revisit type system when i understand *gestures broadly*
### parsing
- [x] build an AST like a real person (sorta?)
### math
- [x] division (float)
- [x] division (int)
- [ ] mod (int)
- [ ] exponent
### strings
- [x] concat
- [ ] substring
- [ ] lower/uppercase
### flow control
- [x] if
- [x] if with empty else
- [x] branch
- [x] pipe
### lists
- [x] lex
- [x] parse
- [x] evaluate
### other structure things
- [ ] generic struct?
- [ ] dict?
### symbols
- [x] define
- [x] access
### shell
- [x] call out
- [x] pipe
|