about summary refs log tree commit diff stats
path: root/cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cpp')
-rw-r--r--cpp/010vm2
-rw-r--r--cpp/014types4
-rw-r--r--cpp/020run5
-rw-r--r--cpp/030container4
-rw-r--r--cpp/031address2
-rw-r--r--cpp/032array5
-rw-r--r--cpp/034exclusive_container2
-rw-r--r--cpp/035call6
-rw-r--r--cpp/041name4
-rw-r--r--cpp/042new9
-rw-r--r--cpp/043space6
-rw-r--r--cpp/vimrc.vim24
12 files changed, 46 insertions, 27 deletions
diff --git a/cpp/010vm b/cpp/010vm
index de50bde0..a900a56e 100644
--- a/cpp/010vm
+++ b/cpp/010vm
@@ -161,7 +161,7 @@ Next_recipe_number = 1000;  // consistent new numbers for each test
 
 
 
-//: Helpers
+//:: Helpers
 
 :(code)
 instruction::instruction() :is_label(false), operation(IDLE) {}
diff --git a/cpp/014types b/cpp/014types
index 226be5ee..f12aa6f8 100644
--- a/cpp/014types
+++ b/cpp/014types
@@ -51,7 +51,7 @@ void insert_container(const string& command, kind_of_type kind, istream& in) {
   t.size = t.elements.size();
 }
 
