diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2015-06-23 13:04:46 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2015-06-23 13:04:46 -0700 |
commit | fedebaf5dbc1b39347ad3e3a1580fa0190c320b6 (patch) | |
tree | c7951656c6495acb5f69db45953ce8cec60587f5 /075scenario_console.cc | |
parent | 02a55f7183f1497284accb3b89abab4a103d6e68 (diff) | |
download | mu-fedebaf5dbc1b39347ad3e3a1580fa0190c320b6.tar.gz |
1630 - bring back replace-in-console
This takes away the need for multi-level escaping in scenario setup. Post-conditions like screen-should-contain are still an issue, though. Maybe each string literal should be able to specify escapes inside its syntax? Or at a per-instruction granularity?
Diffstat (limited to '075scenario_console.cc')
-rw-r--r-- | 075scenario_console.cc | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/075scenario_console.cc b/075scenario_console.cc index f776f6b2..017eebcd 100644 --- a/075scenario_console.cc +++ b/075scenario_console.cc @@ -157,6 +157,32 @@ scenario events-in-scenario [ ] ] +//: Deal with special keys and unmatched brackets by allowing each test to +//: independently choose the unicode symbol to denote them. +:(before "End Primitive Recipe Declarations") +REPLACE_IN_CONSOLE, +:(before "End Primitive Recipe Numbers") +Recipe_number["replace-in-console"] = REPLACE_IN_CONSOLE; +:(before "End Primitive Recipe Implementations") +case REPLACE_IN_CONSOLE: { + assert(scalar(ingredients.at(0))); +//? cerr << "console: " << Memory[CONSOLE] << '\n'; //? 1 + if (!Memory[CONSOLE]) + raise << "console not initialized\n" << die(); + long long int console_data = Memory[Memory[CONSOLE]+1]; +//? cerr << "console data starts at " << console_data << '\n'; //? 1 + long long int size = Memory[console_data]; // array size +//? cerr << "size of console data is " << size << '\n'; //? 1 + for (long long int i = 0, curr = console_data+1; i < size; ++i, curr+=size_of_event()) { +//? cerr << curr << '\n'; //? 1 + if (Memory[curr] != /*text*/0) continue; + if (Memory[curr+1] != ingredients.at(0).at(0)) continue; + for (long long int n = 0; n < size_of_event(); ++n) + Memory[curr+n] = ingredients.at(1).at(n); + } + break; +} + :(code) long long int count_events(const recipe& r) { long long int result = 0; |