diff options
-rw-r--r-- | cpp/010vm | 2 | ||||
-rw-r--r-- | cpp/014types | 4 | ||||
-rw-r--r-- | cpp/020run | 5 | ||||
-rw-r--r-- | cpp/030container | 4 | ||||
-rw-r--r-- | cpp/031address | 2 | ||||
-rw-r--r-- | cpp/032array | 5 | ||||
-rw-r--r-- | cpp/034exclusive_container | 2 | ||||
-rw-r--r-- | cpp/035call | 6 | ||||
-rw-r--r-- | cpp/041name | 4 | ||||
-rw-r--r-- | cpp/042new | 9 | ||||
-rw-r--r-- | cpp/043space | 6 | ||||
-rw-r--r-- | cpp/vimrc.vim | 24 |
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\>" |