-//: Similarly for exclusive_container.
+//:: Similarly for exclusive_container.
 
 :(scenario "exclusive_container")
 exclusive-container foo [
@@ -69,7 +69,7 @@ else if (command == "exclusive-container") {
   insert_container(command, exclusive_container, in);
 }
 
-//: ensure types created in one scenario don't leak outside it.
+//:: ensure types created in one scenario don't leak outside it.
 :(before "End Globals")
 vector<type_number> recently_added_types;
 :(before "End Setup")
diff --git a/cpp/020run b/cpp/020run
index 400524e2..02a949f0 100644
--- a/cpp/020run
+++ b/cpp/020run
@@ -122,7 +122,7 @@ void load(string filename) {
   fin.close();
 }
 
-//: On startup, load everything in core.mu
+//:: On startup, load everything in core.mu
 :(before "End Load Recipes")
 load("core.mu");
 // freeze everything so it doesn't get cleared by tests
@@ -137,7 +137,8 @@ void run(string form) {
   run(tmp.front());
 }
 
-:(code)
+//:: Reading from memory, writing to memory.
+
 vector<int> read_memory(reagent x) {
 //?   cout << "read_memory: " << x.to_string() << '\n'; //? 1
   vector<int> result;
diff --git a/cpp/030container b/cpp/030container
index fa936d25..b84314b6 100644
--- a/cpp/030container
+++ b/cpp/030container
@@ -59,7 +59,7 @@ if (t.kind == container) {
   return result;
 }
 
-//: To access elements of a container, use 'get'
+//:: To access elements of a container, use 'get'
 :(scenario "get")
 recipe main [
   12:integer <- copy 34:literal
@@ -128,7 +128,7 @@ recipe main [
 +run: product 0 is 36
 +mem: storing 36 in location 15
 
-//: To write to elements of containers, you need their address.
+//:: To write to elements of containers, you need their address.
 
 :(scenario "get_address")
 recipe main [
diff --git a/cpp/031address b/cpp/031address
index e3f31869..e31ae67d 100644
--- a/cpp/031address
+++ b/cpp/031address
@@ -75,7 +75,7 @@ reagent deref(reagent x) {
   return result;
 }
 
-//: 'get' can read from container address
+//:: 'get' can read from container address
 :(scenario "get_indirect")
 recipe main [
   1:integer <- copy 2:literal
diff --git a/cpp/032array b/cpp/032array
index 284ca592..3aa531d0 100644
--- a/cpp/032array
+++ b/cpp/032array
@@ -56,7 +56,8 @@ if (x.types[0] != Type_number["array"] && size_of(x) != data.size())
     return 1 + Memory[r.value]*size_of(array_element(r.types));
   }
 
-//: To access elements of an array, use 'index'
+//:: To access elements of an array, use 'index'
+
 :(scenario "index")
 recipe main [
   1:integer <- copy 3:literal
@@ -139,7 +140,7 @@ recipe main [
 +run: address to copy is 2
 +mem: storing 2 in location 5
 
-//: To write to elements of containers, you need their address.
+//:: To write to elements of containers, you need their address.
 
 :(scenario "index_indirect")
 recipe main [
diff --git a/cpp/034exclusive_container b/cpp/034exclusive_container
index 8f9fe842..b7d08c12 100644
--- a/cpp/034exclusive_container
+++ b/cpp/034exclusive_container
@@ -54,7 +54,7 @@ if (t.kind == exclusive_container) {
   return result+1;
 }
 
-//: To access variants of an exclusive container, use 'maybe-convert'.
+//:: To access variants of an exclusive container, use 'maybe-convert'.
 //: It always returns an address (so that you can modify it) or null (to
 //: signal that the conversion failed (because the container contains a
 //: different variant).
diff --git a/cpp/035call b/cpp/035call
index 21d07b18..efb4a2a7 100644
--- a/cpp/035call
+++ b/cpp/035call
@@ -31,7 +31,9 @@ struct routine {
   routine::routine(recipe_number r) {
     calls.push(call(r));
   }
-//: now update routine's helpers
+
+//:: now update routine's helpers
+
 :(replace{} "inline size_t& running_at(routine& rr)")
 inline size_t& running_at(routine& rr) {
   return rr.calls.top().pc;
@@ -56,7 +58,7 @@ default: {
   continue;  // not done with caller; don't increment pc
 }
 
-//: finally, we need to fix the termination conditions for the run loop
+//:: finally, we need to fix the termination conditions for the run loop
 
 :(replace{} "inline bool done(routine& rr)")
 inline bool done(routine& rr) {
diff --git a/cpp/041name b/cpp/041name
index c514ed3d..64a416af 100644
--- a/cpp/041name
+++ b/cpp/041name
@@ -134,7 +134,7 @@ recipe main [
 ]
 -name: assign x 1
 
-//: Support element names for containers in 'get' and 'get-address'.
+//:: Support element names for containers in 'get' and 'get-address'.
 
 //: update our running example container for the next test
 :(before "End Mu Types Initialization")
@@ -173,7 +173,7 @@ recipe main [
 +name: assign a 1
 +name: assign b 3
 
-//: Support variant names for exclusive containers in 'maybe-convert'.
+//:: Support variant names for exclusive containers in 'maybe-convert'.
 
 :(scenarios run)
 :(scenario "maybe_convert_named")
diff --git a/cpp/042new b/cpp/042new
index 0d7742f8..7244cca2 100644
--- a/cpp/042new
+++ b/cpp/042new
@@ -19,7 +19,8 @@ size_t alloc;
     calls.push(call(r));
   }
 
-//: First handle 'type' operands
+//:: First handle 'type' operands.
+
 :(before "End Mu Types Initialization")
 Type_number["type"] = 0;
 :(after "Per-recipe Transforms")
@@ -35,7 +36,8 @@ if (inst.operation == Recipe_number["new"]) {
   trace("new") << inst.ingredients[0].name << " -> " << inst.ingredients[0].value;
 }
 
-//: Now implement the primitive recipe.
+//:: Now implement the primitive recipe.
+
 :(before "End Primitive Recipe Declarations")
 NEW,
 :(before "End Primitive Recipe Numbers")
@@ -74,7 +76,8 @@ recipe main [
 +run: instruction main/2
 +mem: storing 5 in location 3
 
-//: Next, extend 'new' to handle a string literal argument.
+//:: Next, extend 'new' to handle a string literal argument.
+
 :(scenario "new_string")
 recipe main [
   1:address:array:character <- new [abc def]
diff --git a/cpp/043space b/cpp/043space
index b2b29cf3..c285f65f 100644
--- a/cpp/043space
+++ b/cpp/043space
@@ -52,6 +52,8 @@ reagent absolutize(reagent x) {
 :(before "return result" following "reagent deref(reagent x)")
 result.properties.push_back(pair<string, vector<string> >("raw", vector<string>()));
 
+//:: fix 'get'
+
 :(scenario "deref_sidesteps_default_space_in_get")
 recipe main [
   # pretend pointer to container from outside
@@ -69,6 +71,8 @@ recipe main [
 :(after "reagent tmp" following "case GET:")
 tmp.properties.push_back(pair<string, vector<string> >("raw", vector<string>()));
 
+//:: fix 'index'
+
 :(scenario "deref_sidesteps_default_space_in_index")
 recipe main [
   # pretend pointer to array from outside
@@ -87,6 +91,8 @@ recipe main [
 :(after "reagent tmp" following "case INDEX:")
 tmp.properties.push_back(pair<string, vector<string> >("raw", vector<string>()));
 
+//:: helpers
+
 :(code)
 int space_base(const reagent& x) {
   return Current_routine->calls.top().default_space;
diff --git a/cpp/vimrc.vim b/cpp/vimrc.vim
index 4f89542e..627bfc8a 100644
--- a/cpp/vimrc.vim
+++ b/cpp/vimrc.vim
@@ -1,23 +1,29 @@
 " Highlighting literate directives in C++ sources.
 function! HighlightTangledFile()
-  set ft=cpp
+  if &ft == ""
+    set ft=cpp
+  endif
   set comments-=://
   set comments-=n://
   set comments+=n://:,n://
+
+  set isk+=-
+
   syntax region tangleDirective start=+:(+ skip=+".*"+ end=+)+
   highlight link tangleDirective Delimiter
   syntax region traceContains start="^+" end="$"
   highlight traceContains ctermfg=darkgreen
   syntax region traceAbsent start="^-" end="$"
   highlight traceAbsent ctermfg=darkred
+  " Our C++ files can have mu code in scenarios, so highlight mu comments like
+  " regular comments.
+  syntax match muComment /#.*$/ | highlight link muComment Comment
+  syntax match muSalientComment /##.*$/ | highlight link muSalientComment SalientComment
+  " Tangled comments only make sense in the sources and are stripped out of
+  " the generated .cc file. They're highlighted same as regular comments.
+  syntax match tangledComment /\/\/:.*/ | highlight link tangledComment Comment
+  syntax match tangledSalientComment /\/\/::.*/ | highlight link tangledSalientComment SalientComment
 endfunction
 call HighlightTangledFile()
+autocmd BufRead,BufNewFile *.mu set ft=mu
 autocmd BufRead,BufNewFile 0* call HighlightTangledFile()
-
-set isk+=-
-
-" scenarios inside c++ files
-syntax match muComment /#.*$/ | highlight link muComment Comment
-syntax keyword muControl reply jump jump-if jump-unless loop loop-if loop-unless break-if break-unless | highlight link muControl Identifier
-syntax match muAssign "<-" | highlight link muAssign SpecialChar
-syntax match muAssign "\<raw\>"
4.0&id=84e9853c1613f43f76bd46f0c1eb143d1db16ac2'>^
ef6178a ^

77ede6e ^




ef6178a ^

0abafa6 ^
77ede6e ^



143289b ^
77ede6e ^


312a53e ^




4465646 ^


312a53e ^


2dafe4b ^


312a53e ^




ef6178a ^
a275f65 ^
4465646 ^

ef6178a ^





312a53e ^
4465646 ^





db213fd ^

a275f65 ^
312a53e ^


4465646 ^
312a53e ^
a275f65 ^
db213fd ^
4465646 ^
312a53e ^
db213fd ^












2e5ae19 ^


2e5ae19 ^






2e5ae19 ^













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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256