about summary refs log tree commit diff stats
path: root/termbox
Commit message (Expand)AuthorAgeFilesLines
* 4399Kartik Agaram2018-07-251-0/+0
* 3862Kartik K. Agaram2017-05-192-17/+16
* 3861 - screen untouched when entering console modeKartik K. Agaram2017-05-181-1/+0
* 3860 - stop buffering the screen in termboxKartik K. Agaram2017-05-183-197/+29
* 3858Kartik K. Agaram2017-05-132-10/+3
* 3857Kartik K. Agaram2017-05-132-15/+2
* 3854Kartik K. Agaram2017-05-132-12/+180
* 3842Kartik K. Agaram2017-05-043-21/+7
* 3826Kartik K. Agaram2017-04-161-173/+0
* 3824 - experiment: stop buffering in termboxKartik K. Agaram2017-04-163-177/+14
* 3711Kartik K. Agaram2016-12-261-4/+0
* 3488 -Kartik K. Agaram2016-10-081-1/+1
* 3450Kartik K. Agaram2016-10-061-9/+0
* 3444Kartik K. Agaram2016-10-061-3/+13
* 3443Kartik K. Agaram2016-10-051-5/+5
* 3222Kartik K. Agaram2016-08-181-0/+4
* 3191 - now builds on OpenBSDKartik K. Agaram2016-08-161-1/+1
* 2572Kartik K. Agaram2016-01-191-1/+1
* 2181 - detect shift-tabKartik K. Agaram2015-09-112-5/+10
* 2142Kartik K. Agaram2015-09-041-4/+0
* 2141 - attempt to deal with slow networksKartik K. Agaram2015-09-041-16/+27
* 2132 - support for ctrl + arrow keysKartik K. Agaram2015-09-022-4/+27
* 2131 - better tb_sync()Kartik K. Agaram2015-09-021-6/+10
* 2113 - stop updating entire screen on tb_present()Kartik K. Agaram2015-08-292-0/+12
* 2078 - update entire screen on tb_present()Kartik K. Agaram2015-08-261-4/+0
* 1964 - don't mess up pasteKartik K. Agaram2015-08-094-12/+55
* 1859Kartik K. Agaram2015-07-271-1/+1
* 1731 - ah, now fully responsiveKartik K. Agaram2015-07-082-0/+7
* 1573Kartik K. Agaram2015-06-162-0/+9
* 1531 - enable termbox's mouse supportKartik K. Agaram2015-06-052-0/+12
* 1530 - switch to termbox's 256-color modeKartik K. Agaram2015-06-053-48/+17
* 1486 - repl: hitting enter now workingKartik K. Agaram2015-05-272-0/+7
* 1368 - alias carriage-return and newlineKartik K. Agaram2015-05-141-0/+3
* 1327 - better error handling in chessboardKartik K. Agaram2015-05-101-2/+10
* 1325Kartik K. Agaram2015-05-103-0/+0
* 1323 - keyboard supports backspace and newlineKartik K. Agaram2015-05-105-4/+174
* 1319Kartik K. Agaram2015-05-101-6/+6
* 1314Kartik K. Agaram2015-05-091-1/+2
* 1313 - merge termboxKartik K. Agaram2015-05-092-4/+4
* 1276 - make C++ version the defaultKartik K. Agaram2015-05-059-0/+1384
Command Handlers") else if (command == "type") { load_type_abbreviations(in); } :(code) void load_type_abbreviations(istream& in) { string new_type_name = next_word(in); assert(has_data(in) || !new_type_name.empty()); if (!has_data(in) || new_type_name.empty()) { raise << "incomplete 'type' statement; must be of the form 'type <new type name> = <type expression>'\n" << end(); return; } string arrow = next_word(in); assert(has_data(in) || !arrow.empty()); if (arrow.empty()) { raise << "incomplete 'type' statement 'type " << new_type_name << "'\n" << end(); return; } if (arrow != "=") { raise << "'type' statements must be of the form 'type <new type name> = <type expression>' but got 'type " << new_type_name << ' ' << arrow << "'\n" << end(); return; } if (!has_data(in)) { raise << "incomplete 'type' statement 'type " << new_type_name << " ='\n" << end(); return; } string old = next_word(in); if (old.empty()) { raise << "incomplete 'type' statement 'type " << new_type_name << " ='\n" << end(); raise << "'type' statements must be of the form 'type <new type name> = <type expression>' but got 'type " << new_type_name << ' ' << arrow << "'\n" << end(); return; } if (contains_key(Type_abbreviations, new_type_name)) { raise << "'type' conflict: '" << new_type_name << "' defined as both '" << names_to_string_without_quotes(get(Type_abbreviations, new_type_name)) << "' and '" << old << "'\n" << end(); return; } trace(9990, "type") << "alias " << new_type_name << " = " << old << end(); type_tree* old_type = new_type_tree(old); put(Type_abbreviations, new_type_name, old_type); } type_tree* new_type_tree(const string& x) { string_tree* type_names = starts_with(x, "(") ? parse_string_tree(x) : parse_string_list(x); type_tree* result = new_type_tree(type_names); delete type_names; expand_type_abbreviations(result); return result; } string_tree* parse_string_list(const string& s) { istringstream in(s); in >> std::noskipws; return parse_property_list(in); } :(scenario type_error1) % Hide_errors = true; type foo +error: incomplete 'type' statement 'type foo' :(scenario type_error2) % Hide_errors = true; type foo = +error: incomplete 'type' statement 'type foo =' :(scenario type_error3) % Hide_errors = true; type foo bar baz +error: 'type' statements must be of the form 'type <new type name> = <type expression>' but got 'type foo bar' :(scenario type_conflict_error) % Hide_errors = true; type foo = bar type foo = baz +error: 'type' conflict: 'foo' defined as both 'bar' and 'baz' :(scenario type_abbreviation_for_compound) type foo = address:number def main [ a:foo <- copy 0 ] +transform: product type after expanding abbreviations: ("address" "number") //: cleaning up type abbreviations between tests and before exiting :(before "End save_snapshots") Type_abbreviations_snapshot = Type_abbreviations; :(before "End restore_snapshots") restore_type_abbreviations(); :(before "End One-time Setup") atexit(clear_type_abbreviations); :(code) void restore_type_abbreviations() { for (map<string, type_tree*>::iterator p = Type_abbreviations.begin(); p != Type_abbreviations.end(); ++p) { if (!contains_key(Type_abbreviations_snapshot, p->first)) delete p->second; } Type_abbreviations.clear(); Type_abbreviations = Type_abbreviations_snapshot; } void clear_type_abbreviations() { for (map<string, type_tree*>::iterator p = Type_abbreviations.begin(); p != Type_abbreviations.end(); ++p) delete p->second; Type_abbreviations.clear(); } //:: A few default abbreviations. :(before "End Mu Types Initialization") put(Type_abbreviations, "&", new_type_tree("address")); put(Type_abbreviations, "@", new_type_tree("array")); put(Type_abbreviations, "num", new_type_tree("number")); put(Type_abbreviations, "bool", new_type_tree("boolean")); put(Type_abbreviations, "char", new_type_tree("character")); :(scenario use_type_abbreviations_when_declaring_type_abbreviations) type foo = &:num def main [ a:foo <- copy 0 ] +transform: product type after expanding abbreviations: ("address" "number") //:: Expand type aliases before running. //: We'll do this in a transform so that we don't need to define abbreviations //: before we use them. :(scenario abbreviations_for_address_and_array) def main [ f 1:&:num # abbreviation for 'address:number' f 2:@:num # abbreviation for 'array:number' f 3:&:@:num # combining '&' and '@' f 4:&:&:@:&:@:num # ..any number of times f {5: (array (& num) 3)} # support for dilated reagents and more complex parse trees ] def f [ ] +transform: --- expand type abbreviations in recipe 'main' +transform: ingredient type after expanding abbreviations: ("address" "number") +transform: ingredient type after expanding abbreviations: ("array" "number") +transform: ingredient type after expanding abbreviations: ("address" "array" "number") +transform: ingredient type after expanding abbreviations: ("address" "address" "array" "address" "array" "number") +transform: ingredient type after expanding abbreviations: ("array" ("address" "number") "3") :(before "Transform.push_back(update_instruction_operations)") Transform.push_back(expand_type_abbreviations); // idempotent // Begin Type Modifying Transforms // End Type Modifying Transforms :(code) void expand_type_abbreviations(const recipe_ordinal r) { expand_type_abbreviations(get(Recipe, r)); } void expand_type_abbreviations(const recipe& caller) { trace(9991, "transform") << "--- expand type abbreviations in recipe '" << caller.name << "'" << end(); for (int i = 0; i < SIZE(caller.steps); ++i) { const instruction& inst = caller.steps.at(i); trace(9991, "transform") << "instruction '" << to_original_string(inst) << end(); for (long int i = 0; i < SIZE(inst.ingredients); ++i) { expand_type_abbreviations(inst.ingredients.at(i).type); trace(9992, "transform") << "ingredient type after expanding abbreviations: " << names_to_string(inst.ingredients.at(i).type) << end(); } for (long int i = 0; i < SIZE(inst.products); ++i) { expand_type_abbreviations(inst.products.at(i).type); trace(9992, "transform") << "product type after expanding abbreviations: " << names_to_string(inst.products.at(i).type) << end(); } } // End Expand Type Abbreviations(caller) } void expand_type_abbreviations(type_tree* type) { if (!type) return; if (!type->atom) { expand_type_abbreviations(type->left); expand_type_abbreviations(type->right); return; } if (contains_key(Type_abbreviations, type->name)) *type = type_tree(*get(Type_abbreviations, type->name)); }