-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathverb.h
141 lines (118 loc) · 2.9 KB
/
verb.h
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
/*
Copyright 2010, 2011 Andrey Zholos
This file is part of kuc, a vector programming language.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef VERB_H
#define VERB_H
#include "value.h"
enum {
// normal verbs
verb_null,
verb_at,
verb_dot,
verb_comma,
verb_hash,
verb_line,
verb_plus,
verb_minus,
verb_times,
verb_divide,
verb_bang,
verb_and,
verb_or,
verb_tilde,
verb_equal,
verb_less,
verb_greater,
verb_hat,
verb_query,
verb_accent,
verb_cast,
verb_named_last = verb_cast,
// unnamed verbs
verb_list,
verb_divide_int,
verb_first,
verb_not_equal,
verb_not_less,
verb_not_greater,
verb_sum,
verb_raze,
verb_max,
verb_min,
verb_repr,
verb_show,
verb_lex,
verb_parse,
verb_disasm,
verb_collect,
verb_read,
verb_write,
verb_mmap,
verb_time,
verb_assign_item,
verb_assign_element,
// opcode-only verbs
verb_global_read,
verb_global_write,
verb_init_counter,
verb_init_closure,
verb_scalar_plus,
verb_scalar_minus
};
extern const struct verb {
char name;
struct value_verb literal_prime, literal;
} verbs[43];
extern const struct verb_run {
Value (*unary)(Value);
Value (*binary)(Value, Value);
Value (*variadic)(index n, const Value*); // n > 2
bool unary_collect; // reaches collector and should collect after use
bool binary_collect;
} verbs_run[49];
Value left(Value);
Value right(Value, Value);
Value type(Value);
Value enlist(Value);
Value join(Value, Value);
Value variadic_join(index, const Value*);
Value raze(Value);
Value count(Value);
Value take(Value, Value);
Value drop(Value, Value);
Value flip(Value);
Value last(Value);
Value first(Value);
Value reverse(Value);
Value element(Value, Value);
Value bang(Value, Value);
Value value(Value);
Value range(Value);
Value where(Value);
Value group(Value);
Value order_asc(Value);
Value order_desc(Value);
Value unique(Value);
Value binary_min(Value, Value);
Value binary_max(Value, Value);
Value fill(Value, Value);
Value null(Value);
Value find(Value, Value);
Value identical(Value, Value);
Value compose(Value, Value);
Value cast(Value, Value);
Value throw(Value);
Value show(Value);
void globals_init();
#endif /* VERB_H */