diff options
56 files changed, 1481 insertions, 1480 deletions
diff --git a/011load.cc b/011load.cc index 978d2fae..c1525014 100644 --- a/011load.cc +++ b/011load.cc @@ -3,7 +3,7 @@ :(scenarios load) // use 'load' instead of 'run' in all scenarios in this layer :(scenario first_recipe) recipe main [ - 1:number <- copy 23:literal + 1:number <- copy 23 ] +parse: instruction: copy +parse: ingredient: {name: "23", properties: ["23": "literal"]} @@ -245,7 +245,7 @@ recently_added_recipes.clear(); recipe f1 [ ] # this comment will go through to 'load' recipe main [ - 1:number <- copy 23:literal + 1:number <- copy 23 ] +parse: instruction: copy +parse: ingredient: {name: "23", properties: ["23": "literal"]} @@ -254,7 +254,7 @@ recipe main [ :(scenario parse_comment_amongst_instruction) recipe main [ # comment - 1:number <- copy 23:literal + 1:number <- copy 23 ] +parse: instruction: copy +parse: ingredient: {name: "23", properties: ["23": "literal"]} @@ -263,7 +263,7 @@ recipe main [ :(scenario parse_comment_amongst_instruction2) recipe main [ # comment - 1:number <- copy 23:literal + 1:number <- copy 23 # comment ] +parse: instruction: copy @@ -272,9 +272,9 @@ recipe main [ :(scenario parse_comment_amongst_instruction3) recipe main [ - 1:number <- copy 23:literal + 1:number <- copy 23 # comment - 2:number <- copy 23:literal + 2:number <- copy 23 ] +parse: instruction: copy +parse: ingredient: {name: "23", properties: ["23": "literal"]} @@ -285,7 +285,7 @@ recipe main [ :(scenario parse_comment_after_instruction) recipe main [ - 1:number <- copy 23:literal # comment + 1:number <- copy 23 # comment ] +parse: instruction: copy +parse: ingredient: {name: "23", properties: ["23": "literal"]} @@ -305,7 +305,7 @@ recipe main [ :(scenario parse_multiple_properties) recipe main [ - 1:number <- copy 23:literal/foo:bar:baz + 1:number <- copy 23/foo:bar:baz ] +parse: instruction: copy +parse: ingredient: {name: "23", properties: ["23": "literal", "foo": "bar":"baz"]} @@ -313,7 +313,7 @@ recipe main [ :(scenario parse_multiple_products) recipe main [ - 1:number, 2:number <- copy 23:literal + 1:number, 2:number <- copy 23 ] +parse: instruction: copy +parse: ingredient: {name: "23", properties: ["23": "literal"]} @@ -322,7 +322,7 @@ recipe main [ :(scenario parse_multiple_ingredients) recipe main [ - 1:number, 2:number <- copy 23:literal, 4:number + 1:number, 2:number <- copy 23, 4:number ] +parse: instruction: copy +parse: ingredient: {name: "23", properties: ["23": "literal"]} @@ -332,7 +332,7 @@ recipe main [ :(scenario parse_multiple_types) recipe main [ - 1:number, 2:address:number <- copy 23:literal, 4:number + 1:number, 2:address:number <- copy 23, 4:number ] +parse: instruction: copy +parse: ingredient: {name: "23", properties: ["23": "literal"]} @@ -342,6 +342,6 @@ recipe main [ :(scenario parse_properties) recipe main [ - 1:number:address/deref <- copy 23:literal + 1:number:address/deref <- copy 23 ] +parse: product: {name: "1", properties: ["1": "number":"address", "deref": ]} diff --git a/014literal_noninteger.cc b/014literal_noninteger.cc index 5f0b0327..7c6e19d3 100644 --- a/014literal_noninteger.cc +++ b/014literal_noninteger.cc @@ -1,5 +1,4 @@ //: Support literal non-integers. -//: '3.14159:literal' is ugly, so we'll just say '3.14159' for non-integers. :(scenarios load) :(scenario noninteger_literal) diff --git a/020run.cc b/020run.cc index 5f1e15c1..81eeb14d 100644 --- a/020run.cc +++ b/020run.cc @@ -11,14 +11,14 @@ :(scenario copy_literal) recipe main [ - 1:number <- copy 23:literal + 1:number <- copy 23 ] -+run: 1:number <- copy 23:literal ++run: 1:number <- copy 23 +mem: storing 23 in location 1 :(scenario copy) recipe main [ - 1:number <- copy 23:literal + 1:number <- copy 23 2:number <- copy 1:number ] +run: 2:number <- copy 1:number @@ -27,7 +27,7 @@ recipe main [ :(scenario copy_multiple) recipe main [ - 1:number, 2:number <- copy 23:literal, 24:literal + 1:number, 2:number <- copy 23, 24 ] +mem: storing 23 in location 1 +mem: storing 24 in location 2 @@ -249,21 +249,21 @@ bool is_literal(const reagent& r) { :(scenario run_label) recipe main [ +foo - 1:number <- copy 23:literal + 1:number <- copy 23 2:number <- copy 1:number ] -+run: 1:number <- copy 23:literal ++run: 1:number <- copy 23 +run: 2:number <- copy 1:number -run: +foo :(scenario run_dummy) recipe main [ - _ <- copy 0:literal + _ <- copy 0 ] -+run: _ <- copy 0:literal ++run: _ <- copy 0 -:(scenario run_literal) +:(scenario write_to_0_disallowed) recipe main [ - 0:literal/screen <- copy 0:literal + 0 <- copy 34 ] --mem: storing 0 in location 0 +-mem: storing 34 in location 0 diff --git a/021arithmetic.cc b/021arithmetic.cc index 51df6f46..1485e194 100644 --- a/021arithmetic.cc +++ b/021arithmetic.cc @@ -19,21 +19,21 @@ case ADD: { :(scenario add_literal) recipe main [ - 1:number <- add 23:literal, 34:literal + 1:number <- add 23, 34 ] +mem: storing 57 in location 1 :(scenario add) recipe main [ - 1:number <- copy 23:literal - 2:number <- copy 34:literal + 1:number <- copy 23 + 2:number <- copy 34 3:number <- add 1:number, 2:number ] +mem: storing 57 in location 3 :(scenario add_multiple) recipe main [ - 1:number <- add 3:literal, 4:literal, 5:literal + 1:number <- add 3, 4, 5 ] +mem: storing 12 in location 1 @@ -60,21 +60,21 @@ case SUBTRACT: { :(scenario subtract_literal) recipe main [ - 1:number <- subtract 5:literal, 2:literal + 1:number <- subtract 5, 2 ] +mem: storing 3 in location 1 :(scenario subtract) recipe main [ - 1:number <- copy 23:literal - 2:number <- copy 34:literal + 1:number <- copy 23 + 2:number <- copy 34 3:number <- subtract 1:number, 2:number ] +mem: storing -11 in location 3 :(scenario subtract_multiple) recipe main [ - 1:number <- subtract 6:literal, 3:literal, 2:literal + 1:number <- subtract 6, 3, 2 ] +mem: storing 1 in location 1 @@ -96,21 +96,21 @@ case MULTIPLY: { :(scenario multiply_literal) recipe main [ - 1:number <- multiply 2:literal, 3:literal + 1:number <- multiply 2, 3 ] +mem: storing 6 in location 1 :(scenario multiply) recipe main [ - 1:number <- copy 4:literal - 2:number <- copy 6:literal + 1:number <- copy 4 + 2:number <- copy 6 3:number <- multiply 1:number, 2:number ] +mem: storing 24 in location 3 :(scenario multiply_multiple) recipe main [ - 1:number <- multiply 2:literal, 3:literal, 4:literal + 1:number <- multiply 2, 3, 4 ] +mem: storing 24 in location 1 @@ -137,21 +137,21 @@ case DIVIDE: { :(scenario divide_literal) recipe main [ - 1:number <- divide 8:literal, 2:literal + 1:number <- divide 8, 2 ] +mem: storing 4 in location 1 :(scenario divide) recipe main [ - 1:number <- copy 27:literal - 2:number <- copy 3:literal + 1:number <- copy 27 + 2:number <- copy 3 3:number <- divide 1:number, 2:number ] +mem: storing 9 in location 3 :(scenario divide_multiple) recipe main [ - 1:number <- divide 12:literal, 3:literal, 2:literal + 1:number <- divide 12, 3, 2 ] +mem: storing 2 in location 1 @@ -178,15 +178,15 @@ case DIVIDE_WITH_REMAINDER: { :(scenario divide_with_remainder_literal) recipe main [ - 1:number, 2:number <- divide-with-remainder 9:literal, 2:literal + 1:number, 2:number <- divide-with-remainder 9, 2 ] +mem: storing 4 in location 1 +mem: storing 1 in location 2 :(scenario divide_with_remainder) recipe main [ - 1:number <- copy 27:literal - 2:number <- copy 11:literal + 1:number <- copy 27 + 2:number <- copy 11 3:number, 4:number <- divide-with-remainder 1:number, 2:number ] +mem: storing 2 in location 3 @@ -195,7 +195,7 @@ recipe main [ :(scenario divide_with_decimal_point) recipe main [ # todo: literal floats? - 1:number <- divide 5:literal, 2:literal + 1:number <- divide 5, 2 ] +mem: storing 2.5 in location 1 diff --git a/022boolean.cc b/022boolean.cc index bebe2204..6b02b4a8 100644 --- a/022boolean.cc +++ b/022boolean.cc @@ -18,27 +18,27 @@ case AND: { :(scenario and) recipe main [ - 1:boolean <- copy 1:literal - 2:boolean <- copy 0:literal + 1:boolean <- copy 1 + 2:boolean <- copy 0 3:boolean <- and 1:boolean, 2:boolean ] +mem: storing 0 in location 3 :(scenario and2) recipe main [ - 1:boolean <- and 1:literal, 1:literal + 1:boolean <- and 1, 1 ] +mem: storing 1 in location 1 :(scenario and_multiple) recipe main [ - 1:boolean <- and 1:literal, 1:literal, 0:literal + 1:boolean <- and 1, 1, 0 ] +mem: storing 0 in location 1 :(scenario and_multiple2) recipe main [ - 1:boolean <- and 1:literal, 1:literal, 1:literal + 1:boolean <- and 1, 1, 1 ] +mem: storing 1 in location 1 @@ -60,27 +60,27 @@ case OR: { :(scenario or) recipe main [ - 1:boolean <- copy 1:literal - 2:boolean <- copy 0:literal + 1:boolean <- copy 1 + 2:boolean <- copy 0 3:boolean <- or 1:boolean, 2:boolean ] +mem: storing 1 in location 3 :(scenario or2) recipe main [ - 1:boolean <- or 0:literal, 0:literal + 1:boolean <- or 0, 0 ] +mem: storing 0 in location 1 :(scenario or_multiple) recipe main [ - 1:boolean <- and 0:literal, 0:literal, 0:literal + 1:boolean <- and 0, 0, 0 ] +mem: storing 0 in location 1 :(scenario or_multiple2) recipe main [ - 1:boolean <- or 0:literal, 0:literal, 1:literal + 1:boolean <- or 0, 0, 1 ] +mem: storing 1 in location 1 @@ -100,14 +100,14 @@ case NOT: { :(scenario not) recipe main [ - 1:boolean <- copy 1:literal + 1:boolean <- copy 1 2:boolean <- not 1:boolean ] +mem: storing 0 in location 2 :(scenario not_multiple) recipe main [ - 1:boolean, 2:boolean, 3:boolean <- not 1:literal, 0:literal, 1:literal + 1:boolean, 2:boolean, 3:boolean <- not 1, 0, 1 ] +mem: storing 0 in location 1 +mem: storing 1 in location 2 diff --git a/023jump.cc b/023jump.cc index af713628..ba18e439 100644 --- a/023jump.cc +++ b/023jump.cc @@ -4,10 +4,10 @@ #? % Trace_stream->dump_layer = "all"; #? 1 recipe main [ jump 1:offset - 1:number <- copy 1:literal + 1:number <- copy 1 ] +run: jump 1:offset --run: 1:number <- copy 1:literal +-run: 1:number <- copy 1 -mem: storing 1 in location 1 :(before "End Primitive Recipe Declarations") @@ -75,22 +75,22 @@ case JUMP_IF: { :(scenario jump_if) recipe main [ - jump-if 999:literal, 1:offset - 123:number <- copy 1:literal + jump-if 999, 1:offset + 123:number <- copy 1 ] -+run: jump-if 999:literal, 1:offset ++run: jump-if 999, 1:offset +run: jumping to instruction 2 --run: 1:number <- copy 1:literal +-run: 1:number <- copy 1 -mem: storing 1 in location 123 :(scenario jump_if_fallthrough) recipe main [ - jump-if 0:literal, 1:offset - 123:number <- copy 1:literal + jump-if 0, 1:offset + 123:number <- copy 1 ] -+run: jump-if 0:literal, 1:offset ++run: jump-if 0, 1:offset +run: jump-if fell through -+run: 123:number <- copy 1:literal ++run: 123:number <- copy 1 +mem: storing 1 in location 123 :(before "End Primitive Recipe Declarations") @@ -123,20 +123,20 @@ case JUMP_UNLESS: { :(scenario jump_unless) recipe main [ - jump-unless 0:literal, 1:offset - 123:number <- copy 1:literal + jump-unless 0, 1:offset + 123:number <- copy 1 ] -+run: jump-unless 0:literal, 1:offset ++run: jump-unless 0, 1:offset +run: jumping to instruction 2 --run: 123:number <- copy 1:literal +-run: 123:number <- copy 1 -mem: storing 1 in location 123 :(scenario jump_unless_fallthrough) recipe main [ - jump-unless 999:literal, 1:offset - 123:number <- copy 1:literal + jump-unless 999, 1:offset + 123:number <- copy 1 ] -+run: jump-unless 999:literal, 1:offset ++run: jump-unless 999, 1:offset +run: jump-unless fell through -+run: 123:number <- copy 1:literal ++run: 123:number <- copy 1 +mem: storing 1 in location 123 diff --git a/024compare.cc b/024compare.cc index cd31065b..fb3481fd 100644 --- a/024compare.cc +++ b/024compare.cc @@ -25,8 +25,8 @@ case EQUAL: { :(scenario equal) recipe main [ - 1:number <- copy 34:literal - 2:number <- copy 33:literal + 1:number <- copy 34 + 2:number <- copy 33 3:number <- equal 1:number, 2:number ] +mem: location 1 is 34 @@ -35,8 +35,8 @@ recipe main [ :(scenario equal2) recipe main [ - 1:number <- copy 34:literal - 2:number <- copy 34:literal + 1:number <- copy 34 + 2:number <- copy 34 3:number <- equal 1:number, 2:number ] +mem: location 1 is 34 @@ -45,13 +45,13 @@ recipe main [ :(scenario equal_multiple) recipe main [ - 1:number <- equal 34:literal, 34:literal, 34:literal + 1:number <- equal 34, 34, 34 ] +mem: storing 1 in location 1 :(scenario equal_multiple2) recipe main [ - 1:number <- equal 34:literal, 34:literal, 35:literal + 1:number <- equal 34, 34, 35 ] +mem: storing 0 in location 1 @@ -85,29 +85,29 @@ case GREATER_THAN: { :(scenario greater_than) recipe main [ - 1:number <- copy 34:literal - 2:number <- copy 33:literal + 1:number <- copy 34 + 2:number <- copy 33 3:boolean <- greater-than 1:number, 2:number ] +mem: storing 1 in location 3 :(scenario greater_than2) recipe main [ - 1:number <- copy 34:literal - 2:number <- copy 34:literal + 1:number <- copy 34 + 2:number <- copy 34 3:boolean <- greater-than 1:number, 2:number ] +mem: storing 0 in location 3 :(scenario greater_than_multiple) recipe main [ - 1:boolean <- greater-than 36:literal, 35:literal, 34:literal + 1:boolean <- greater-than 36, 35, 34 ] +mem: storing 1 in location 1 :(scenario greater_than_multiple2) recipe main [ - 1:boolean <- greater-than 36:literal, 35:literal, 35:literal + 1:boolean <- greater-than 36, 35, 35 ] +mem: storing 0 in location 1 @@ -141,29 +141,29 @@ case LESSER_THAN: { :(scenario lesser_than) recipe main [ - 1:number <- copy 32:literal - 2:number <- copy 33:literal + 1:number <- copy 32 + 2:number <- copy 33 3:boolean <- lesser-than 1:number, 2:number ] +mem: storing 1 in location 3 :(scenario lesser_than2) recipe main [ - 1:number <- copy 34:literal - 2:number <- copy 33:literal + 1:number <- copy 34 + 2:number <- copy 33 3:boolean <- lesser-than 1:number, 2:number ] +mem: storing 0 in location 3 :(scenario lesser_than_multiple) recipe main [ - 1:boolean <- lesser-than 34:literal, 35:literal, 36:literal + 1:boolean <- lesser-than 34, 35, 36 ] +mem: storing 1 in location 1 :(scenario lesser_than_multiple2) recipe main [ - 1:boolean <- lesser-than 34:literal, 35:literal, 35:literal + 1:boolean <- lesser-than 34, 35, 35 ] +mem: storing 0 in location 1 @@ -197,37 +197,37 @@ case GREATER_OR_EQUAL: { :(scenario greater_or_equal) recipe main [ - 1:number <- copy 34:literal - 2:number <- copy 33:literal + 1:number <- copy 34 + 2:number <- copy 33 3:boolean <- greater-or-equal 1:number, 2:number ] +mem: storing 1 in location 3 :(scenario greater_or_equal2) recipe main [ - 1:number <- copy 34:literal - 2:number <- copy 34:literal + 1:number <- copy 34 + 2:number <- copy 34 3:boolean <- greater-or-equal 1:number, 2:number ] +mem: storing 1 in location 3 :(scenario greater_or_equal3) recipe main [ - 1:number <- copy 34:literal - 2:number <- copy 35:literal + 1:number <- copy 34 + 2:number <- copy 35 3:boolean <- greater-or-equal 1:number, 2:number ] +mem: storing 0 in location 3 :(scenario greater_or_equal_multiple) recipe main [ - 1:boolean <- greater-or-equal 36:literal, 35:literal, 35:literal + 1:boolean <- greater-or-equal 36, 35, 35 ] +mem: storing 1 in location 1 :(scenario greater_or_equal_multiple2) recipe main [ - 1:boolean <- greater-or-equal 36:literal, 35:literal, 36:literal + 1:boolean <- greater-or-equal 36, 35, 36 ] +mem: storing 0 in location 1 @@ -261,36 +261,36 @@ case LESSER_OR_EQUAL: { :(scenario lesser_or_equal) recipe main [ - 1:number <- copy 32:literal - 2:number <- copy 33:literal + 1:number <- copy 32 + 2:number <- copy 33 3:boolean <- lesser-or-equal 1:number, 2:number ] +mem: storing 1 in location 3 :(scenario lesser_or_equal2) recipe main [ - 1:number <- copy 33:literal - 2:number <- copy 33:literal + 1:number <- copy 33 + 2:number <- copy 33 3:boolean <- lesser-or-equal 1:number, 2:number ] +mem: storing 1 in location 3 :(scenario lesser_or_equal3) recipe main [ - 1:number <- copy 34:literal - 2:number <- copy 33:literal + 1:number <- copy 34 + 2:number <- copy 33 3:boolean <- lesser-or-equal 1:number, 2:number ] +mem: storing 0 in location 3 :(scenario lesser_or_equal_multiple) recipe main [ - 1:boolean <- lesser-or-equal 34:literal, 35:literal, 35:literal + 1:boolean <- lesser-or-equal 34, 35, 35 ] +mem: storing 1 in location 1 :(scenario lesser_or_equal_multiple2) recipe main [ - 1:boolean <- lesser-or-equal 34:literal, 35:literal, 34:literal + 1:boolean <- lesser-or-equal 34, 35, 34 ] +mem: storing 0 in location 1 diff --git a/029tools.cc b/029tools.cc index 8285969e..02d1f555 100644 --- a/029tools.cc +++ b/029tools.cc @@ -111,7 +111,7 @@ case _CLEAR_TRACE: { :(scenario assert) % Hide_warnings = true; // '%' lines insert arbitrary C code into tests before calling 'run' with the lines below. Must be immediately after :(scenario) line. recipe main [ - assert 0:literal, [this is an assert in mu] + assert 0, [this is an assert in mu] ] +warn: this is an assert in mu diff --git a/030container.cc b/030container.cc index 76f05d05..46314d00 100644 --- a/030container.cc +++ b/030container.cc @@ -19,8 +19,8 @@ Type[point].elements.push_back(i); //: avoid warnings. :(scenario copy_multiple_locations) recipe main [ - 1:number <- copy 34:literal - 2:number <- copy 35:literal + 1:number <- copy 34 + 2:number <- copy 35 3:point <- copy 1:point/raw # unsafe ] +mem: storing 34 in location 3 @@ -42,9 +42,9 @@ Type[point_number].elements.push_back(i2); :(scenario copy_handles_nested_container_elements) recipe main [ - 12:number <- copy 34:literal - 13:number <- copy 35:literal - 14:number <- copy 36:literal + 12:number <- copy 34 + 13:number <- copy 35 + 14:number <- copy 36 15:point-number <- copy 12:point-number/raw # unsafe ] +mem: storing 36 in location 17 @@ -54,24 +54,24 @@ recipe main [ :(scenario compare_multiple_locations) recipe main [ - 1:number <- copy 34:literal # first - 2:number <- copy 35:literal - 3:number <- copy 36:literal - 4:number <- copy 34:literal # second - 5:number <- copy 35:literal - 6:number <- copy 36:literal + 1:number <- copy 34 # first + 2:number <- copy 35 + 3:number <- copy 36 + 4:number <- copy 34 # second + 5:number <- copy 35 + 6:number <- copy 36 7:boolean <- equal 1:point-number/raw, 4:point-number/raw # unsafe ] +mem: storing 1 in location 7 :(scenario compare_multiple_locations2) recipe main [ - 1:number <- copy 34:literal # first - 2:number <- copy 35:literal - 3:number <- copy 36:literal - 4:number <- copy 34:literal # second - 5:number <- copy 35:literal - 6:number <- copy 37:literal # different + 1:number <- copy 34 # first + 2:number <- copy 35 + 3:number <- copy 36 + 4:number <- copy 34 # second + 5:number <- copy 35 + 6:number <- copy 37 # different 7:boolean <- equal 1:point-number/raw, 4:point-number/raw # unsafe ] +mem: storing 0 in location 7 @@ -95,8 +95,8 @@ if (t.kind == container) { //:: To access elements of a container, use 'get' :(scenario get) recipe main [ - 12:number <- copy 34:literal - 13:number <- copy 35:literal + 12:number <- copy 34 + 13:number <- copy 35 15:number <- get 12:point/raw, 1:offset # unsafe ] +mem: storing 35 in location 15 @@ -145,9 +145,9 @@ case GET: { :(scenario get_handles_nested_container_elements) recipe main [ - 12:number <- copy 34:literal - 13:number <- copy 35:literal - 14:number <- copy 36:literal + 12:number <- copy 34 + 13:number <- copy 35 + 14:number <- copy 36 15:number <- get 12:point-number/raw, 1:offset # unsafe ] +mem: storing 36 in location 15 @@ -156,8 +156,8 @@ recipe main [ :(scenario get_address) recipe main [ - 12:number <- copy 34:literal - 13:number <- copy 35:literal + 12:number <- copy 34 + 13:number <- copy 35 15:address:number <- get-address 12:point/raw, 1:offset # unsafe ] +mem: storing 13 in location 15 @@ -165,9 +165,9 @@ recipe main [ :(scenario get_out_of_bounds) % Hide_warnings = true; recipe main [ - 12:number <- copy 34:literal - 13:number <- copy 35:literal - 14:number <- copy 36:literal + 12:number <- copy 34 + 13:number <- copy 35 + 14:number <- copy 36 get 12:point-number/raw, 2:offset # point-number occupies 3 locations but has only 2 fields; out of bounds ] +warn: main: invalid offset 2 for point-number @@ -175,9 +175,9 @@ recipe main [ :(scenario get_out_of_bounds2) % Hide_warnings = true; recipe main [ - 12:number <- copy 34:literal - 13:number <- copy 35:literal - 14:number <- copy 36:literal + 12:number <- copy 34 + 13:number <- copy 35 + 14:number <- copy 36 get 12:point-number/raw, -1:offset ] +warn: main: invalid offset -1 for point-number @@ -219,9 +219,9 @@ case GET_ADDRESS: { :(scenario get_address_out_of_bounds) % Hide_warnings = true; recipe main [ - 12:number <- copy 34:literal - 13:number <- copy 35:literal - 14:number <- copy 36:literal + 12:number <- copy 34 + 13:number <- copy 35 + 14:number <- copy 36 get-address 12:point-number/raw, 2:offset # point-number occupies 3 locations but has only 2 fields; out of bounds ] +warn: invalid offset 2 for point-number @@ -229,9 +229,9 @@ recipe main [ :(scenario get_address_out_of_bounds2) % Hide_warnings = true; recipe main [ - 12:number <- copy 34:literal - 13:number <- copy 35:literal - 14:number <- copy 36:literal + 12:number <- copy 34 + 13:number <- copy 35 + 14:number <- copy 36 get-address 12:point-number/raw, -1:offset ] +warn: invalid offset -1 for point-number @@ -359,14 +359,14 @@ Next_type_ordinal = 1000; #? % Trace_stream->dump_layer = "run"; recipe main [ # integer is not a type - 1:integer <- copy 0:literal + 1:integer <- copy 0 ] +warn: unknown type: integer :(scenario run_allows_type_definition_after_use) % Hide_warnings = true; recipe main [ - 1:bar <- copy 0:literal + 1:bar <- copy 0 ] container bar [ @@ -459,7 +459,7 @@ container foo [ ] recipe main [ - 1:foo <- merge 3:literal, 4:literal + 1:foo <- merge 3, 4 ] +mem: storing 3 in location 1 +mem: storing 4 in location 2 diff --git a/031address.cc b/031address.cc index 71f29522..657b7459 100644 --- a/031address.cc +++ b/031address.cc @@ -3,8 +3,8 @@ :(scenario copy_indirect) recipe main [ - 1:address:number <- copy 2:literal - 2:number <- copy 34:literal + 1:address:number <- copy 2 + 2:number <- copy 34 # This loads location 1 as an address and looks up *that* location. 3:number <- copy 1:address:number/deref ] @@ -17,8 +17,8 @@ x = canonize(x); //: 'deref' property :(scenario store_indirect) recipe main [ - 1:address:number <- copy 2:literal - 1:address:number/deref <- copy 34:literal + 1:address:number <- copy 2 + 1:address:number/deref <- copy 34 ] +mem: storing 34 in location 2 @@ -72,18 +72,18 @@ reagent deref(reagent x) { //:: 'get' can read from container address :(scenario get_indirect) recipe main [ - 1:number <- copy 2:literal - 2:number <- copy 34:literal - 3:number <- copy 35:literal + 1:number <- copy 2 + 2:number <- copy 34 + 3:number <- copy 35 4:number <- get 1:address:point/deref, 0:offset ] +mem: storing 34 in location 4 :(scenario include_nonderef_properties) recipe main [ - 1:number <- copy 2:literal - 2:number <- copy 34:literal - 3:number <- copy 35:literal + 1:number <- copy 2 + 2:number <- copy 34 + 3:number <- copy 35 4:number <- get 1:address:point/deref/foo, 0:offset ] +mem: storing 34 in location 4 @@ -94,9 +94,9 @@ base = canonize(base); :(scenario get_address_indirect) # 'get' can read from container address recipe main [ - 1:number <- copy 2:literal - 2:number <- copy 34:literal - 3:number <- copy 35:literal + 1:number <- copy 2 + 2:number <- copy 34 + 3:number <- copy 35 4:number <- get-address 1:address:point/deref, 0:offset ] +mem: storing 2 in location 4 diff --git a/032array.cc b/032array.cc index a9274b49..e7bcd1c9 100644 --- a/032array.cc +++ b/032array.cc @@ -12,10 +12,10 @@ # Arrays can be copied around with a single instruction just like numbers, # no matter how large they are. recipe main [ - 1:number <- copy 3:literal # length - 2:number <- copy 14:literal - 3:number <- copy 15:literal - 4:number <- copy 16:literal + 1:number <- copy 3 # length + 2:number <- copy 14 + 3:number <- copy 15 + 4:number <- copy 16 5:array:number <- copy 1:array:number/raw # unsafe ] +mem: storing 3 in location 5 @@ -25,11 +25,11 @@ recipe main [ :(scenario copy_array_indirect) recipe main [ - 1:number <- copy 3:literal # length - 2:number <- copy 14:literal - 3:number <- copy 15:literal - 4:number <- copy 16:literal - 5:address:array:number <- copy 1:literal + 1:number <- copy 3 # length + 2:number <- copy 14 + 3:number <- copy 15 + 4:number <- copy 16 + 5:address:array:number <- copy 1 6:array:number <- copy 5:address:array:number/deref ] +mem: storing 3 in location 6 @@ -54,21 +54,21 @@ if (x.types.at(0) == Type_ordinal["array"]) return false; :(scenario index) recipe main [ - 1:number <- copy 3:literal # length - 2:number <- copy 14:literal - 3:number <- copy 15:literal - 4:number <- copy 16:literal - 5:number <- index 1:array:number/raw, 0:literal # unsafe + 1:number <- copy 3 # length + 2:number <- copy 14 + 3:number <- copy 15 + 4:number <- copy 16 + 5:number <- index 1:array:number/raw, 0 # unsafe ] +mem: storing 14 in location 5 :(scenario index_direct_offset) recipe main [ - 1:number <- copy 3:literal # length - 2:number <- copy 14:literal - 3:number <- copy 15:literal - 4:number <- copy 16:literal - 5:number <- copy 0:literal + 1:number <- copy 3 # length + 2:number <- copy 14 + 3:number <- copy 15 + 4:number <- copy 16 + 5:number <- copy 0 6:number <- index 1:array:number/raw, 5:number # unsafe ] +mem: storing 14 in location 6 @@ -114,42 +114,42 @@ vector<type_ordinal> array_element(const vector<type_ordinal>& types) { :(scenario index_indirect) recipe main [ - 1:number <- copy 3:literal # length - 2:number <- copy 14:literal - 3:number <- copy 15:literal - 4:number <- copy 16:literal - 5:address:array:number <- copy 1:literal - 6:number <- index 5:address:array:number/deref, 1:literal + 1:number <- copy 3 # length + 2:number <- copy 14 + 3:number <- copy 15 + 4:number <- copy 16 + 5:address:array:number <- copy 1 + 6:number <- index 5:address:array:number/deref, 1 ] +mem: storing 15 in location 6 :(scenario index_out_of_bounds) % Hide_warnings = true; recipe main [ - 1:number <- copy 3:literal # 3 points - 2:number <- copy 14:literal - 3:number <- copy 15:literal - 4:number <- copy 16:literal - 5:number <- copy 14:literal - 6:number <- copy 15:literal - 7:number <- copy 16:literal - 8:address:array:point <- copy 1:literal - index 8:address:array:point/deref, 4:literal # less than size of array in locations, but larger than its length in elements + 1:number <- copy 3 # 3 points + 2:number <- copy 14 + 3:number <- copy 15 + 4:number <- copy 16 + 5:number <- copy 14 + 6:number <- copy 15 + 7:number <- copy 16 + 8:address:array:point <- copy 1 + index 8:address:array:point/deref, 4 # less than size of array in locations, but larger than its length in elements ] +warn: main: invalid index 4 :(scenario index_out_of_bounds2) % Hide_warnings = true; recipe main [ - 1:number <- copy 3:literal # 3 points - 2:number <- copy 14:literal - 3:number <- copy 15:literal - 4:number <- copy 16:literal - 5:number <- copy 14:literal - 6:number <- copy 15:literal - 7:number <- copy 16:literal - 8:address:array:point <- copy 1:literal - index 8:address:array:point/deref, -1:literal + 1:number <- copy 3 # 3 points + 2:number <- copy 14 + 3:number <- copy 15 + 4:number <- copy 16 + 5:number <- copy 14 + 6:number <- copy 15 + 7:number <- copy 16 + 8:address:array:point <- copy 1 + index 8:address:array:point/deref, -1 ] +warn: main: invalid index -1 @@ -157,11 +157,11 @@ recipe main [ :(scenario index_address) recipe main [ - 1:number <- copy 3:literal # length - 2:number <- copy 14:literal - 3:number <- copy 15:literal - 4:number <- copy 16:literal - 5:number <- index-address 1:array:number/raw, 0:literal # unsafe + 1:number <- copy 3 # length + 2:number <- copy 14 + 3:number <- copy 15 + 4:number <- copy 16 + 5:number <- index-address 1:array:number/raw, 0 # unsafe ] +mem: storing 2 in location 5 @@ -198,30 +198,30 @@ case INDEX_ADDRESS: { :(scenario index_address_out_of_bounds) % Hide_warnings = true; recipe main [ - 1:number <- copy 3:literal # 3 points - 2:number <- copy 14:literal - 3:number <- copy 15:literal - 4:number <- copy 16:literal - 5:number <- copy 14:literal - 6:number <- copy 15:literal - 7:number <- copy 16:literal - 8:address:array:point <- copy 1:literal - index-address 8:address:array:point/deref, 4:literal # less than size of array in locations, but larger than its length in elements + 1:number <- copy 3 # 3 points + 2:number <- copy 14 + 3:number <- copy 15 + 4:number <- copy 16 + 5:number <- copy 14 + 6:number <- copy 15 + 7:number <- copy 16 + 8:address:array:point <- copy 1 + index-address 8:address:array:point/deref, 4 # less than size of array in locations, but larger than its length in elements ] +warn: main: invalid index 4 :(scenario index_address_out_of_bounds2) % Hide_warnings = true; recipe main [ - 1:number <- copy 3:literal # 3 points - 2:number <- copy 14:literal - 3:number <- copy 15:literal - 4:number <- copy 16:literal - 5:number <- copy 14:literal - 6:number <- copy 15:literal - 7:number <- copy 16:literal - 8:address:array:point <- copy 1:literal - index-address 8:address:array:point/deref, -1:literal + 1:number <- copy 3 # 3 points + 2:number <- copy 14 + 3:number <- copy 15 + 4:number <- copy 16 + 5:number <- copy 14 + 6:number <- copy 15 + 7:number <- copy 16 + 8:address:array:point <- copy 1 + index-address 8:address:array:point/deref, -1 ] +warn: main: invalid index -1 @@ -229,10 +229,10 @@ recipe main [ :(scenario array_length) recipe main [ - 1:number <- copy 3:literal # length - 2:number <- copy 14:literal - 3:number <- copy 15:literal - 4:number <- copy 16:literal + 1:number <- copy 3 # length + 2:number <- copy 14 + 3:number <- copy 15 + 4:number <- copy 16 5:number <- length 1:array:number/raw # unsafe ] +mem: storing 3 in location 5 diff --git a/033exclusive_container.cc b/033exclusive_container.cc index 804d649f..3893d46f 100644 --- a/033exclusive_container.cc +++ b/033exclusive_container.cc @@ -27,9 +27,9 @@ Type[tmp].element_names.push_back("p"); :(scenario copy_exclusive_container) # Copying exclusive containers copies all their contents and an extra location for the tag. recipe main [ - 1:number <- copy 1:literal # 'point' variant - 2:number <- copy 34:literal - 3:number <- copy 35:literal + 1:number <- copy 1 # 'point' variant + 2:number <- copy 34 + 3:number <- copy 35 4:number-or-point <- copy 1:number-or-point/raw # unsafe ] +mem: storing 1 in location 4 @@ -61,18 +61,18 @@ Type_ordinal["variant"] = 0; :(scenario maybe_convert) recipe main [ - 12:number <- copy 1:literal - 13:number <- copy 35:literal - 14:number <- copy 36:literal + 12:number <- copy 1 + 13:number <- copy 35 + 14:number <- copy 36 20:address:point <- maybe-convert 12:number-or-point/raw, 1:variant # unsafe ] +mem: storing 13 in location 20 :(scenario maybe_convert_fail) recipe main [ - 12:number <- copy 1:literal - 13:number <- copy 35:literal - 14:number <- copy 36:literal + 12:number <- copy 1 + 13:number <- copy 35 + 14:number <- copy 36 20:address:point <- maybe-convert 12:number-or-point/raw, 0:variant # unsafe ] +mem: storing 0 in location 20 @@ -137,9 +137,9 @@ exclusive-container foo [ ] recipe main [ - 1:number <- copy 34:literal - 2:foo <- merge 0:literal/x, 1:number - 4:foo <- merge 1:literal/x, 1:number + 1:number <- copy 34 + 2:foo <- merge 0/x, 1:number + 4:foo <- merge 1/x, 1:number ] +mem: storing 0 in location 2 +mem: storing 34 in location 3 diff --git a/034call.cc b/034call.cc index 0a8a940b..498dc1a5 100644 --- a/034call.cc +++ b/034call.cc @@ -5,29 +5,29 @@ recipe main [ f ] recipe f [ - 3:number <- add 2:literal, 2:literal + 3:number <- add 2, 2 ] +mem: storing 4 in location 3 :(scenario return_on_fallthrough) recipe main [ f - 1:number <- copy 0:literal - 2:number <- copy 0:literal - 3:number <- copy 0:literal + 1:number <- copy 0 + 2:number <- copy 0 + 3:number <- copy 0 ] recipe f [ - 4:number <- copy 0:literal - 5:number <- copy 0:literal + 4:number <- copy 0 + 5:number <- copy 0 ] +run: f # running f -+run: 4:number <- copy 0:literal -+run: 5:number <- copy 0:literal ++run: 4:number <- copy 0 ++run: 5:number <- copy 0 # back out to main -+run: 1:number <- copy 0:literal -+run: 2:number <- copy 0:literal -+run: 3:number <- copy 0:literal ++run: 1:number <- copy 0 ++run: 2:number <- copy 0 ++run: 3:number <- copy 0 :(before "struct routine {") // Everytime a recipe runs another, we interrupt it and start running the new diff --git a/035call_ingredient.cc b/035call_ingredient.cc index 7ffa1207..599906da 100644 --- a/035call_ingredient.cc +++ b/035call_ingredient.cc @@ -3,11 +3,11 @@ :(scenario next_ingredient) recipe main [ - f 2:literal + f 2 ] recipe f [ 12:number <- next-ingredient - 13:number <- add 1:literal, 12:number + 13:number <- add 1, 12:number ] +mem: storing 3 in location 13 @@ -59,7 +59,7 @@ case NEXT_INGREDIENT: { :(scenario rewind_ingredients) recipe main [ - f 2:literal + f 2 ] recipe f [ 12:number <- next-ingredient # consume ingredient @@ -84,10 +84,10 @@ case REWIND_INGREDIENTS: { :(scenario ingredient) recipe main [ - f 1:literal, 2:literal + f 1, 2 ] recipe f [ - 12:number <- ingredient 1:literal # consume second ingredient first + 12:number <- ingredient 1 # consume second ingredient first 13:number, 1:boolean <- next-ingredient # next-ingredient tries to scan past that ] +mem: storing 2 in location 12 diff --git a/036call_reply.cc b/036call_reply.cc index a5f265a2..9a1a9b7e 100644 --- a/036call_reply.cc +++ b/036call_reply.cc @@ -2,11 +2,11 @@ :(scenario reply) recipe main [ - 1:number, 2:number <- f 34:literal + 1:number, 2:number <- f 34 ] recipe f [ 12:number <- next-ingredient - 13:number <- add 1:literal, 12:number + 13:number <- add 1, 12:number reply 12:number, 13:number ] +mem: storing 34 in location 1 @@ -55,11 +55,11 @@ case REPLY: { //: Products can include containers and exclusive containers, addresses and arrays. :(scenario reply_container) recipe main [ - 3:point <- f 2:literal + 3:point <- f 2 ] recipe f [ 12:number <- next-ingredient - 13:number <- copy 35:literal + 13:number <- copy 35 reply 12:point/raw # unsafe ] +run: result 0 is [2, 35] @@ -74,7 +74,7 @@ recipe f [ :(scenario reply_same_as_ingredient) % Hide_warnings = true; recipe main [ - 1:number <- copy 0:literal + 1:number <- copy 0 2:number <- test1 1:number # call with different ingredient and product ] recipe test1 [ @@ -86,7 +86,7 @@ recipe test1 [ :(scenario reply_same_as_ingredient_dummy) % Hide_warnings = true; recipe main [ - 1:number <- copy 0:literal + 1:number <- copy 0 _ <- test1 1:number # call with different ingredient and product ] recipe test1 [ @@ -119,8 +119,8 @@ recipe main [ 1:number <- test1 ] recipe test1 [ - reply-if 0:literal, 34:literal - reply 35:literal + reply-if 0, 34 + reply 35 ] +mem: storing 35 in location 1 @@ -129,8 +129,8 @@ recipe main [ 1:number <- test1 ] recipe test1 [ - reply-if 1:literal, 34:literal - reply 35:literal + reply-if 1, 34 + reply 35 ] +mem: storing 34 in location 1 diff --git a/037recipe.cc b/037recipe.cc index 41c688f5..e342f98f 100644 --- a/037recipe.cc +++ b/037recipe.cc @@ -4,7 +4,7 @@ :(scenario call_literal_recipe) recipe main [ - 1:number <- call f:recipe, 34:literal + 1:number <- call f:recipe, 34 ] recipe f [ 2:number <- next-ingredient @@ -15,7 +15,7 @@ recipe f [ :(scenario call_variable) recipe main [ 1:recipe-ordinal <- copy f:recipe - 2:number <- call 1:recipe-ordinal, 34:literal + 2:number <- call 1:recipe-ordinal, 34 ] recipe f [ 3:number <- next-ingredient diff --git a/038scheduler.cc b/038scheduler.cc index b0d489d5..d32fb76a 100644 --- a/038scheduler.cc +++ b/038scheduler.cc @@ -6,11 +6,11 @@ recipe f1 [ start-running f2:recipe # wait for f2 to run { - jump-unless 1:number, -1:literal + jump-unless 1:number, -1 } ] recipe f2 [ - 1:number <- copy 1:literal + 1:number <- copy 1 ] +schedule: f1 +schedule: f2 @@ -144,47 +144,47 @@ case START_RUNNING: { :(scenario scheduler_runs_single_routine) % Scheduling_interval = 1; recipe f1 [ - 1:number <- copy 0:literal - 2:number <- copy 0:literal + 1:number <- copy 0 + 2:number <- copy 0 ] +schedule: f1 -+run: 1:number <- copy 0:literal ++run: 1:number <- copy 0 +schedule: f1 -+run: 2:number <- copy 0:literal ++run: 2:number <- copy 0 :(scenario scheduler_interleaves_routines) % Scheduling_interval = 1; recipe f1 [ start-running f2:recipe - 1:number <- copy 0:literal - 2:number <- copy 0:literal + 1:number <- copy 0 + 2:number <- copy 0 ] recipe f2 [ - 3:number <- copy 0:literal - 4:number <- copy 0:literal + 3:number <- copy 0 + 4:number <- copy 0 ] +schedule: f1 +run: start-running f2:recipe +schedule: f2 -+run: 3:number <- copy 0:literal ++run: 3:number <- copy 0 +schedule: f1 -+run: 1:number <- copy 0:literal ++run: 1:number <- copy 0 +schedule: f2 -+run: 4:number <- copy 0:literal ++run: 4:number <- copy 0 +schedule: f1 -+run: 2:number <- copy 0:literal ++run: 2:number <- copy 0 :(scenario start_running_takes_args) recipe f1 [ - start-running f2:recipe, 3:literal + start-running f2:recipe, 3 # wait for f2 to run { - jump-unless 1:number, -1:literal + jump-unless 1:number, -1 } ] recipe f2 [ 1:number <- next-ingredient - 2:number <- add 1:number, 1:literal + 2:number <- add 1:number, 1 ] +mem: storing 4 in location 2 @@ -193,22 +193,22 @@ recipe f1 [ 1:number <- start-running f2:recipe ] recipe f2 [ - 12:number <- copy 44:literal + 12:number <- copy 44 ] +mem: storing 2 in location 1 //: this scenario will require some careful setup in escaped C++ //: (straining our tangle capabilities to near-breaking point) :(scenario scheduler_skips_completed_routines) -% recipe_ordinal f1 = load("recipe f1 [\n1:number <- copy 0:literal\n]").front(); -% recipe_ordinal f2 = load("recipe f2 [\n2:number <- copy 0:literal\n]").front(); +% recipe_ordinal f1 = load("recipe f1 [\n1:number <- copy 0\n]").front(); +% recipe_ordinal f2 = load("recipe f2 [\n2:number <- copy 0\n]").front(); % Routines.push_back(new routine(f1)); // f1 meant to run % Routines.push_back(new routine(f2)); % Routines.back()->state = COMPLETED; // f2 not meant to run #? % Trace_stream->dump_layer = "all"; # must have at least one routine without escaping recipe f3 [ - 3:number <- copy 0:literal + 3:number <- copy 0 ] # by interleaving '+' lines with '-' lines, we allow f1 and f3 to run in any order +schedule: f1 @@ -222,8 +222,8 @@ recipe f3 [ % Routines.push_back(new routine(COPY)); % Routines.back()->state = COMPLETED; recipe f1 [ - 1:number <- copy 0:literal - 2:number <- copy 0:literal + 1:number <- copy 0 + 2:number <- copy 0 ] +schedule: f1 -run: idle @@ -236,7 +236,7 @@ recipe main [ # f1 never actually runs because its parent completes without waiting for it ] recipe f1 [ - 1:number <- copy 0:literal + 1:number <- copy 0 ] -schedule: f1 @@ -264,12 +264,12 @@ bool has_completed_parent(long long int routine_index) { % Scheduling_interval = 2; recipe f1 [ 1:number/child-id <- start-running f2:recipe - 12:number <- copy 0:literal # race condition since we don't care about location 12 + 12:number <- copy 0 # race condition since we don't care about location 12 # thanks to Scheduling_interval, f2's one instruction runs in between here and completes 2:number/state <- routine-state 1:number/child-id ] recipe f2 [ - 12:number <- copy 0:literal + 12:number <- copy 0 # trying to run a second instruction marks routine as completed ] # recipe f2 should be in state COMPLETED diff --git a/039wait.cc b/039wait.cc index 5b589d6a..43efa8cf 100644 --- a/039wait.cc +++ b/039wait.cc @@ -5,14 +5,14 @@ :(scenario wait_for_location) recipe f1 [ - 1:number <- copy 0:literal + 1:number <- copy 0 start-running f2:recipe wait-for-location 1:number # now wait for f2 to run and modify location 1 before using its value 2:number <- copy 1:number ] recipe f2 [ - 1:number <- copy 34:literal + 1:number <- copy 34 ] # if we got the synchronization wrong we'd be storing 0 in location 2 +mem: storing 34 in location 2 @@ -61,14 +61,14 @@ for (long long int i = 0; i < SIZE(Routines); ++i) { :(scenario wait_for_routine) recipe f1 [ - 1:number <- copy 0:literal + 1:number <- copy 0 12:number/routine <- start-running f2:recipe wait-for-routine 12:number/routine # now wait for f2 to run and modify location 1 before using its value 3:number <- copy 1:number ] recipe f2 [ - 1:number <- copy 34:literal + 1:number <- copy 34 ] +schedule: f1 +run: waiting for routine 2 diff --git a/040brace.cc b/040brace.cc index d8ed387e..dcacdace 100644 --- a/040brace.cc +++ b/040brace.cc @@ -24,7 +24,7 @@ recipe main [ { break - 1:number <- copy 0:literal + 1:number <- copy 0 } ] +after-brace: recipe main @@ -157,10 +157,10 @@ Recipe_ordinal["loop-unless"] = LOOP_UNLESS; :(scenario loop) recipe main [ - 1:number <- copy 0:literal - 2:number <- copy 0:literal + 1:number <- copy 0 + 2:number <- copy 0 { - 3:number <- copy 0:literal + 3:number <- copy 0 loop } ] @@ -172,7 +172,7 @@ recipe main [ :(scenario break_empty_block) recipe main [ - 1:number <- copy 0:literal + 1:number <- copy 0 { break } @@ -183,7 +183,7 @@ recipe main [ :(scenario break_cascading) recipe main [ - 1:number <- copy 0:literal + 1:number <- copy 0 { break } @@ -198,11 +198,11 @@ recipe main [ :(scenario break_cascading2) recipe main [ - 1:number <- copy 0:literal - 2:number <- copy 0:literal + 1:number <- copy 0 + 2:number <- copy 0 { break - 3:number <- copy 0:literal + 3:number <- copy 0 } { break @@ -217,11 +217,11 @@ recipe main [ :(scenario break_if) recipe main [ - 1:number <- copy 0:literal - 2:number <- copy 0:literal + 1:number <- copy 0 + 2:number <- copy 0 { break-if 2:number - 3:number <- copy 0:literal + 3:number <- copy 0 } { break @@ -236,36 +236,36 @@ recipe main [ :(scenario break_nested) recipe main [ - 1:number <- copy 0:literal + 1:number <- copy 0 { - 2:number <- copy 0:literal + 2:number <- copy 0 break { - 3:number <- copy 0:literal + 3:number <- copy 0 } - 4:number <- copy 0:literal + 4:number <- copy 0 } ] +after-brace: jump 4:offset :(scenario break_nested_degenerate) recipe main [ - 1:number <- copy 0:literal + 1:number <- copy 0 { - 2:number <- copy 0:literal + 2:number <- copy 0 break { } - 4:number <- copy 0:literal + 4:number <- copy 0 } ] +after-brace: jump 3:offset :(scenario break_nested_degenerate2) recipe main [ - 1:number <- copy 0:literal + 1:number <- copy 0 { - 2:number <- copy 0:literal + 2:number <- copy 0 break { } @@ -276,7 +276,7 @@ recipe main [ :(scenario break_label) % Hide_warnings = true; recipe main [ - 1:number <- copy 0:literal + 1:number <- copy 0 { break +foo:offset } @@ -285,11 +285,11 @@ recipe main [ :(scenario break_unless) recipe main [ - 1:number <- copy 0:literal - 2:number <- copy 0:literal + 1:number <- copy 0 + 2:number <- copy 0 { break-unless 2:number - 3:number <- copy 0:literal + 3:number <- copy 0 } ] +after-brace: recipe main @@ -300,11 +300,11 @@ recipe main [ :(scenario loop_unless) recipe main [ - 1:number <- copy 0:literal - 2:number <- copy 0:literal + 1:number <- copy 0 + 2:number <- copy 0 { loop-unless 2:number - 3:number <- copy 0:literal + 3:number <- copy 0 } ] +after-brace: recipe main @@ -315,14 +315,14 @@ recipe main [ :(scenario loop_nested) recipe main [ - 1:number <- copy 0:literal + 1:number <- copy 0 { - 2:number <- copy 0:literal + 2:number <- copy 0 { - 3:number <- copy 0:literal + 3:number <- copy 0 } loop-if 4:boolean - 5:number <- copy 0:literal + 5:number <- copy 0 } ] +after-brace: recipe main @@ -330,9 +330,9 @@ recipe main [ :(scenario loop_label) recipe main [ - 1:number <- copy 0:literal + 1:number <- copy 0 +foo - 2:number <- copy 0:literal + 2:number <- copy 0 ] +after-brace: recipe main +after-brace: copy ... @@ -343,14 +343,14 @@ recipe main [ :(scenario brace_conversion_and_run) #? % Trace_stream->dump_layer = "run"; recipe test-factorial [ - 1:number <- copy 5:literal - 2:number <- copy 1:literal + 1:number <- copy 5 + 2:number <- copy 1 { - 3:boolean <- equal 1:number, 1:literal + 3:boolean <- equal 1:number, 1 break-if 3:boolean # $print 1:number 2:number <- multiply 2:number, 1:number - 1:number <- subtract 1:number, 1:literal + 1:number <- subtract 1:number, 1 loop } 4:number <- copy 2:number # trigger a read diff --git a/041jump_label.cc b/041jump_label.cc index a24970d5..00a547e2 100644 --- a/041jump_label.cc +++ b/041jump_label.cc @@ -5,7 +5,7 @@ :(scenario jump_to_label) recipe main [ jump +target:label - 1:number <- copy 0:literal + 1:number <- copy 0 +target ] -mem: storing 0 in location 1 @@ -62,7 +62,7 @@ recipe main [ { { break +target:label - 1:number <- copy 0:literal + 1:number <- copy 0 } } +target @@ -73,8 +73,8 @@ recipe main [ recipe main [ { { - jump-if 1:literal, +target:label - 1:number <- copy 0:literal + jump-if 1, +target:label + 1:number <- copy 0 } } +target @@ -85,8 +85,8 @@ recipe main [ recipe main [ { { - loop-unless 0:literal, +target:label # loop/break with a label don't care about braces - 1:number <- copy 0:literal + loop-unless 0, +target:label # loop/break with a label don't care about braces + 1:number <- copy 0 } } +target @@ -96,13 +96,13 @@ recipe main [ :(scenario jump_runs_code_after_label) recipe main [ # first a few lines of padding to exercise the offset computation - 1:number <- copy 0:literal - 2:number <- copy 0:literal - 3:number <- copy 0:literal + 1:number <- copy 0 + 2:number <- copy 0 + 3:number <- copy 0 jump +target:label - 4:number <- copy 0:literal + 4:number <- copy 0 +target - 5:number <- copy 0:literal + 5:number <- copy 0 ] +mem: storing 0 in location 5 -mem: storing 0 in location 4 diff --git a/042name.cc b/042name.cc index 9e2d75b2..a12f6eaa 100644 --- a/042name.cc +++ b/042name.cc @@ -4,7 +4,7 @@ :(scenario convert_names) recipe main [ - x:number <- copy 0:literal + x:number <- copy 0 ] +name: assign x 1 +mem: storing 0 in location 1 @@ -149,7 +149,7 @@ bool is_special_name(const string& s) { :(scenario convert_names_passes_dummy) # _ is just a dummy result that never gets consumed recipe main [ - _, x:number <- copy 0:literal, 1:literal + _, x:number <- copy 0, 1 ] +name: assign x 1 -name: assign _ 1 @@ -157,7 +157,7 @@ recipe main [ //: an escape hatch to suppress name conversion that we'll use later :(scenario convert_names_passes_raw) recipe main [ - x:number/raw <- copy 0:literal + x:number/raw <- copy 0 ] -name: assign x 1 @@ -171,7 +171,7 @@ recipe main [ :(scenario convert_names_warns_when_mixing_names_and_numeric_locations2) % Hide_warnings = true; recipe main [ - x:number <- copy 1:literal + x:number <- copy 1 1:number <- copy x:number ] +warn: mixing variable names and numeric addresses in main @@ -187,7 +187,7 @@ $warn: 0 :(scenario convert_names_does_not_warn_when_mixing_names_and_literals) % Hide_warnings = true; recipe main [ - x:number <- copy 1:literal + x:number <- copy 1 ] -warn: mixing variable names and numeric addresses in main $warn: 0 @@ -195,8 +195,8 @@ $warn: 0 :(scenario convert_names_warns_on_reusing_name_with_different_type) % Hide_warnings = true; recipe main [ - x:number <- copy 1:literal - x:boolean <- copy 1:literal + x:number <- copy 1 + x:boolean <- copy 1 ] +warn: x used with multiple types in main @@ -208,7 +208,7 @@ Type[point].element_names.push_back("x"); Type[point].element_names.push_back("y"); :(scenario convert_names_transforms_container_elements) recipe main [ - p:address:point <- copy 0:literal # unsafe + p:address:point <- copy 0 # unsafe a:number <- get p:address:point/deref, y:offset b:number <- get p:address:point/deref, x:offset ] @@ -237,8 +237,8 @@ if (inst.operation == Recipe_ordinal["get"] :(scenarios transform) :(scenario convert_names_handles_containers) recipe main [ - a:point <- copy 0:literal - b:number <- copy 0:literal + a:point <- copy 0 + b:number <- copy 0 ] +name: assign a 1 +name: assign b 3 @@ -248,9 +248,9 @@ recipe main [ :(scenarios run) :(scenario maybe_convert_named) recipe main [ - 12:number <- copy 1:literal - 13:number <- copy 35:literal - 14:number <- copy 36:literal + 12:number <- copy 1 + 13:number <- copy 35 + 14:number <- copy 36 20:address:point <- maybe-convert 12:number-or-point/raw, p:variant # unsafe ] +name: variant p of type number-or-point has tag 1 diff --git a/043new.cc b/043new.cc index d72ca7ec..868910d5 100644 --- a/043new.cc +++ b/043new.cc @@ -139,22 +139,22 @@ recipe main [ :(scenario new_array) recipe main [ - 1:address:array:number/raw <- new number:type, 5:literal + 1:address:array:number/raw <- new number:type, 5 2:address:number/raw <- new number:type 3:number/raw <- subtract 2:address:number/raw, 1:address:array:number/raw ] -+run: 1:address:array:number/raw <- new number:type, 5:literal ++run: 1:address:array:number/raw <- new number:type, 5 +mem: array size is 5 # don't forget the extra location for array size +mem: storing 6 in location 3 :(scenario new_empty_array) recipe main [ - 1:address:array:number/raw <- new number:type, 0:literal + 1:address:array:number/raw <- new number:type, 0 2:address:number/raw <- new number:type 3:number/raw <- subtract 2:address:number/raw, 1:address:array:number/raw ] -+run: 1:address:array:number/raw <- new number:type, 0:literal ++run: 1:address:array:number/raw <- new number:type, 0 +mem: array size is 0 +mem: storing 1 in location 3 @@ -173,7 +173,7 @@ recipe f2 [ # hack: assumes scheduler implementation 3:boolean/raw <- equal 1:address:number/raw, 2:address:number/raw # signal f2 complete - 4:number/raw <- copy 1:literal + 4:number/raw <- copy 1 ] +mem: storing 0 in location 3 @@ -266,7 +266,7 @@ if (Free_list[size]) { recipe main [ 1:address:number <- new number:type abandon 1:address:number - 2:address:number <- new number:type, 2:literal # different size + 2:address:number <- new number:type, 2 # different size 3:boolean <- equal 1:address:number, 2:address:number ] # no reuse @@ -274,9 +274,9 @@ recipe main [ :(scenario new_reclaim_array) recipe main [ - 1:address:array:number <- new number:type, 2:literal + 1:address:array:number <- new number:type, 2 abandon 1:address:array:number - 2:address:array:number <- new number:type, 2:literal + 2:address:array:number <- new number:type, 2 3:boolean <- equal 1:address:array:number, 2:address:array:number ] # reuse @@ -287,7 +287,7 @@ recipe main [ :(scenario new_string) recipe main [ 1:address:array:character <- new [abc def] - 2:character <- index 1:address:array:character/deref, 5:literal + 2:character <- index 1:address:array:character/deref, 5 ] # number code for 'e' +mem: storing 101 in location 2 @@ -296,7 +296,7 @@ recipe main [ recipe main [ 1:address:array:character <- new [a«c] 2:number <- length 1:address:array:character/deref - 3:character <- index 1:address:array:character/deref, 1:literal + 3:character <- index 1:address:array:character/deref, 1 ] +mem: storing 3 in location 2 # unicode for '«' diff --git a/044space.cc b/044space.cc index 31fca4ec..69c36281 100644 --- a/044space.cc +++ b/044space.cc @@ -6,21 +6,21 @@ # if default-space is 10, and if an array of 5 locals lies from location 11 to 15 (inclusive), # then location 0 is really location 11, location 1 is really location 12, and so on. recipe main [ - 10:number <- copy 5:literal # pretend array; in practice we'll use new - default-space:address:array:location <- copy 10:literal - 1:number <- copy 23:literal + 10:number <- copy 5 # pretend array; in practice we'll use new + default-space:address:array:location <- copy 10 + 1:number <- copy 23 ] +mem: storing 23 in location 12 :(scenario deref_sidesteps_default_space) recipe main [ # pretend pointer from outside - 3:number <- copy 34:literal + 3:number <- copy 34 # pretend array - 1000:number <- copy 5:literal + 1000:number <- copy 5 # actual start of this recipe - default-space:address:array:location <- copy 1000:literal - 1:address:number <- copy 3:literal + default-space:address:array:location <- copy 1000 + 1:address:number <- copy 3 8:number/raw <- copy 1:address:number/deref ] +mem: storing 34 in location 8 @@ -28,7 +28,7 @@ recipe main [ //:: first disable name conversion for 'default-space' :(scenario convert_names_passes_default_space) recipe main [ - default-space:number, x:number <- copy 0:literal, 1:literal + default-space:number, x:number <- copy 0, 1 ] +name: assign x 1 -name: assign default-space 1 @@ -69,13 +69,13 @@ result.properties.push_back(pair<string, vector<string> >("raw", vector<string>( :(scenario deref_sidesteps_default_space_in_get) recipe main [ # pretend pointer to container from outside - 12:number <- copy 34:literal - 13:number <- copy 35:literal + 12:number <- copy 34 + 13:number <- copy 35 # pretend array - 1000:number <- copy 5:literal + 1000:number <- copy 5 # actual start of this recipe - default-space:address:array:location <- copy 1000:literal - 1:address:point <- copy 12:literal + default-space:address:array:location <- copy 1000 + 1:address:point <- copy 12 9:number/raw <- get 1:address:point/deref, 1:offset ] +mem: storing 35 in location 9 @@ -88,15 +88,15 @@ tmp.properties.push_back(pair<string, vector<string> >("raw", vector<string>())) :(scenario deref_sidesteps_default_space_in_index) recipe main [ # pretend pointer to array from outside - 12:number <- copy 2:literal - 13:number <- copy 34:literal - 14:number <- copy 35:literal + 12:number <- copy 2 + 13:number <- copy 34 + 14:number <- copy 35 # pretend array - 1000:number <- copy 5:literal + 1000:number <- copy 5 # actual start of this recipe - default-space:address:array:location <- copy 1000:literal - 1:address:array:number <- copy 12:literal - 9:number/raw <- index 1:address:array:number/deref, 1:literal + default-space:address:array:location <- copy 1000 + 1:address:array:number <- copy 12 + 9:number/raw <- index 1:address:array:number/deref, 1 ] +mem: storing 35 in location 9 @@ -109,8 +109,8 @@ tmp.properties.push_back(pair<string, vector<string> >("raw", vector<string>())) :(scenario new_default_space) recipe main [ new-default-space - x:number <- copy 0:literal - y:number <- copy 3:literal + x:number <- copy 0 + y:number <- copy 3 ] # allocate space for x and y, as well as the chaining slot at 0 +mem: array size is 3 @@ -153,7 +153,7 @@ recipe main [ ] recipe foo [ local-scope - x:number <- copy 34:literal + x:number <- copy 34 reply default-space:address:array:location ] # both calls to foo should have received the same default-space @@ -220,7 +220,7 @@ long long int address(long long int offset, long long int base) { :(scenario get_default_space) recipe main [ - default-space:address:array:location <- copy 10:literal + default-space:address:array:location <- copy 10 1:number/raw <- copy default-space:address:array:location ] +mem: storing 10 in location 1 diff --git a/045space_surround.cc b/045space_surround.cc index 1ab41c91..fee7ef71 100644 --- a/045space_surround.cc +++ b/045space_surround.cc @@ -7,12 +7,12 @@ :(scenario surrounding_space) # location 1 in space 1 refers to the space surrounding the default space, here 20. recipe main [ - 10:number <- copy 5:literal # pretend array - 20:number <- copy 5:literal # pretend array - default-space:address:array:location <- copy 10:literal - 0:address:array:location/names:dummy <- copy 20:literal # later layers will explain the /names: property - 1:number <- copy 32:literal - 1:number/space:1 <- copy 33:literal + 10:number <- copy 5 # pretend array + 20:number <- copy 5 # pretend array + default-space:address:array:location <- copy 10 + 0:address:array:location/names:dummy <- copy 20 # later layers will explain the /names: property + 1:number <- copy 32 + 1:number/space:1 <- copy 33 ] # chain space +mem: storing 20 in location 11 @@ -51,5 +51,5 @@ long long int space_index(const reagent& x) { :(scenario permit_space_as_variable_name) recipe main [ - space:number <- copy 0:literal + space:number <- copy 0 ] diff --git a/046closure_name.cc b/046closure_name.cc index dc2c4b61..35486ed7 100644 --- a/046closure_name.cc +++ b/046closure_name.cc @@ -5,24 +5,24 @@ :(scenario closure) recipe main [ - default-space:address:array:location <- new location:type, 30:literal + default-space:address:array:location <- new location:type, 30 1:address:array:location/names:new-counter <- new-counter 2:number/raw <- increment-counter 1:address:array:location/names:new-counter 3:number/raw <- increment-counter 1:address:array:location/names:new-counter ] recipe new-counter [ - default-space:address:array:location <- new location:type, 30:literal - x:number <- copy 23:literal - y:number <- copy 3:literal # variable that will be incremented + default-space:address:array:location <- new location:type, 30 + x:number <- copy 23 + y:number <- copy 3 # variable that will be incremented reply default-space:address:array:location ] recipe increment-counter [ - default-space:address:array:location <- new location:type, 30:literal + default-space:address:array:location <- new location:type, 30 0:address:array:location/names:new-counter <- next-ingredient # outer space must be created by 'new-counter' above - y:number/space:1 <- add y:number/space:1, 1:literal # increment - y:number <- copy 234:literal # dummy + y:number/space:1 <- add y:number/space:1, 1 # increment + y:number <- copy 234 # dummy reply y:number/space:1 ] diff --git a/047global.cc b/047global.cc index 39be9bc2..faa731c1 100644 --- a/047global.cc +++ b/047global.cc @@ -6,13 +6,13 @@ :(scenario global_space) recipe main [ # pretend arrays; in practice we'll use new - 10:number <- copy 5:literal - 20:number <- copy 5:literal + 10:number <- copy 5 + 20:number <- copy 5 # actual start of this recipe - global-space:address:array:location <- copy 20:literal - default-space:address:array:location <- copy 10:literal - 1:number <- copy 23:literal - 1:number/space:global <- copy 24:literal + global-space:address:array:location <- copy 20 + default-space:address:array:location <- copy 10 + 1:number <- copy 23 + 1:number/space:global <- copy 24 ] +mem: storing 23 in location 12 +mem: storing 24 in location 22 @@ -53,9 +53,9 @@ global_space = 0; :(scenario global_space_with_names) % Hide_warnings = true; recipe main [ - global-space:address:array:location <- new location:type, 10:literal - x:number <- copy 23:literal - 1:number/space:global <- copy 24:literal + global-space:address:array:location <- new location:type, 10 + x:number <- copy 23 + 1:number/space:global <- copy 24 ] # don't warn that we're mixing numeric addresses and names $warn: 0 diff --git a/048tangle.cc b/048tangle.cc index 0c4129f0..743d6945 100644 --- a/048tangle.cc +++ b/048tangle.cc @@ -4,13 +4,13 @@ :(scenario tangle_before) recipe main [ - 1:number <- copy 0:literal + 1:number <- copy 0 +label1 - 3:number <- copy 0:literal + 3:number <- copy 0 ] before +label1 [ - 2:number <- copy 0:literal + 2:number <- copy 0 ] +mem: storing 0 in location 1 +mem: storing 0 in location 2 @@ -70,15 +70,15 @@ void insert_fragments(const recipe_ordinal r) { :(scenario tangle_before_and_after) recipe main [ - 1:number <- copy 0:literal + 1:number <- copy 0 +label1 - 4:number <- copy 0:literal + 4:number <- copy 0 ] before +label1 [ - 2:number <- copy 0:literal + 2:number <- copy 0 ] after +label1 [ - 3:number <- copy 0:literal + 3:number <- copy 0 ] +mem: storing 0 in location 1 +mem: storing 0 in location 2 @@ -90,22 +90,22 @@ $mem: 4 :(scenario tangle_keeps_labels_separate) recipe main [ - 1:number <- copy 0:literal + 1:number <- copy 0 +label1 +label2 - 6:number <- copy 0:literal + 6:number <- copy 0 ] before +label1 [ - 2:number <- copy 0:literal + 2:number <- copy 0 ] after +label1 [ - 3:number <- copy 0:literal + 3:number <- copy 0 ] before +label2 [ - 4:number <- copy 0:literal + 4:number <- copy 0 ] after +label2 [ - 5:number <- copy 0:literal + 5:number <- copy 0 ] +mem: storing 0 in location 1 +mem: storing 0 in location 2 @@ -121,21 +121,21 @@ $mem: 6 :(scenario tangle_stacks_multiple_fragments) recipe main [ - 1:number <- copy 0:literal + 1:number <- copy 0 +label1 - 6:number <- copy 0:literal + 6:number <- copy 0 ] before +label1 [ - 2:number <- copy 0:literal + 2:number <- copy 0 ] after +label1 [ - 3:number <- copy 0:literal + 3:number <- copy 0 ] before +label1 [ - 4:number <- copy 0:literal + 4:number <- copy 0 ] after +label1 [ - 5:number <- copy 0:literal + 5:number <- copy 0 ] +mem: storing 0 in location 1 # 'before' fragments stack in order @@ -151,17 +151,17 @@ $mem: 6 :(scenario tangle_supports_fragments_with_multiple_instructions) recipe main [ - 1:number <- copy 0:literal + 1:number <- copy 0 +label1 - 6:number <- copy 0:literal + 6:number <- copy 0 ] before +label1 [ - 2:number <- copy 0:literal - 3:number <- copy 0:literal + 2:number <- copy 0 + 3:number <- copy 0 ] after +label1 [ - 4:number <- copy 0:literal - 5:number <- copy 0:literal + 4:number <- copy 0 + 5:number <- copy 0 ] +mem: storing 0 in location 1 +mem: storing 0 in location 2 @@ -175,16 +175,16 @@ $mem: 6 :(scenario tangle_tangles_into_all_labels_with_same_name) recipe main [ - 1:number <- copy 0:literal + 1:number <- copy 0 +label1 +label1 - 4:number <- copy 0:literal + 4:number <- copy 0 ] before +label1 [ - 2:number <- copy 0:literal + 2:number <- copy 0 ] after +label1 [ - 3:number <- copy 0:literal + 3:number <- copy 0 ] +mem: storing 0 in location 1 +mem: storing 0 in location 2 diff --git a/049continuation.cc b/049continuation.cc index c79db298..20cf1b05 100644 --- a/049continuation.cc +++ b/049continuation.cc @@ -52,13 +52,13 @@ case CONTINUE_FROM: { :(scenario continuation) # simulate a loop using continuations recipe main [ - 1:number <- copy 0:literal + 1:number <- copy 0 2:continuation <- current-continuation { #? $print 1:number - 3:boolean <- greater-or-equal 1:number, 3:literal + 3:boolean <- greater-or-equal 1:number, 3 break-if 3:boolean - 1:number <- add 1:number, 1:literal + 1:number <- add 1:number, 1 continue-from 2:continuation # loop } ] @@ -72,10 +72,10 @@ $current-continuation: 1 :(scenario continuation_inside_caller) #? % Trace_stream->dump_layer = "all"; #? 1 recipe main [ - 1:number <- copy 0:literal + 1:number <- copy 0 2:continuation <- loop-body { - 3:boolean <- greater-or-equal 1:number, 3:literal + 3:boolean <- greater-or-equal 1:number, 3 break-if 3:boolean continue-from 2:continuation # loop } @@ -83,7 +83,7 @@ recipe main [ recipe loop-body [ 4:continuation <- current-continuation - 1:number <- add 1:number, 1:literal + 1:number <- add 1:number, 1 ] +mem: storing 1 in location 1 +mem: storing 2 in location 1 @@ -106,11 +106,11 @@ recipe loop-body [ :(scenario delimited_continuation) recipe main [ - 1:continuation <- create-delimited-continuation f:recipe 12:literal # 12 is an argument to f - 2:number <- copy 5:literal + 1:continuation <- create-delimited-continuation f:recipe 12 # 12 is an argument to f + 2:number <- copy 5 { 2:number <- call 1:continuation, 2:number # 2 is an argument to g, the 'top' of the continuation - 3:boolean <- greater-or-equal 2:number, 8:literal + 3:boolean <- greater-or-equal 2:number, 8 break-if 3:boolean loop } @@ -128,13 +128,13 @@ recipe g [ reply-delimited-continuation # calls of the continuation start from here 22:number <- next-ingredient - 23:number <- add 22:number, 1:literal + 23:number <- add 22:number, 1 reply 23:number ] #? ? # first call of 'g' executes the part before reply-delimited-continuation +mem: storing 12 in location 21 -+run: 2:number <- copy 5:literal ++run: 2:number <- copy 5 +mem: storing 5 in location 2 # calls of the continuation execute the part after reply-delimited-continuation +run: 2:number <- call 1:continuation, 2:number diff --git a/050scenario.cc b/050scenario.cc index a0d72615..e35ab0cb 100644 --- a/050scenario.cc +++ b/050scenario.cc @@ -8,7 +8,7 @@ :(scenario scenario_block) scenario foo [ run [ - 1:number <- copy 13:literal + 1:number <- copy 13 ] memory-should-contain [ 1 <- 13 @@ -19,13 +19,13 @@ scenario foo [ :(scenario scenario_multiple_blocks) scenario foo [ run [ - 1:number <- copy 13:literal + 1:number <- copy 13 ] memory-should-contain [ 1 <- 13 ] run [ - 2:number <- copy 13:literal + 2:number <- copy 13 ] memory-should-contain [ 1 <- 13 @@ -36,7 +36,7 @@ scenario foo [ :(scenario scenario_check_memory_and_trace) scenario foo [ run [ - 1:number <- copy 13:literal + 1:number <- copy 13 trace [a], [a b c] ] memory-should-contain [ @@ -92,9 +92,9 @@ scenario parse_scenario(istream& in) { :(scenario read_scenario_with_bracket_in_comment) scenario foo [ # ']' in comment - 1:number <- copy 0:literal + 1:number <- copy 0 ] -+run: 1:number <- copy 0:literal ++run: 1:number <- copy 0 :(scenario read_scenario_with_bracket_in_comment_in_nested_string) scenario foo [ @@ -161,11 +161,11 @@ void run_mu_scenario(const scenario& s) { % Hide_warnings = true; % Disable_redefine_warnings = true; recipe scenario-foo [ - 1:number <- copy 34:literal + 1:number <- copy 34 ] recipe scenario-foo [ - 1:number <- copy 35:literal + 1:number <- copy 35 ] +warn: redefining recipe scenario-foo @@ -181,7 +181,7 @@ if (recipe_name.find("scenario-") == 0) return true; #? % Trace_stream->dump_layer = "all"; recipe main [ run [ - 1:number <- copy 13:literal + 1:number <- copy 13 ] ] +mem: storing 13 in location 1 @@ -215,10 +215,10 @@ void bind_special_scenario_names(recipe_ordinal r) { :(scenario run_multiple) recipe main [ run [ - 1:number <- copy 13:literal + 1:number <- copy 13 ] run [ - 2:number <- copy 13:literal + 2:number <- copy 13 ] ] +mem: storing 13 in location 1 @@ -363,10 +363,10 @@ recipe main [ % Scenario_testing_scenario = true; % Hide_warnings = true; recipe main [ - 1:number <- copy 3:literal - 2:number <- copy 97:literal # 'a' - 3:number <- copy 98:literal # 'b' - 4:number <- copy 99:literal # 'c' + 1:number <- copy 3 + 2:number <- copy 97 # 'a' + 3:number <- copy 98 # 'b' + 4:number <- copy 99 # 'c' memory-should-contain [ 1:string <- [ab] ] @@ -375,10 +375,10 @@ recipe main [ :(scenario memory_check_string) recipe main [ - 1:number <- copy 3:literal - 2:number <- copy 97:literal # 'a' - 3:number <- copy 98:literal # 'b' - 4:number <- copy 99:literal # 'c' + 1:number <- copy 3 + 2:number <- copy 97 # 'a' + 3:number <- copy 98 # 'b' + 4:number <- copy 99 # 'c' memory-should-contain [ 1:string <- [abc] ] diff --git a/051scenario_test.mu b/051scenario_test.mu index 88085e9b..a36897c4 100644 --- a/051scenario_test.mu +++ b/051scenario_test.mu @@ -2,7 +2,7 @@ scenario first_scenario_in_mu [ run [ - 1:number <- add 2:literal, 2:literal + 1:number <- add 2, 2 ] memory-should-contain [ 1 <- 4 @@ -12,7 +12,7 @@ scenario first_scenario_in_mu [ scenario scenario_with_comment_in_mu [ run [ # comment - 1:number <- add 2:literal, 2:literal + 1:number <- add 2, 2 ] memory-should-contain [ 1 <- 4 @@ -23,7 +23,7 @@ scenario scenario_with_multiple_comments_in_mu [ run [ # comment1 # comment2 - 1:number <- add 2:literal, 2:literal + 1:number <- add 2, 2 ] memory-should-contain [ 1 <- 4 @@ -32,10 +32,10 @@ scenario scenario_with_multiple_comments_in_mu [ scenario check_string_in_memory [ run [ - 1:number <- copy 3:literal - 2:character <- copy 97:literal # 'a' - 3:character <- copy 98:literal # 'b' - 4:character <- copy 99:literal # 'c' + 1:number <- copy 3 + 2:character <- copy 97 # 'a' + 3:character <- copy 98 # 'b' + 4:character <- copy 99 # 'c' ] memory-should-contain [ 1:string <- [abc] @@ -44,7 +44,7 @@ scenario check_string_in_memory [ scenario check_trace [ run [ - 1:number <- add 2:literal, 2:literal + 1:number <- add 2, 2 ] trace-should-contain [ mem: storing 4 in location 1 @@ -53,7 +53,7 @@ scenario check_trace [ scenario check_trace_negative [ run [ - 1:number <- add 2:literal, 2:literal + 1:number <- add 2, 2 ] trace-should-not-contain [ mem: storing 5 in location 1 diff --git a/060string.mu b/060string.mu index 74db7fe1..16e7bdf2 100644 --- a/060string.mu +++ b/060string.mu @@ -11,11 +11,11 @@ recipe string-equal [ trace [string-equal], [comparing lengths] length-equal?:boolean <- equal a-len:number, b-len:number break-if length-equal?:boolean - reply 0:literal + reply 0 } # compare each corresponding character trace [string-equal], [comparing characters] - i:number <- copy 0:literal + i:number <- copy 0 { done?:boolean <- greater-or-equal i:number, a-len:number break-if done?:boolean @@ -24,17 +24,17 @@ recipe string-equal [ { chars-match?:boolean <- equal a2:character, b2:character break-if chars-match?:boolean - reply 0:literal + reply 0 } - i:number <- add i:number, 1:literal + i:number <- add i:number, 1 loop } - reply 1:literal + reply 1 ] scenario string-equal-reflexive [ run [ - default-space:address:array:location <- new location:type, 30:literal + default-space:address:array:location <- new location:type, 30 x:address:array:character <- new [abc] 3:boolean/raw <- string-equal x:address:array:character, x:address:array:character ] @@ -45,7 +45,7 @@ scenario string-equal-reflexive [ scenario string-equal-identical [ run [ - default-space:address:array:location <- new location:type, 30:literal + default-space:address:array:location <- new location:type, 30 x:address:array:character <- new [abc] y:address:array:character <- new [abc] 3:boolean/raw <- string-equal x:address:array:character, y:address:array:character @@ -57,7 +57,7 @@ scenario string-equal-identical [ scenario string-equal-distinct-lengths [ run [ - default-space:address:array:location <- new location:type, 30:literal + default-space:address:array:location <- new location:type, 30 x:address:array:character <- new [abc] y:address:array:character <- new [abcd] 3:boolean/raw <- string-equal x:address:array:character, y:address:array:character @@ -75,7 +75,7 @@ scenario string-equal-distinct-lengths [ scenario string-equal-with-empty [ run [ - default-space:address:array:location <- new location:type, 30:literal + default-space:address:array:location <- new location:type, 30 x:address:array:character <- new [] y:address:array:character <- new [abcd] 3:boolean/raw <- string-equal x:address:array:character, y:address:array:character @@ -87,7 +87,7 @@ scenario string-equal-with-empty [ scenario string-equal-common-lengths-but-distinct [ run [ - default-space:address:array:location <- new location:type, 30:literal + default-space:address:array:location <- new location:type, 30 x:address:array:character <- new [abc] y:address:array:character <- new [abd] 3:boolean/raw <- string-equal x:address:array:character, y:address:array:character @@ -105,15 +105,15 @@ container buffer [ recipe new-buffer [ local-scope -#? $print default-space:address:array:location, 10:literal/newline +#? $print default-space:address:array:location, 10/newline result:address:buffer <- new buffer:type len:address:number <- get-address result:address:buffer/deref, length:offset - len:address:number/deref <- copy 0:literal + len:address:number/deref <- copy 0 s:address:address:array:character <- get-address result:address:buffer/deref, data:offset capacity:number, found?:boolean <- next-ingredient assert found?:boolean, [new-buffer must get a capacity argument] s:address:address:array:character/deref <- new character:type, capacity:number -#? $print s:address:address:array:character/deref, 10:literal/newline +#? $print s:address:address:array:character/deref, 10/newline reply result:address:buffer ] @@ -123,18 +123,18 @@ recipe grow-buffer [ # double buffer size x:address:address:array:character <- get-address in:address:buffer/deref, data:offset oldlen:number <- length x:address:address:array:character/deref/deref - newlen:number <- multiply oldlen:number, 2:literal + newlen:number <- multiply oldlen:number, 2 olddata:address:array:character <- copy x:address:address:array:character/deref x:address:address:array:character/deref <- new character:type, newlen:number # copy old contents - i:number <- copy 0:literal + i:number <- copy 0 { done?:boolean <- greater-or-equal i:number, oldlen:number break-if done?:boolean src:character <- index olddata:address:array:character/deref, i:number dest:address:character <- index-address x:address:address:array:character/deref/deref, i:number dest:address:character/deref <- copy src:character - i:number <- add i:number, 1:literal + i:number <- add i:number, 1 loop } reply in:address:buffer @@ -158,11 +158,11 @@ recipe buffer-append [ len:address:number <- get-address in:address:buffer/deref, length:offset { # backspace? just drop last character if it exists and return - backspace?:boolean <- equal c:character, 8:literal/backspace + backspace?:boolean <- equal c:character, 8/backspace break-unless backspace?:boolean - empty?:boolean <- lesser-or-equal len:address:number/deref, 0:literal + empty?:boolean <- lesser-or-equal len:address:number/deref, 0 reply-if empty?:boolean, in:address:buffer/same-as-ingredient:0 - len:address:number/deref <- subtract len:address:number/deref, 1:literal + len:address:number/deref <- subtract len:address:number/deref, 1 reply in:address:buffer/same-as-ingredient:0 } { @@ -172,28 +172,28 @@ recipe buffer-append [ in:address:buffer <- grow-buffer in:address:buffer } s:address:array:character <- get in:address:buffer/deref, data:offset -#? $print [array underlying buf: ], s:address:array:character, 10:literal/newline -#? $print [index: ], len:address:number/deref, 10:literal/newline +#? $print [array underlying buf: ], s:address:array:character, 10/newline +#? $print [index: ], len:address:number/deref, 10/newline dest:address:character <- index-address s:address:array:character/deref, len:address:number/deref -#? $print [storing ], c:character, [ in ], dest:address:character, 10:literal/newline +#? $print [storing ], c:character, [ in ], dest:address:character, 10/newline dest:address:character/deref <- copy c:character - len:address:number/deref <- add len:address:number/deref, 1:literal + len:address:number/deref <- add len:address:number/deref, 1 reply in:address:buffer/same-as-ingredient:0 ] scenario buffer-append-works [ run [ local-scope - x:address:buffer <- new-buffer 3:literal + x:address:buffer <- new-buffer 3 s1:address:array:character <- get x:address:buffer/deref, data:offset - x:address:buffer <- buffer-append x:address:buffer, 97:literal # 'a' - x:address:buffer <- buffer-append x:address:buffer, 98:literal # 'b' - x:address:buffer <- buffer-append x:address:buffer, 99:literal # 'c' + x:address:buffer <- buffer-append x:address:buffer, 97 # 'a' + x:address:buffer <- buffer-append x:address:buffer, 98 # 'b' + x:address:buffer <- buffer-append x:address:buffer, 99 # 'c' s2:address:array:character <- get x:address:buffer/deref, data:offset 1:boolean/raw <- equal s1:address:array:character, s2:address:array:character 2:array:character/raw <- copy s2:address:array:character/deref +buffer-filled - x:address:buffer <- buffer-append x:address:buffer, 100:literal # 'd' + x:address:buffer <- buffer-append x:address:buffer, 100 # 'd' s3:address:array:character <- get x:address:buffer/deref, data:offset 10:boolean/raw <- equal s1:address:array:character, s3:address:array:character 11:number/raw <- get x:address:buffer/deref, length:offset @@ -222,10 +222,10 @@ scenario buffer-append-works [ scenario buffer-append-handles-backspace [ run [ local-scope - x:address:buffer <- new-buffer 3:literal - x:address:buffer <- buffer-append x:address:buffer, 97:literal # 'a' - x:address:buffer <- buffer-append x:address:buffer, 98:literal # 'b' - x:address:buffer <- buffer-append x:address:buffer, 8:literal/backspace + x:address:buffer <- new-buffer 3 + x:address:buffer <- buffer-append x:address:buffer, 97 # 'a' + x:address:buffer <- buffer-append x:address:buffer, 98 # 'b' + x:address:buffer <- buffer-append x:address:buffer, 8/backspace s:address:array:character <- buffer-to-array x:address:buffer 1:array:character/raw <- copy s:address:array:character/deref ] @@ -247,20 +247,20 @@ recipe integer-to-decimal-string [ reply result:address:array:character } # save sign - negate-result:boolean <- copy 0:literal + negate-result:boolean <- copy 0 { - negative?:boolean <- lesser-than n:number, 0:literal + negative?:boolean <- lesser-than n:number, 0 break-unless negative?:boolean - negate-result:boolean <- copy 1:literal - n:number <- multiply n:number, -1:literal + negate-result:boolean <- copy 1 + n:number <- multiply n:number, -1 } # add digits from right to left into intermediate buffer - tmp:address:buffer <- new-buffer 30:literal - digit-base:number <- copy 48:literal # '0' + tmp:address:buffer <- new-buffer 30 + digit-base:number <- copy 48 # '0' { - done?:boolean <- equal n:number, 0:literal + done?:boolean <- equal n:number, 0 break-if done?:boolean - n:number, digit:number <- divide-with-remainder n:number, 10:literal + n:number, digit:number <- divide-with-remainder n:number, 10 c:character <- add digit-base:number, digit:number tmp:address:buffer <- buffer-append tmp:address:buffer, c:character loop @@ -268,26 +268,26 @@ recipe integer-to-decimal-string [ # add sign { break-unless negate-result:boolean - tmp:address:buffer <- buffer-append tmp:address:buffer, 45:literal # '-' + tmp:address:buffer <- buffer-append tmp:address:buffer, 45 # '-' } # reverse buffer into string result len:number <- get tmp:address:buffer/deref, length:offset buf:address:array:character <- get tmp:address:buffer/deref, data:offset result:address:array:character <- new character:type, len:number - i:number <- subtract len:number, 1:literal - j:number <- copy 0:literal + i:number <- subtract len:number, 1 + j:number <- copy 0 { # while i >= 0 - done?:boolean <- lesser-than i:number, 0:literal + done?:boolean <- lesser-than i:number, 0 break-if done?:boolean # result[j] = tmp[i] src:character <- index buf:address:array:character/deref, i:number dest:address:character <- index-address result:address:array:character/deref, j:number dest:address:character/deref <- copy src:character # ++i - i:number <- subtract i:number, 1:literal + i:number <- subtract i:number, 1 # --j - j:number <- add j:number, 1:literal + j:number <- add j:number, 1 loop } reply result:address:array:character @@ -299,14 +299,14 @@ recipe buffer-to-array [ { # propagate null buffer break-if in:address:buffer - reply 0:literal + reply 0 } len:number <- get in:address:buffer/deref, length:offset -#? $print [size ], len:number, 10:literal/newline +#? $print [size ], len:number, 10/newline s:address:array:character <- get in:address:buffer/deref, data:offset # we can't just return s because it is usually the wrong length result:address:array:character <- new character:type, len:number - i:number <- copy 0:literal + i:number <- copy 0 { #? $print i:number #? 1 done?:boolean <- greater-or-equal i:number, len:number @@ -314,7 +314,7 @@ recipe buffer-to-array [ src:character <- index s:address:array:character/deref, i:number dest:address:character <- index-address result:address:array:character/deref, i:number dest:address:character/deref <- copy src:character - i:number <- add i:number, 1:literal + i:number <- add i:number, 1 loop } reply result:address:array:character @@ -322,7 +322,7 @@ recipe buffer-to-array [ scenario integer-to-decimal-digit-zero [ run [ - 1:address:array:character/raw <- integer-to-decimal-string 0:literal + 1:address:array:character/raw <- integer-to-decimal-string 0 2:array:character/raw <- copy 1:address:array:character/deref/raw ] memory-should-contain [ @@ -332,7 +332,7 @@ scenario integer-to-decimal-digit-zero [ scenario integer-to-decimal-digit-positive [ run [ - 1:address:array:character/raw <- integer-to-decimal-string 234:literal + 1:address:array:character/raw <- integer-to-decimal-string 234 2:array:character/raw <- copy 1:address:array:character/deref/raw ] memory-should-contain [ @@ -342,7 +342,7 @@ scenario integer-to-decimal-digit-positive [ scenario integer-to-decimal-digit-negative [ run [ - 1:address:array:character/raw <- integer-to-decimal-string -1:literal + 1:address:array:character/raw <- integer-to-decimal-string -1 2:array:character/raw <- copy 1:address:array:character/deref/raw ] memory-should-contain [ @@ -363,8 +363,8 @@ recipe string-append [ result-len:number <- add a-len:number, b-len:number result:address:array:character <- new character:type, result-len:number # copy a into result - result-idx:number <- copy 0:literal - i:number <- copy 0:literal + result-idx:number <- copy 0 + i:number <- copy 0 { # while i < a.length a-done?:boolean <- greater-or-equal i:number, a-len:number @@ -374,13 +374,13 @@ recipe string-append [ in:character <- index a:address:array:character/deref, i:number out:address:character/deref <- copy in:character # ++i - i:number <- add i:number, 1:literal + i:number <- add i:number, 1 # ++result-idx - result-idx:number <- add result-idx:number, 1:literal + result-idx:number <- add result-idx:number, 1 loop } # copy b into result - i:number <- copy 0:literal + i:number <- copy 0 { # while i < b.length b-done?:boolean <- greater-or-equal i:number, b-len:number @@ -390,9 +390,9 @@ recipe string-append [ in:character <- index b:address:array:character/deref, i:number out:address:character/deref <- copy in:character # ++i - i:number <- add i:number, 1:literal + i:number <- add i:number, 1 # ++result-idx - result-idx:number <- add result-idx:number, 1:literal + result-idx:number <- add result-idx:number, 1 loop } reply result:address:array:character @@ -425,17 +425,17 @@ recipe interpolate [ # result-len = result-len + arg.length - 1 for the 'underscore' being replaced a-len:number <- length a:address:array:character/deref result-len:number <- add result-len:number, a-len:number - result-len:number <- subtract result-len:number, 1:literal + result-len:number <- subtract result-len:number, 1 loop } -#? $print tem-len:number, [ ], $result-len:number, 10:literal/newline +#? $print tem-len:number, [ ], $result-len:number, 10/newline rewind-ingredients _ <- next-ingredient # skip template # result = new array:character[result-len] result:address:array:character <- new character:type, result-len:number # repeatedly copy sections of template and 'holes' into result - result-idx:number <- copy 0:literal - i:number <- copy 0:literal + result-idx:number <- copy 0 + i:number <- copy 0 { # while arg received a:address:array:character, arg-received?:boolean <- next-ingredient @@ -447,19 +447,19 @@ recipe interpolate [ break-if tem-done?:boolean, +done:label # while template[i] != '_' in:character <- index template:address:array:character/deref, i:number - underscore?:boolean <- equal in:character, 95:literal # '_' + underscore?:boolean <- equal in:character, 95 # '_' break-if underscore?:boolean # result[result-idx] = template[i] out:address:character <- index-address result:address:array:character/deref, result-idx:number out:address:character/deref <- copy in:character # ++i - i:number <- add i:number, 1:literal + i:number <- add i:number, 1 # ++result-idx - result-idx:number <- add result-idx:number, 1:literal + result-idx:number <- add result-idx:number, 1 loop } # copy 'a' into result - j:number <- copy 0:literal + j:number <- copy 0 { # while j < a.length arg-done?:boolean <- greater-or-equal j:number, a-len:number @@ -469,13 +469,13 @@ recipe interpolate [ out:address:character <- index-address result:address:array:character/deref, result-idx:number out:address:character/deref <- copy in:character # ++j - j:number <- add j:number, 1:literal + j:number <- add j:number, 1 # ++result-idx - result-idx:number <- add result-idx:number, 1:literal + result-idx:number <- add result-idx:number, 1 loop } # skip '_' in template - i:number <- add i:number, 1:literal + i:number <- add i:number, 1 loop # interpolate next arg } +done @@ -489,9 +489,9 @@ recipe interpolate [ out:address:character <- index-address result:address:array:character/deref, result-idx:number out:address:character/deref <- copy in:character # ++i - i:number <- add i:number, 1:literal + i:number <- add i:number, 1 # ++result-idx - result-idx:number <- add result-idx:number, 1:literal + result-idx:number <- add result-idx:number, 1 loop } reply result:address:array:character @@ -540,61 +540,61 @@ recipe space? [ local-scope c:character <- next-ingredient # most common case first - result:boolean <- equal c:character, 32:literal/space + result:boolean <- equal c:character, 32/space jump-if result:boolean, +reply:label - result:boolean <- equal c:character, 10:literal/newline + result:boolean <- equal c:character, 10/newline jump-if result:boolean, +reply:label - result:boolean <- equal c:character, 9:literal/tab + result:boolean <- equal c:character, 9/tab jump-if result:boolean, +reply:label - result:boolean <- equal c:character, 13:literal/carriage-return + result:boolean <- equal c:character, 13/carriage-return # remaining uncommon cases in sorted order # http://unicode.org code-points in unicode-set Z and Pattern_White_Space jump-if result:boolean, +reply:label - result:boolean <- equal c:character, 11:literal/ctrl-k + result:boolean <- equal c:character, 11/ctrl-k jump-if result:boolean, +reply:label - result:boolean <- equal c:character, 12:literal/ctrl-l + result:boolean <- equal c:character, 12/ctrl-l jump-if result:boolean, +reply:label - result:boolean <- equal c:character, 133:literal/ctrl-0085 + result:boolean <- equal c:character, 133/ctrl-0085 jump-if result:boolean, +reply:label - result:boolean <- equal c:character, 160:literal/no-break-space + result:boolean <- equal c:character, 160/no-break-space jump-if result:boolean, +reply:label - result:boolean <- equal c:character, 5760:literal/ogham-space-mark + result:boolean <- equal c:character, 5760/ogham-space-mark jump-if result:boolean, +reply:label - result:boolean <- equal c:character, 8192:literal/en-quad + result:boolean <- equal c:character, 8192/en-quad jump-if result:boolean, +reply:label - result:boolean <- equal c:character, 8193:literal/em-quad + result:boolean <- equal c:character, 8193/em-quad jump-if result:boolean, +reply:label - result:boolean <- equal c:character, 8194:literal/en-space + result:boolean <- equal c:character, 8194/en-space jump-if result:boolean, +reply:label - result:boolean <- equal c:character, 8195:literal/em-space + result:boolean <- equal c:character, 8195/em-space jump-if result:boolean, +reply:label - result:boolean <- equal c:character, 8196:literal/three-per-em-space + result:boolean <- equal c:character, 8196/three-per-em-space jump-if result:boolean, +reply:label - result:boolean <- equal c:character, 8197:literal/four-per-em-space + result:boolean <- equal c:character, 8197/four-per-em-space jump-if result:boolean, +reply:label - result:boolean <- equal c:character, 8198:literal/six-per-em-space + result:boolean <- equal c:character, 8198/six-per-em-space jump-if result:boolean, +reply:label - result:boolean <- equal c:character, 8199:literal/figure-space + result:boolean <- equal c:character, 8199/figure-space jump-if result:boolean, +reply:label - result:boolean <- equal c:character, 8200:literal/punctuation-space + result:boolean <- equal c:character, 8200/punctuation-space jump-if result:boolean, +reply:label - result:boolean <- equal c:character, 8201:literal/thin-space + result:boolean <- equal c:character, 8201/thin-space jump-if result:boolean, +reply:label - result:boolean <- equal c:character, 8202:literal/hair-space + result:boolean <- equal c:character, 8202/hair-space jump-if result:boolean, +reply:label - result:boolean <- equal c:character, 8206:literal/left-to-right + result:boolean <- equal c:character, 8206/left-to-right jump-if result:boolean, +reply:label - result:boolean <- equal c:character, 8207:literal/right-to-left + result:boolean <- equal c:character, 8207/right-to-left jump-if result:boolean, +reply:label - result:boolean <- equal c:character, 8232:literal/line-separator + result:boolean <- equal c:character, 8232/line-separator jump-if result:boolean, +reply:label - result:boolean <- equal c:character, 8233:literal/paragraph-separator + result:boolean <- equal c:character, 8233/paragraph-separator jump-if result:boolean, +reply:label - result:boolean <- equal c:character, 8239:literal/narrow-no-break-space + result:boolean <- equal c:character, 8239/narrow-no-break-space jump-if result:boolean, +reply:label - result:boolean <- equal c:character, 8287:literal/medium-mathematical-space + result:boolean <- equal c:character, 8287/medium-mathematical-space jump-if result:boolean, +reply:label - result:boolean <- equal c:character, 12288:literal/ideographic-space + result:boolean <- equal c:character, 12288/ideographic-space jump-if result:boolean, +reply:label +reply reply result:boolean @@ -606,37 +606,37 @@ recipe trim [ s:address:array:character <- next-ingredient len:number <- length s:address:array:character/deref # left trim: compute start - start:number <- copy 0:literal + start:number <- copy 0 { { at-end?:boolean <- greater-or-equal start:number, len:number break-unless at-end?:boolean - result:address:array:character <- new character:type, 0:literal + result:address:array:character <- new character:type, 0 reply result:address:array:character } curr:character <- index s:address:array:character/deref, start:number whitespace?:boolean <- space? curr:character break-unless whitespace?:boolean - start:number <- add start:number, 1:literal + start:number <- add start:number, 1 loop } # right trim: compute end - end:number <- subtract len:number, 1:literal + end:number <- subtract len:number, 1 { not-at-start?:boolean <- greater-than end:number, start:number assert not-at-start?:boolean [end ran up against start] curr:character <- index s:address:array:character/deref, end:number whitespace?:boolean <- space? curr:character break-unless whitespace?:boolean - end:number <- subtract end:number, 1:literal + end:number <- subtract end:number, 1 loop } # result = new character[end+1 - start] - new-len:number <- subtract end:number, start:number, -1:literal + new-len:number <- subtract end:number, start:number, -1 result:address:array:character <- new character:type, new-len:number # i = start, j = 0 i:number <- copy start:number - j:number <- copy 0:literal + j:number <- copy 0 { # while i <= end done?:boolean <- greater-than i:number, end:number @@ -646,8 +646,8 @@ recipe trim [ dest:address:character <- index-address result:address:array:character/deref, j:number dest:address:character/deref <- copy src:character # ++i, ++j - i:number <- add i:number, 1:literal - j:number <- add j:number, 1:literal + i:number <- add i:number, 1 + j:number <- add j:number, 1 loop } reply result:address:array:character @@ -722,7 +722,7 @@ recipe find-next [ curr:character <- index text:address:array:character/deref, idx:number found?:boolean <- equal curr:character, pattern:character break-if found?:boolean - idx:number <- add idx:number, 1:literal + idx:number <- add idx:number, 1 loop } reply idx:number @@ -731,7 +731,7 @@ recipe find-next [ scenario string-find-next [ run [ 1:address:array:character <- new [a/b] - 2:number <- find-next 1:address:array:character, 47:literal/slash, 0:literal/start-index + 2:number <- find-next 1:address:array:character, 47/slash, 0/start-index ] memory-should-contain [ 2 <- 1 @@ -741,7 +741,7 @@ scenario string-find-next [ scenario string-find-next-empty [ run [ 1:address:array:character <- new [] - 2:number <- find-next 1:address:array:character, 47:literal/slash, 0:literal/start-index + 2:number <- find-next 1:address:array:character, 47/slash, 0/start-index ] memory-should-contain [ 2 <- 0 @@ -751,7 +751,7 @@ scenario string-find-next-empty [ scenario string-find-next-initial [ run [ 1:address:array:character <- new [/abc] - 2:number <- find-next 1:address:array:character, 47:literal/slash, 0:literal/start-index + 2:number <- find-next 1:address:array:character, 47/slash, 0/start-index ] memory-should-contain [ 2 <- 0 # prefix match @@ -761,7 +761,7 @@ scenario string-find-next-initial [ scenario string-find-next-final [ run [ 1:address:array:character <- new [abc/] - 2:number <- find-next 1:address:array:character, 47:literal/slash, 0:literal/start-index + 2:number <- find-next 1:address:array:character, 47/slash, 0/start-index ] memory-should-contain [ 2 <- 3 # suffix match @@ -771,7 +771,7 @@ scenario string-find-next-final [ scenario string-find-next-missing [ run [ 1:address:array:character <- new [abc] - 2:number <- find-next 1:address:array:character, 47:literal/slash, 0:literal/start-index + 2:number <- find-next 1:address:array:character, 47/slash, 0/start-index ] memory-should-contain [ 2 <- 3 # no match @@ -781,7 +781,7 @@ scenario string-find-next-missing [ scenario string-find-next-invalid-index [ run [ 1:address:array:character <- new [abc] - 2:number <- find-next 1:address:array:character, 47:literal/slash, 4:literal/start-index + 2:number <- find-next 1:address:array:character, 47/slash, 4/start-index ] memory-should-contain [ 2 <- 4 # no change @@ -791,7 +791,7 @@ scenario string-find-next-invalid-index [ scenario string-find-next-first [ run [ 1:address:array:character <- new [ab/c/] - 2:number <- find-next 1:address:array:character, 47:literal/slash, 0:literal/start-index + 2:number <- find-next 1:address:array:character, 47/slash, 0/start-index ] memory-should-contain [ 2 <- 2 # first '/' of multiple @@ -801,7 +801,7 @@ scenario string-find-next-first [ scenario string-find-next-second [ run [ 1:address:array:character <- new [ab/c/] - 2:number <- find-next 1:address:array:character, 47:literal/slash, 3:literal/start-index + 2:number <- find-next 1:address:array:character, 47/slash, 3/start-index ] memory-should-contain [ 2 <- 4 # second '/' of multiple @@ -815,7 +815,7 @@ recipe find-substring [ text:address:array:character <- next-ingredient pattern:address:array:character <- next-ingredient idx:number <- next-ingredient - first:character <- index pattern:address:array:character/deref, 0:literal + first:character <- index pattern:address:array:character/deref, 0 # repeatedly check for match at current idx len:number <- length text:address:array:character/deref { @@ -824,7 +824,7 @@ recipe find-substring [ break-if done?:boolean found?:boolean <- match-at text:address:array:character pattern:address:array:character, idx:number break-if found?:boolean - idx:number <- add idx:number, 1:literal + idx:number <- add idx:number, 1 # optimization: skip past indices that definitely won't match idx:number <- find-next text:address:array:character, first:character, idx:number loop @@ -836,7 +836,7 @@ scenario find-substring-1 [ run [ 1:address:array:character <- new [abc] 2:address:array:character <- new [bc] - 3:number <- find-substring 1:address:array:character, 2:address:array:character, 0:literal + 3:number <- find-substring 1:address:array:character, 2:address:array:character, 0 ] memory-should-contain [ 3 <- 1 @@ -847,7 +847,7 @@ scenario find-substring-2 [ run [ 1:address:array:character <- new [abcd] 2:address:array:character <- new [bc] - 3:number <- find-substring 1:address:array:character, 2:address:array:character, 1:literal + 3:number <- find-substring 1:address:array:character, 2:address:array:character, 1 ] memory-should-contain [ 3 <- 1 @@ -858,7 +858,7 @@ scenario find-substring-no-match [ run [ 1:address:array:character <- new [abc] 2:address:array:character <- new [bd] - 3:number <- find-substring 1:address:array:character, 2:address:array:character, 0:literal + 3:number <- find-substring 1:address:array:character, 2:address:array:character, 0 ] memory-should-contain [ 3 <- 3 # not found @@ -869,7 +869,7 @@ scenario find-substring-suffix-match [ run [ 1:address:array:character <- new [abcd] 2:address:array:character <- new [cd] - 3:number <- find-substring 1:address:array:character, 2:address:array:character, 0:literal + 3:number <- find-substring 1:address:array:character, 2:address:array:character, 0 ] memory-should-contain [ 3 <- 2 @@ -880,7 +880,7 @@ scenario find-substring-suffix-match-2 [ run [ 1:address:array:character <- new [abcd] 2:address:array:character <- new [cde] - 3:number <- find-substring 1:address:array:character, 2:address:array:character, 0:literal + 3:number <- find-substring 1:address:array:character, 2:address:array:character, 0 ] memory-should-contain [ 3 <- 4 # not found @@ -901,10 +901,10 @@ recipe match-at [ x:number <- subtract x:number, pattern-len:number enough-room?:boolean <- lesser-or-equal idx:number, x:number break-if enough-room?:boolean - reply 0:literal/not-found + reply 0/not-found } # check each character of pattern - pattern-idx:number <- copy 0:literal + pattern-idx:number <- copy 0 { done?:boolean <- greater-or-equal pattern-idx:number, pattern-len:number break-if done?:boolean @@ -913,20 +913,20 @@ recipe match-at [ { match?:boolean <- equal c:character, exp:character break-if match?:boolean - reply 0:literal/not-found + reply 0/not-found } - idx:number <- add idx:number, 1:literal - pattern-idx:number <- add pattern-idx:number, 1:literal + idx:number <- add idx:number, 1 + pattern-idx:number <- add pattern-idx:number, 1 loop } - reply 1:literal/found + reply 1/found ] scenario match-at-checks-substring-at-index [ run [ 1:address:array:character <- new [abc] 2:address:array:character <- new [ab] - 3:boolean <- match-at 1:address:array:character, 2:address:array:character, 0:literal + 3:boolean <- match-at 1:address:array:character, 2:address:array:character, 0 ] memory-should-contain [ 3 <- 1 # match found @@ -936,7 +936,7 @@ scenario match-at-checks-substring-at-index [ scenario match-at-reflexive [ run [ 1:address:array:character <- new [abc] - 3:boolean <- match-at 1:address:array:character, 1:address:array:character, 0:literal + 3:boolean <- match-at 1:address:array:character, 1:address:array:character, 0 ] memory-should-contain [ 3 <- 1 # match found @@ -947,7 +947,7 @@ scenario match-at-outside-bounds [ run [ 1:address:array:character <- new [abc] 2:address:array:character <- new [a] - 3:boolean <- match-at 1:address:array:character, 2:address:array:character, 4:literal + 3:boolean <- match-at 1:address:array:character, 2:address:array:character, 4 ] memory-should-contain [ 3 <- 0 # never matches @@ -958,7 +958,7 @@ scenario match-at-empty-pattern [ run [ 1:address:array:character <- new [abc] 2:address:array:character <- new [] - 3:boolean <- match-at 1:address:array:character, 2:address:array:character, 0:literal + 3:boolean <- match-at 1:address:array:character, 2:address:array:character, 0 ] memory-should-contain [ 3 <- 1 # always matches empty pattern given a valid index @@ -969,7 +969,7 @@ scenario match-at-empty-pattern-outside-bound [ run [ 1:address:array:character <- new [abc] 2:address:array:character <- new [] - 3:boolean <- match-at 1:address:array:character, 2:address:array:character, 4:literal + 3:boolean <- match-at 1:address:array:character, 2:address:array:character, 4 ] memory-should-contain [ 3 <- 0 # no match @@ -980,7 +980,7 @@ scenario match-at-empty-text [ run [ 1:address:array:character <- new [] 2:address:array:character <- new [abc] - 3:boolean <- match-at 1:address:array:character, 2:address:array:character, 0:literal + 3:boolean <- match-at 1:address:array:character, 2:address:array:character, 0 ] memory-should-contain [ 3 <- 0 # no match @@ -990,7 +990,7 @@ scenario match-at-empty-text [ scenario match-at-empty-against-empty [ run [ 1:address:array:character <- new [] - 3:boolean <- match-at 1:address:array:character, 1:address:array:character, 0:literal + 3:boolean <- match-at 1:address:array:character, 1:address:array:character, 0 ] memory-should-contain [ 3 <- 1 # matches because pattern is also empty @@ -1001,7 +1001,7 @@ scenario match-at-inside-bounds [ run [ 1:address:array:character <- new [abc] 2:address:array:character <- new [bc] - 3:boolean <- match-at 1:address:array:character, 2:address:array:character, 1:literal + 3:boolean <- match-at 1:address:array:character, 2:address:array:character, 1 ] memory-should-contain [ 3 <- 1 # matches inner substring @@ -1012,7 +1012,7 @@ scenario match-at-inside-bounds-2 [ run [ 1:address:array:character <- new [abc] 2:address:array:character <- new [bc] - 3:boolean <- match-at 1:address:array:character, 2:address:array:character, 0:literal + 3:boolean <- match-at 1:address:array:character, 2:address:array:character, 0 ] memory-should-contain [ 3 <- 0 # no match @@ -1027,27 +1027,27 @@ recipe split [ # empty string? return empty array len:number <- length s:address:array:character/deref { - empty?:boolean <- equal len:number, 0:literal + empty?:boolean <- equal len:number, 0 break-unless empty?:boolean - result:address:array:address:array:character <- new location:type, 0:literal + result:address:array:address:array:character <- new location:type, 0 reply result:address:array:address:array:character } # count #pieces we need room for - count:number <- copy 1:literal # n delimiters = n+1 pieces - idx:number <- copy 0:literal + count:number <- copy 1 # n delimiters = n+1 pieces + idx:number <- copy 0 { idx:number <- find-next s:address:array:character, delim:character, idx:number done?:boolean <- greater-or-equal idx:number, len:number break-if done?:boolean - idx:number <- add idx:number, 1:literal - count:number <- add count:number, 1:literal + idx:number <- add idx:number, 1 + count:number <- add count:number, 1 loop } # allocate space result:address:array:address:array:character <- new location:type, count:number # repeatedly copy slices start..end until delimiter into result[curr-result] - curr-result:number <- copy 0:literal - start:number <- copy 0:literal + curr-result:number <- copy 0 + start:number <- copy 0 { # while next delim exists done?:boolean <- greater-or-equal start:number, len:number @@ -1057,8 +1057,8 @@ recipe split [ dest:address:address:array:character <- index-address result:address:array:address:array:character/deref, curr-result:number dest:address:address:array:character/deref <- string-copy s:address:array:character, start:number, end:number # slide over to next slice - start:number <- add end:number, 1:literal - curr-result:number <- add curr-result:number, 1:literal + start:number <- add end:number, 1 + curr-result:number <- add curr-result:number, 1 loop } reply result:address:array:address:array:character @@ -1067,10 +1067,10 @@ recipe split [ scenario string-split-1 [ run [ 1:address:array:character <- new [a/b] - 2:address:array:address:array:character <- split 1:address:array:character, 47:literal/slash + 2:address:array:address:array:character <- split 1:address:array:character, 47/slash 3:number <- length 2:address:array:address:array:character/deref - 4:address:array:character <- index 2:address:array:address:array:character/deref, 0:literal - 5:address:array:character <- index 2:address:array:address:array:character/deref, 1:literal + 4:address:array:character <- index 2:address:array:address:array:character/deref, 0 + 5:address:array:character <- index 2:address:array:address:array:character/deref, 1 10:array:character <- copy 4:address:array:character/deref 20:array:character <- copy 5:address:array:character/deref ] @@ -1084,11 +1084,11 @@ scenario string-split-1 [ scenario string-split-2 [ run [ 1:address:array:character <- new [a/b/c] - 2:address:array:address:array:character <- split 1:address:array:character, 47:literal/slash + 2:address:array:address:array:character <- split 1:address:array:character, 47/slash 3:number <- length 2:address:array:address:array:character/deref - 4:address:array:character <- index 2:address:array:address:array:character/deref, 0:literal - 5:address:array:character <- index 2:address:array:address:array:character/deref, 1:literal - 6:address:array:character <- index 2:address:array:address:array:character/deref, 2:literal + 4:address:array:character <- index 2:address:array:address:array:character/deref, 0 + 5:address:array:character <- index 2:address:array:address:array:character/deref, 1 + 6:address:array:character <- index 2:address:array:address:array:character/deref, 2 10:array:character <- copy 4:address:array:character/deref 20:array:character <- copy 5:address:array:character/deref 30:array:character <- copy 6:address:array:character/deref @@ -1104,9 +1104,9 @@ scenario string-split-2 [ scenario string-split-missing [ run [ 1:address:array:character <- new [abc] - 2:address:array:address:array:character <- split 1:address:array:character, 47:literal/slash + 2:address:array:address:array:character <- split 1:address:array:character, 47/slash 3:number <- length 2:address:array:address:array:character/deref - 4:address:array:character <- index 2:address:array:address:array:character/deref, 0:literal + 4:address:array:character <- index 2:address:array:address:array:character/deref, 0 10:array:character <- copy 4:address:array:character/deref ] memory-should-contain [ @@ -1118,7 +1118,7 @@ scenario string-split-missing [ scenario string-split-empty [ run [ 1:address:array:character <- new [] - 2:address:array:address:array:character <- split 1:address:array:character, 47:literal/slash + 2:address:array:address:array:character <- split 1:address:array:character, 47/slash 3:number <- length 2:address:array:address:array:character/deref ] memory-should-contain [ @@ -1129,12 +1129,12 @@ scenario string-split-empty [ scenario string-split-empty-piece [ run [ 1:address:array:character <- new [a/b//c] - 2:address:array:address:array:character <- split 1:address:array:character, 47:literal/slash + 2:address:array:address:array:character <- split 1:address:array:character, 47/slash 3:number <- length 2:address:array:address:array:character/deref - 4:address:array:character <- index 2:address:array:address:array:character/deref, 0:literal - 5:address:array:character <- index 2:address:array:address:array:character/deref, 1:literal - 6:address:array:character <- index 2:address:array:address:array:character/deref, 2:literal - 7:address:array:character <- index 2:address:array:address:array:character/deref, 3:literal + 4:address:array:character <- index 2:address:array:address:array:character/deref, 0 + 5:address:array:character <- index 2:address:array:address:array:character/deref, 1 + 6:address:array:character <- index 2:address:array:address:array:character/deref, 2 + 7:address:array:character <- index 2:address:array:address:array:character/deref, 3 10:array:character <- copy 4:address:array:character/deref 20:array:character <- copy 5:address:array:character/deref 30:array:character <- copy 6:address:array:character/deref @@ -1157,15 +1157,15 @@ recipe split-first [ # empty string? return empty strings len:number <- length text:address:array:character/deref { - empty?:boolean <- equal len:number, 0:literal + empty?:boolean <- equal len:number, 0 break-unless empty?:boolean x:address:array:character <- new [] y:address:array:character <- new [] reply x:address:array:character, y:address:array:character } - idx:number <- find-next text:address:array:character, delim:character, 0:literal - x:address:array:character <- string-copy text:address:array:character, 0:literal, idx:number - idx:number <- add idx:number, 1:literal + idx:number <- find-next text:address:array:character, delim:character, 0 + x:address:array:character <- string-copy text:address:array:character, 0, idx:number + idx:number <- add idx:number, 1 y:address:array:character <- string-copy text:address:array:character, idx:number, len:number reply x:address:array:character, y:address:array:character ] @@ -1173,7 +1173,7 @@ recipe split-first [ scenario string-split-first [ run [ 1:address:array:character <- new [a/b] - 2:address:array:character, 3:address:array:character <- split-first 1:address:array:character, 47:literal/slash + 2:address:array:character, 3:address:array:character <- split-first 1:address:array:character, 47/slash 10:array:character <- copy 2:address:array:character/deref 20:array:character <- copy 3:address:array:character/deref ] @@ -1198,15 +1198,15 @@ recipe string-copy [ result:address:array:character <- new character:type, len:number # copy start..end into result[curr-result] src-idx:number <- copy start:number - dest-idx:number <- copy 0:literal + dest-idx:number <- copy 0 { done?:boolean <- greater-or-equal src-idx:number, end:number break-if done?:boolean src:character <- index buf:address:array:character/deref, src-idx:number dest:address:character <- index-address result:address:array:character/deref, dest-idx:number dest:address:character/deref <- copy src:character - src-idx:number <- add src-idx:number, 1:literal - dest-idx:number <- add dest-idx:number, 1:literal + src-idx:number <- add src-idx:number, 1 + dest-idx:number <- add dest-idx:number, 1 loop } reply result:address:array:character @@ -1215,7 +1215,7 @@ recipe string-copy [ scenario string-copy-copies-substring [ run [ 1:address:array:character <- new [abc] - 2:address:array:character <- string-copy 1:address:array:character, 1:literal, 3:literal + 2:address:array:character <- string-copy 1:address:array:character, 1, 3 3:array:character <- copy 2:address:array:character/deref ] memory-should-contain [ @@ -1226,7 +1226,7 @@ scenario string-copy-copies-substring [ scenario string-copy-out-of-bounds [ run [ 1:address:array:character <- new [abc] - 2:address:array:character <- string-copy 1:address:array:character, 2:literal, 4:literal + 2:address:array:character <- string-copy 1:address:array:character, 2, 4 3:array:character <- copy 2:address:array:character/deref ] memory-should-contain [ @@ -1237,7 +1237,7 @@ scenario string-copy-out-of-bounds [ scenario string-copy-out-of-bounds-2 [ run [ 1:address:array:character <- new [abc] - 2:address:array:character <- string-copy 1:address:array:character, 3:literal, 3:literal + 2:address:array:character <- string-copy 1:address:array:character, 3, 3 3:array:character <- copy 2:address:array:character/deref ] memory-should-contain [ diff --git a/061channel.mu b/061channel.mu index 2a839898..d1f4c55d 100644 --- a/061channel.mu +++ b/061channel.mu @@ -10,8 +10,8 @@ scenario channel [ run [ - 1:address:channel <- new-channel 3:literal/capacity - 1:address:channel <- write 1:address:channel, 34:literal + 1:address:channel <- new-channel 3/capacity + 1:address:channel <- write 1:address:channel, 34 2:number, 1:address:channel <- read 1:address:channel ] memory-should-contain [ @@ -38,13 +38,13 @@ recipe new-channel [ result:address:channel <- new channel:type # result.first-full = 0 full:address:number <- get-address result:address:channel/deref, first-full:offset - full:address:number/deref <- copy 0:literal + full:address:number/deref <- copy 0 # result.first-free = 0 free:address:number <- get-address result:address:channel/deref, first-free:offset - free:address:number/deref <- copy 0:literal + free:address:number/deref <- copy 0 # result.data = new location[ingredient+1] capacity:number <- next-ingredient - capacity:number <- add capacity:number, 1:literal # unused slot for 'full?' below + capacity:number <- add capacity:number, 1 # unused slot for 'full?' below dest:address:address:array:location <- get-address result:address:channel/deref, data:offset dest:address:address:array:location/deref <- new location:type, capacity:number reply result:address:channel @@ -68,13 +68,13 @@ recipe write [ dest:address:location <- index-address circular-buffer:address:array:location/deref, free:address:number/deref dest:address:location/deref <- copy val:location # increment free - free:address:number/deref <- add free:address:number/deref, 1:literal + free:address:number/deref <- add free:address:number/deref, 1 { # wrap free around to 0 if necessary len:number <- length circular-buffer:address:array:location/deref at-end?:boolean <- greater-or-equal free:address:number/deref, len:number break-unless at-end?:boolean - free:address:number/deref <- copy 0:literal + free:address:number/deref <- copy 0 } reply chan:address:channel/same-as-ingredient:0 ] @@ -95,13 +95,13 @@ recipe read [ circular-buffer:address:array:location <- get chan:address:channel/deref, data:offset result:location <- index circular-buffer:address:array:location/deref, full:address:number/deref # increment full - full:address:number/deref <- add full:address:number/deref, 1:literal + full:address:number/deref <- add full:address:number/deref, 1 { # wrap full around to 0 if necessary len:number <- length circular-buffer:address:array:location/deref at-end?:boolean <- greater-or-equal full:address:number/deref, len:number break-unless at-end?:boolean - full:address:number/deref <- copy 0:literal + full:address:number/deref <- copy 0 } reply result:location, chan:address:channel/same-as-ingredient:0 ] @@ -119,7 +119,7 @@ recipe clear-channel [ scenario channel-initialization [ run [ - 1:address:channel <- new-channel 3:literal/capacity + 1:address:channel <- new-channel 3/capacity 2:number <- get 1:address:channel/deref, first-full:offset 3:number <- get 1:address:channel/deref, first-free:offset ] @@ -131,8 +131,8 @@ scenario channel-initialization [ scenario channel-write-increments-free [ run [ - 1:address:channel <- new-channel 3:literal/capacity - 1:address:channel <- write 1:address:channel, 34:literal + 1:address:channel <- new-channel 3/capacity + 1:address:channel <- write 1:address:channel, 34 2:number <- get 1:address:channel/deref, first-full:offset 3:number <- get 1:address:channel/deref, first-free:offset ] @@ -144,8 +144,8 @@ scenario channel-write-increments-free [ scenario channel-read-increments-full [ run [ - 1:address:channel <- new-channel 3:literal/capacity - 1:address:channel <- write 1:address:channel, 34:literal + 1:address:channel <- new-channel 3/capacity + 1:address:channel <- write 1:address:channel, 34 _, 1:address:channel <- read 1:address:channel 2:number <- get 1:address:channel/deref, first-full:offset 3:number <- get 1:address:channel/deref, first-free:offset @@ -159,15 +159,15 @@ scenario channel-read-increments-full [ scenario channel-wrap [ run [ # channel with just 1 slot - 1:address:channel <- new-channel 1:literal/capacity + 1:address:channel <- new-channel 1/capacity # write and read a value - 1:address:channel <- write 1:address:channel, 34:literal + 1:address:channel <- write 1:address:channel, 34 _, 1:address:channel <- read 1:address:channel # first-free will now be 1 2:number <- get 1:address:channel/deref, first-free:offset 3:number <- get 1:address:channel/deref, first-free:offset # write second value, verify that first-free wraps - 1:address:channel <- write 1:address:channel, 34:literal + 1:address:channel <- write 1:address:channel, 34 4:number <- get 1:address:channel/deref, first-free:offset # read second value, verify that first-full wraps _, 1:address:channel <- read 1:address:channel @@ -201,13 +201,13 @@ recipe channel-full? [ chan:address:channel <- next-ingredient # tmp = chan.first-free + 1 tmp:number <- get chan:address:channel/deref, first-free:offset - tmp:number <- add tmp:number, 1:literal + tmp:number <- add tmp:number, 1 { # if tmp == chan.capacity, tmp = 0 len:number <- channel-capacity chan:address:channel at-end?:boolean <- greater-or-equal tmp:number, len:number break-unless at-end?:boolean - tmp:number <- copy 0:literal + tmp:number <- copy 0 } # return chan.first-full == tmp full:number <- get chan:address:channel/deref, first-full:offset @@ -226,7 +226,7 @@ recipe channel-capacity [ scenario channel-new-empty-not-full [ run [ - 1:address:channel <- new-channel 3:literal/capacity + 1:address:channel <- new-channel 3/capacity 2:boolean <- channel-empty? 1:address:channel 3:boolean <- channel-full? 1:address:channel ] @@ -238,8 +238,8 @@ scenario channel-new-empty-not-full [ scenario channel-write-not-empty [ run [ - 1:address:channel <- new-channel 3:literal/capacity - 1:address:channel <- write 1:address:channel, 34:literal + 1:address:channel <- new-channel 3/capacity + 1:address:channel <- write 1:address:channel, 34 2:boolean <- channel-empty? 1:address:channel 3:boolean <- channel-full? 1:address:channel ] @@ -251,8 +251,8 @@ scenario channel-write-not-empty [ scenario channel-write-full [ run [ - 1:address:channel <- new-channel 1:literal/capacity - 1:address:channel <- write 1:address:channel, 34:literal + 1:address:channel <- new-channel 1/capacity + 1:address:channel <- write 1:address:channel, 34 2:boolean <- channel-empty? 1:address:channel 3:boolean <- channel-full? 1:address:channel ] @@ -264,8 +264,8 @@ scenario channel-write-full [ scenario channel-read-not-full [ run [ - 1:address:channel <- new-channel 1:literal/capacity - 1:address:channel <- write 1:address:channel, 34:literal + 1:address:channel <- new-channel 1/capacity + 1:address:channel <- write 1:address:channel, 34 _, 1:address:channel <- read 1:address:channel 2:boolean <- channel-empty? 1:address:channel 3:boolean <- channel-full? 1:address:channel @@ -286,7 +286,7 @@ recipe buffer-lines [ out:address:channel <- next-ingredient # repeat forever { - line:address:buffer <- new-buffer, 30:literal + line:address:buffer <- new-buffer, 30 # read characters from 'in' until newline, copy into line { +next-character @@ -294,7 +294,7 @@ recipe buffer-lines [ # drop a character on backspace { # special-case: if it's a backspace - backspace?:boolean <- equal c:character, 8:literal + backspace?:boolean <- equal c:character, 8 break-unless backspace?:boolean # drop previous character #? close-console #? 2 @@ -302,23 +302,23 @@ recipe buffer-lines [ #? ] #? 1 { buffer-length:address:number <- get-address line:address:buffer/deref, length:offset - buffer-empty?:boolean <- equal buffer-length:address:number/deref, 0:literal + buffer-empty?:boolean <- equal buffer-length:address:number/deref, 0 break-if buffer-empty?:boolean -#? $print [before: ], buffer-length:address:number/deref, 10:literal/newline - buffer-length:address:number/deref <- subtract buffer-length:address:number/deref, 1:literal -#? $print [after: ], buffer-length:address:number/deref, 10:literal/newline +#? $print [before: ], buffer-length:address:number/deref, 10/newline + buffer-length:address:number/deref <- subtract buffer-length:address:number/deref, 1 +#? $print [after: ], buffer-length:address:number/deref, 10/newline } #? $exit #? 2 # and don't append this one loop +next-character:label } # append anything else -#? $print [buffer-lines: appending ], c:character, 10:literal/newline +#? $print [buffer-lines: appending ], c:character, 10/newline line:address:buffer <- buffer-append line:address:buffer, c:character - line-done?:boolean <- equal c:character, 10:literal/newline + line-done?:boolean <- equal c:character, 10/newline break-if line-done?:boolean # stop buffering on eof (currently only generated by fake console) - eof?:boolean <- equal c:character, 0:literal/eof + eof?:boolean <- equal c:character, 0/eof break-if eof?:boolean loop } @@ -326,7 +326,7 @@ recipe buffer-lines [ # copy line into 'out' #? $print [buffer-lines: emitting #? ] - i:number <- copy 0:literal + i:number <- copy 0 line-contents:address:array:character <- get line:address:buffer/deref, data:offset max:number <- get line:address:buffer/deref, length:offset { @@ -334,8 +334,8 @@ recipe buffer-lines [ break-if done?:boolean c:character <- index line-contents:address:array:character/deref, i:number out:address:channel <- write out:address:channel, c:character -#? $print [writing ], i:number, [: ], c:character, 10:literal/newline - i:number <- add i:number, 1:literal +#? $print [writing ], i:number, [: ], c:character, 10/newline + i:number <- add i:number, 1 loop } #? $dump-trace #? 1 @@ -347,8 +347,8 @@ recipe buffer-lines [ scenario buffer-lines-blocks-until-newline [ run [ - 1:address:channel/stdin <- new-channel 10:literal/capacity - 2:address:channel/buffered-stdin <- new-channel 10:literal/capacity + 1:address:channel/stdin <- new-channel 10/capacity + 2:address:channel/buffered-stdin <- new-channel 10/capacity 3:boolean <- channel-empty? 2:address:channel/buffered-stdin assert 3:boolean, [ F buffer-lines-blocks-until-newline: channel should be empty after init] @@ -359,21 +359,21 @@ F buffer-lines-blocks-until-newline: channel should be empty after init] assert 5:boolean, [ F buffer-lines-blocks-until-newline: channel should be empty after buffer-lines bring-up] # write 'a' - 1:address:channel <- write 1:address:channel, 97:literal/a + 1:address:channel <- write 1:address:channel, 97/a restart 4:number/buffer-routine wait-for-routine 4:number/buffer-routine 6:boolean <- channel-empty? 2:address:channel/buffered-stdin assert 6:boolean, [ F buffer-lines-blocks-until-newline: channel should be empty after writing 'a'] # write 'b' - 1:address:channel <- write 1:address:channel, 98:literal/b + 1:address:channel <- write 1:address:channel, 98/b restart 4:number/buffer-routine wait-for-routine 4:number/buffer-routine 7:boolean <- channel-empty? 2:address:channel/buffered-stdin assert 7:boolean, [ F buffer-lines-blocks-until-newline: channel should be empty after writing 'b'] # write newline - 1:address:channel <- write 1:address:channel, 10:literal/newline + 1:address:channel <- write 1:address:channel, 10/newline restart 4:number/buffer-routine wait-for-routine 4:number/buffer-routine 8:boolean <- channel-empty? 2:address:channel/buffered-stdin diff --git a/062array.mu b/062array.mu index a14f4916..e0b72593 100644 --- a/062array.mu +++ b/062array.mu @@ -1,6 +1,6 @@ scenario array-from-args [ run [ - 1:address:array:location <- new-array 0:literal, 1:literal, 2:literal + 1:address:array:location <- new-array 0, 1, 2 2:array:location <- copy 1:address:array:location/deref ] memory-should-contain [ @@ -14,17 +14,17 @@ scenario array-from-args [ # create an array out of a list of scalar args recipe new-array [ local-scope - capacity:number <- copy 0:literal + capacity:number <- copy 0 { # while read curr-value curr-value:location, exists?:boolean <- next-ingredient break-unless exists?:boolean - capacity:number <- add capacity:number, 1:literal + capacity:number <- add capacity:number, 1 loop } result:address:array:location <- new location:type, capacity:number rewind-ingredients - i:number <- copy 0:literal + i:number <- copy 0 { # while read curr-value done?:boolean <- greater-or-equal i:number, capacity:number @@ -33,7 +33,7 @@ recipe new-array [ assert exists?:boolean, [error in rewinding ingredients to new-array] tmp:address:location <- index-address result:address:array:location/deref, i:number tmp:address:location/deref <- copy curr-value:location - i:number <- add i:number, 1:literal + i:number <- add i:number, 1 loop } reply result:address:array:location diff --git a/063list.mu b/063list.mu index fd64cfe8..fce02c8d 100644 --- a/063list.mu +++ b/063list.mu @@ -40,10 +40,10 @@ recipe rest [ scenario list-handling [ run [ #? $start-tracing #? 1 - 1:address:list <- copy 0:literal - 1:address:list <- push 3:literal, 1:address:list - 1:address:list <- push 4:literal, 1:address:list - 1:address:list <- push 5:literal, 1:address:list + 1:address:list <- copy 0 + 1:address:list <- push 3, 1:address:list + 1:address:list <- push 4, 1:address:list + 1:address:list <- push 5, 1:address:list 2:number <- first 1:address:list 1:address:list <- rest 1:address:list 3:number <- first 1:address:list diff --git a/065duplex_list.mu b/065duplex_list.mu index c54934ec..b1bfb7a8 100644 --- a/065duplex_list.mu +++ b/065duplex_list.mu @@ -26,7 +26,7 @@ recipe push-duplex [ recipe first-duplex [ local-scope in:address:duplex-list <- next-ingredient - reply-unless in:address:duplex-list, 0:literal + reply-unless in:address:duplex-list, 0 result:location <- get in:address:duplex-list/deref, value:offset reply result:location ] @@ -35,7 +35,7 @@ recipe first-duplex [ recipe next-duplex [ local-scope in:address:duplex-list <- next-ingredient - reply-unless in:address:duplex-list, 0:literal + reply-unless in:address:duplex-list, 0 result:address:duplex-list <- get in:address:duplex-list/deref, next:offset reply result:address:duplex-list ] @@ -44,7 +44,7 @@ recipe next-duplex [ recipe prev-duplex [ local-scope in:address:duplex-list <- next-ingredient - reply-unless in:address:duplex-list, 0:literal + reply-unless in:address:duplex-list, 0 result:address:duplex-list <- get in:address:duplex-list/deref, prev:offset reply result:address:duplex-list ] @@ -52,12 +52,12 @@ recipe prev-duplex [ scenario duplex-list-handling [ run [ # reserve locations 0, 1 and 2 to check for missing null check - 1:number <- copy 34:literal - 2:number <- copy 35:literal - 3:address:duplex-list <- copy 0:literal - 3:address:duplex-list <- push-duplex 3:literal, 3:address:duplex-list - 3:address:duplex-list <- push-duplex 4:literal, 3:address:duplex-list - 3:address:duplex-list <- push-duplex 5:literal, 3:address:duplex-list + 1:number <- copy 34 + 2:number <- copy 35 + 3:address:duplex-list <- copy 0 + 3:address:duplex-list <- push-duplex 3, 3:address:duplex-list + 3:address:duplex-list <- push-duplex 4, 3:address:duplex-list + 3:address:duplex-list <- push-duplex 5, 3:address:duplex-list 4:address:duplex-list <- copy 3:address:duplex-list 5:number <- first 4:address:duplex-list 4:address:duplex-list <- next-duplex 4:address:duplex-list @@ -121,12 +121,12 @@ recipe insert-duplex [ scenario inserting-into-duplex-list [ run [ - 1:address:duplex-list <- copy 0:literal # 1 points to head of list - 1:address:duplex-list <- push-duplex 3:literal, 1:address:duplex-list - 1:address:duplex-list <- push-duplex 4:literal, 1:address:duplex-list - 1:address:duplex-list <- push-duplex 5:literal, 1:address:duplex-list + 1:address:duplex-list <- copy 0 # 1 points to head of list + 1:address:duplex-list <- push-duplex 3, 1:address:duplex-list + 1:address:duplex-list <- push-duplex 4, 1:address:duplex-list + 1:address:duplex-list <- push-duplex 5, 1:address:duplex-list 2:address:duplex-list <- next-duplex 1:address:duplex-list # 2 points inside list - 2:address:duplex-list <- insert-duplex 6:literal, 2:address:duplex-list + 2:address:duplex-list <- insert-duplex 6, 2:address:duplex-list # check structure like before 2:address:duplex-list <- copy 1:address:duplex-list 3:number <- first 2:address:duplex-list @@ -158,13 +158,13 @@ scenario inserting-into-duplex-list [ scenario inserting-at-end-of-duplex-list [ run [ - 1:address:duplex-list <- copy 0:literal # 1 points to head of list - 1:address:duplex-list <- push-duplex 3:literal, 1:address:duplex-list - 1:address:duplex-list <- push-duplex 4:literal, 1:address:duplex-list - 1:address:duplex-list <- push-duplex 5:literal, 1:address:duplex-list + 1:address:duplex-list <- copy 0 # 1 points to head of list + 1:address:duplex-list <- push-duplex 3, 1:address:duplex-list + 1:address:duplex-list <- push-duplex 4, 1:address:duplex-list + 1:address:duplex-list <- push-duplex 5, 1:address:duplex-list 2:address:duplex-list <- next-duplex 1:address:duplex-list # 2 points inside list 2:address:duplex-list <- next-duplex 2:address:duplex-list # now at end of list - 2:address:duplex-list <- insert-duplex 6:literal, 2:address:duplex-list + 2:address:duplex-list <- insert-duplex 6, 2:address:duplex-list # check structure like before 2:address:duplex-list <- copy 1:address:duplex-list 3:number <- first 2:address:duplex-list @@ -196,11 +196,11 @@ scenario inserting-at-end-of-duplex-list [ scenario inserting-after-start-of-duplex-list [ run [ - 1:address:duplex-list <- copy 0:literal # 1 points to head of list - 1:address:duplex-list <- push-duplex 3:literal, 1:address:duplex-list - 1:address:duplex-list <- push-duplex 4:literal, 1:address:duplex-list - 1:address:duplex-list <- push-duplex 5:literal, 1:address:duplex-list - 2:address:duplex-list <- insert-duplex 6:literal, 1:address:duplex-list + 1:address:duplex-list <- copy 0 # 1 points to head of list + 1:address:duplex-list <- push-duplex 3, 1:address:duplex-list + 1:address:duplex-list <- push-duplex 4, 1:address:duplex-list + 1:address:duplex-list <- push-duplex 5, 1:address:duplex-list + 2:address:duplex-list <- insert-duplex 6, 1:address:duplex-list # check structure like before 2:address:duplex-list <- copy 1:address:duplex-list 3:number <- first 2:address:duplex-list @@ -245,9 +245,9 @@ recipe remove-duplex [ prev-node:address:duplex-list <- get in:address:duplex-list/deref, prev:offset # null in's pointers x:address:address:duplex-list <- get-address in:address:duplex-list/deref, next:offset - x:address:address:duplex-list/deref <- copy 0:literal + x:address:address:duplex-list/deref <- copy 0 x:address:address:duplex-list <- get-address in:address:duplex-list/deref, prev:offset - x:address:address:duplex-list/deref <- copy 0:literal + x:address:address:duplex-list/deref <- copy 0 { # if next-node is not null break-unless next-node:address:duplex-list @@ -268,13 +268,13 @@ recipe remove-duplex [ scenario removing-from-duplex-list [ run [ - 1:address:duplex-list <- copy 0:literal # 1 points to head of list - 1:address:duplex-list <- push-duplex 3:literal, 1:address:duplex-list - 1:address:duplex-list <- push-duplex 4:literal, 1:address:duplex-list - 1:address:duplex-list <- push-duplex 5:literal, 1:address:duplex-list + 1:address:duplex-list <- copy 0 # 1 points to head of list + 1:address:duplex-list <- push-duplex 3, 1:address:duplex-list + 1:address:duplex-list <- push-duplex 4, 1:address:duplex-list + 1:address:duplex-list <- push-duplex 5, 1:address:duplex-list 2:address:duplex-list <- next-duplex 1:address:duplex-list # 2 points at second element 2:address:duplex-list <- remove-duplex 2:address:duplex-list - 3:boolean <- equal 2:address:duplex-list, 0:literal + 3:boolean <- equal 2:address:duplex-list, 0 # check structure like before 2:address:duplex-list <- copy 1:address:duplex-list 4:number <- first 2:address:duplex-list @@ -297,10 +297,10 @@ scenario removing-from-duplex-list [ scenario removing-from-start-of-duplex-list [ run [ - 1:address:duplex-list <- copy 0:literal # 1 points to head of list - 1:address:duplex-list <- push-duplex 3:literal, 1:address:duplex-list - 1:address:duplex-list <- push-duplex 4:literal, 1:address:duplex-list - 1:address:duplex-list <- push-duplex 5:literal, 1:address:duplex-list + 1:address:duplex-list <- copy 0 # 1 points to head of list + 1:address:duplex-list <- push-duplex 3, 1:address:duplex-list + 1:address:duplex-list <- push-duplex 4, 1:address:duplex-list + 1:address:duplex-list <- push-duplex 5, 1:address:duplex-list # removing from head? return value matters. 1:address:duplex-list <- remove-duplex 1:address:duplex-list # check structure like before @@ -324,15 +324,15 @@ scenario removing-from-start-of-duplex-list [ scenario removing-from-end-of-duplex-list [ run [ - 1:address:duplex-list <- copy 0:literal # 1 points to head of list - 1:address:duplex-list <- push-duplex 3:literal, 1:address:duplex-list - 1:address:duplex-list <- push-duplex 4:literal, 1:address:duplex-list - 1:address:duplex-list <- push-duplex 5:literal, 1:address:duplex-list + 1:address:duplex-list <- copy 0 # 1 points to head of list + 1:address:duplex-list <- push-duplex 3, 1:address:duplex-list + 1:address:duplex-list <- push-duplex 4, 1:address:duplex-list + 1:address:duplex-list <- push-duplex 5, 1:address:duplex-list # delete last element 2:address:duplex-list <- next-duplex 1:address:duplex-list 2:address:duplex-list <- next-duplex 2:address:duplex-list 2:address:duplex-list <- remove-duplex 2:address:duplex-list - 3:boolean <- equal 2:address:duplex-list, 0:literal + 3:boolean <- equal 2:address:duplex-list, 0 # check structure like before 2:address:duplex-list <- copy 1:address:duplex-list 4:number <- first 2:address:duplex-list @@ -355,8 +355,8 @@ scenario removing-from-end-of-duplex-list [ scenario removing-from-singleton-list [ run [ - 1:address:duplex-list <- copy 0:literal # 1 points to singleton list - 1:address:duplex-list <- push-duplex 3:literal, 1:address:duplex-list + 1:address:duplex-list <- copy 0 # 1 points to singleton list + 1:address:duplex-list <- push-duplex 3, 1:address:duplex-list 2:address:duplex-list <- remove-duplex 1:address:duplex-list 3:address:duplex-list <- get 1:address:duplex-list/deref, next:offset 4:address:duplex-list <- get 1:address:duplex-list/deref, prev:offset diff --git a/066stream.mu b/066stream.mu index 7bdf36a5..4c77319a 100644 --- a/066stream.mu +++ b/066stream.mu @@ -8,7 +8,7 @@ recipe new-stream [ local-scope result:address:stream <- new stream:type i:address:number <- get-address result:address:stream/deref, index:offset - i:address:number/deref <- copy 0:literal + i:address:number/deref <- copy 0 d:address:address:array:character <- get-address result:address:stream/deref, data:offset d:address:address:array:character/deref <- next-ingredient reply result:address:stream @@ -18,7 +18,7 @@ recipe rewind-stream [ local-scope in:address:stream <- next-ingredient x:address:number <- get-address in:address:stream/deref, index:offset - x:address:number/deref <- copy 0:literal + x:address:number/deref <- copy 0 reply in:address:stream/same-as-arg:0 ] @@ -27,9 +27,9 @@ recipe read-line [ in:address:stream <- next-ingredient idx:address:number <- get-address in:address:stream/deref, index:offset s:address:array:character <- get in:address:stream/deref, data:offset - next-idx:number <- find-next s:address:array:character, 10:literal/newline, idx:address:number/deref + next-idx:number <- find-next s:address:array:character, 10/newline, idx:address:number/deref result:address:array:character <- string-copy s:address:array:character, idx:address:number/deref, next-idx:number - idx:address:number/deref <- add next-idx:number, 1:literal # skip newline + idx:address:number/deref <- add next-idx:number, 1 # skip newline reply result:address:array:character ] diff --git a/071print.mu b/071print.mu index b970b02e..a1c7b67d 100644 --- a/071print.mu +++ b/071print.mu @@ -21,11 +21,11 @@ recipe new-fake-screen [ width:address:number/deref <- next-ingredient height:address:number <- get-address result:address:screen/deref, num-rows:offset height:address:number/deref <- next-ingredient -#? $print height:address:number/deref, 10:literal/newline +#? $print height:address:number/deref, 10/newline row:address:number <- get-address result:address:screen/deref, cursor-row:offset - row:address:number/deref <- copy 0:literal + row:address:number/deref <- copy 0 column:address:number <- get-address result:address:screen/deref, cursor-column:offset - column:address:number/deref <- copy 0:literal + column:address:number/deref <- copy 0 bufsize:number <- multiply width:address:number/deref, height:address:number/deref buf:address:address:array:screen-cell <- get-address result:address:screen/deref, data:offset buf:address:address:array:screen-cell/deref <- new screen-cell:type, bufsize:number @@ -44,7 +44,7 @@ recipe clear-screen [ # clear fake screen buf:address:array:screen-cell <- get x:address:screen/deref, data:offset max:number <- length buf:address:array:screen-cell/deref - i:number <- copy 0:literal + i:number <- copy 0 { done?:boolean <- greater-or-equal i:number, max:number break-if done?:boolean @@ -52,15 +52,15 @@ recipe clear-screen [ curr-content:address:character <- get-address curr:address:screen-cell/deref, contents:offset curr-content:address:character/deref <- copy [ ] curr-color:address:character <- get-address curr:address:screen-cell/deref, color:offset - curr-color:address:character/deref <- copy 7:literal/white - i:number <- add i:number, 1:literal + curr-color:address:character/deref <- copy 7/white + i:number <- add i:number, 1 loop } # reset cursor cur:address:number <- get-address x:address:screen/deref, cursor-row:offset - cur:address:number/deref <- copy 0:literal + cur:address:number/deref <- copy 0 cur:address:number <- get-address x:address:screen/deref, cursor-column:offset - cur:address:number/deref <- copy 0:literal + cur:address:number/deref <- copy 0 reply x:address:screen/same-as-ingredient:0 } # otherwise, real screen @@ -71,21 +71,21 @@ recipe clear-screen [ recipe fake-screen-is-clear? [ local-scope screen:address:screen <- next-ingredient - reply-unless screen:address:screen, 1:literal/true + reply-unless screen:address:screen, 1/true buf:address:array:screen-cell <- get screen:address:screen/deref, data:offset - i:number <- copy 0:literal + i:number <- copy 0 len:number <- length buf:address:array:screen-cell/deref { done?:boolean <- greater-or-equal i:number, len:number break-if done?:boolean curr:screen-cell <- index buf:address:array:screen-cell/deref, i:number curr-contents:character <- get curr:screen-cell, contents:offset - i:number <- add i:number, 1:literal + i:number <- add i:number, 1 loop-unless curr-contents:character # not 0 - reply 0:literal/false + reply 0/false } - reply 1:literal/true + reply 1/true ] recipe print-character [ @@ -96,13 +96,13 @@ recipe print-character [ { # default color to white break-if color-found?:boolean - color:number <- copy 7:literal/white + color:number <- copy 7/white } bg-color:number, bg-color-found?:boolean <- next-ingredient { # default bg-color to black break-if bg-color-found?:boolean - bg-color:number <- copy 0:literal/black + bg-color:number <- copy 0/black } #? trace [app], [print character] #? 1 { @@ -113,28 +113,28 @@ recipe print-character [ height:number <- get x:address:screen/deref, num-rows:offset # if cursor is out of bounds, silently exit row:address:number <- get-address x:address:screen/deref, cursor-row:offset - legal?:boolean <- greater-or-equal row:address:number/deref, 0:literal + legal?:boolean <- greater-or-equal row:address:number/deref, 0 reply-unless legal?:boolean, x:address:screen legal?:boolean <- lesser-than row:address:number/deref, height:number reply-unless legal?:boolean, x:address:screen column:address:number <- get-address x:address:screen/deref, cursor-column:offset - legal?:boolean <- greater-or-equal column:address:number/deref, 0:literal + legal?:boolean <- greater-or-equal column:address:number/deref, 0 reply-unless legal?:boolean, x:address:screen legal?:boolean <- lesser-than column:address:number/deref, width:number reply-unless legal?:boolean, x:address:screen # special-case: newline { - newline?:boolean <- equal c:character, 10:literal/newline -#? $print c:character, [ ], newline?:boolean, 10:literal/newline + newline?:boolean <- equal c:character, 10/newline +#? $print c:character, [ ], newline?:boolean, 10/newline break-unless newline?:boolean { # unless cursor is already at bottom - bottom:number <- subtract height:number, 1:literal + bottom:number <- subtract height:number, 1 at-bottom?:boolean <- greater-or-equal row:address:number/deref, bottom:number break-if at-bottom?:boolean # move it to the next row - column:address:number/deref <- copy 0:literal - row:address:number/deref <- add row:address:number/deref, 1:literal + column:address:number/deref <- copy 0 + row:address:number/deref <- add row:address:number/deref, 1 } reply x:address:screen/same-as-ingredient:0 } @@ -145,24 +145,24 @@ recipe print-character [ len:number <- length buf:address:array:screen-cell/deref # special-case: backspace { - backspace?:boolean <- equal c:character, 8:literal + backspace?:boolean <- equal c:character, 8 break-unless backspace?:boolean { # unless cursor is already at left margin - at-left?:boolean <- lesser-or-equal column:address:number/deref, 0:literal + at-left?:boolean <- lesser-or-equal column:address:number/deref, 0 break-if at-left?:boolean # clear previous location - column:address:number/deref <- subtract column:address:number/deref, 1:literal - index:number <- subtract index:number, 1:literal + column:address:number/deref <- subtract column:address:number/deref, 1 + index:number <- subtract index:number, 1 cursor:address:screen-cell <- index-address buf:address:array:screen-cell/deref, index:number cursor-contents:address:character <- get-address cursor:address:screen-cell/deref, contents:offset cursor-color:address:number <- get-address cursor:address:screen-cell/deref, color:offset - cursor-contents:address:character/deref <- copy 32:literal/space - cursor-color:address:number/deref <- copy 7:literal/white + cursor-contents:address:character/deref <- copy 32/space + cursor-color:address:number/deref <- copy 7/white } reply x:address:screen/same-as-ingredient:0 } -#? $print [saving character ], c:character, [ to fake screen ], cursor:address/screen, 10:literal/newline +#? $print [saving character ], c:character, [ to fake screen ], cursor:address/screen, 10/newline cursor:address:screen-cell <- index-address buf:address:array:screen-cell/deref, index:number cursor-contents:address:character <- get-address cursor:address:screen-cell/deref, contents:offset cursor-color:address:number <- get-address cursor:address:screen-cell/deref, color:offset @@ -170,10 +170,10 @@ recipe print-character [ cursor-color:address:number/deref <- copy color:number # increment column unless it's already all the way to the right { - right:number <- subtract width:number, 1:literal + right:number <- subtract width:number, 1 at-right?:boolean <- greater-or-equal column:address:number/deref, right:number break-if at-right?:boolean - column:address:number/deref <- add column:address:number/deref, 1:literal + column:address:number/deref <- add column:address:number/deref, 1 } reply x:address:screen/same-as-ingredient:0 } @@ -185,8 +185,8 @@ recipe print-character [ scenario print-character-at-top-left [ run [ #? $start-tracing #? 3 - 1:address:screen <- new-fake-screen 3:literal/width, 2:literal/height - 1:address:screen <- print-character 1:address:screen, 97:literal # 'a' + 1:address:screen <- new-fake-screen 3/width, 2/height + 1:address:screen <- print-character 1:address:screen, 97 # 'a' 2:address:array:screen-cell <- get 1:address:screen/deref, data:offset 3:array:screen-cell <- copy 2:address:array:screen-cell/deref ] @@ -200,8 +200,8 @@ scenario print-character-at-top-left [ scenario print-character-color [ run [ - 1:address:screen <- new-fake-screen 3:literal/width, 2:literal/height - 1:address:screen <- print-character 1:address:screen, 97:literal/a, 1:literal/red + 1:address:screen <- new-fake-screen 3/width, 2/height + 1:address:screen <- print-character 1:address:screen, 97/a, 1/red 2:address:array:screen-cell <- get 1:address:screen/deref, data:offset 3:array:screen-cell <- copy 2:address:array:screen-cell/deref ] @@ -216,9 +216,9 @@ scenario print-character-color [ scenario print-backspace-character [ run [ #? $start-tracing #? 3 - 1:address:screen <- new-fake-screen 3:literal/width, 2:literal/height - 1:address:screen <- print-character 1:address:screen, 97:literal # 'a' - 1:address:screen <- print-character 1:address:screen, 8:literal # backspace + 1:address:screen <- new-fake-screen 3/width, 2/height + 1:address:screen <- print-character 1:address:screen, 97 # 'a' + 1:address:screen <- print-character 1:address:screen, 8 # backspace 2:number <- get 1:address:screen/deref, cursor-column:offset 3:address:array:screen-cell <- get 1:address:screen/deref, data:offset 4:array:screen-cell <- copy 3:address:array:screen-cell/deref @@ -234,10 +234,10 @@ scenario print-backspace-character [ scenario print-extra-backspace-character [ run [ - 1:address:screen <- new-fake-screen 3:literal/width, 2:literal/height - 1:address:screen <- print-character 1:address:screen, 97:literal # 'a' - 1:address:screen <- print-character 1:address:screen, 8:literal # backspace - 1:address:screen <- print-character 1:address:screen, 8:literal # backspace + 1:address:screen <- new-fake-screen 3/width, 2/height + 1:address:screen <- print-character 1:address:screen, 97 # 'a' + 1:address:screen <- print-character 1:address:screen, 8 # backspace + 1:address:screen <- print-character 1:address:screen, 8 # backspace 2:number <- get 1:address:screen/deref, cursor-column:offset 3:address:array:screen-cell <- get 1:address:screen/deref, data:offset 4:array:screen-cell <- copy 3:address:array:screen-cell/deref @@ -253,10 +253,10 @@ scenario print-extra-backspace-character [ scenario print-at-right-margin [ run [ - 1:address:screen <- new-fake-screen 2:literal/width, 2:literal/height - 1:address:screen <- print-character 1:address:screen, 97:literal # 'a' - 1:address:screen <- print-character 1:address:screen, 98:literal # 'b' - 1:address:screen <- print-character 1:address:screen, 99:literal # 'c' + 1:address:screen <- new-fake-screen 2/width, 2/height + 1:address:screen <- print-character 1:address:screen, 97 # 'a' + 1:address:screen <- print-character 1:address:screen, 98 # 'b' + 1:address:screen <- print-character 1:address:screen, 99 # 'c' 2:number <- get 1:address:screen/deref, cursor-column:offset 3:address:array:screen-cell <- get 1:address:screen/deref, data:offset 4:array:screen-cell <- copy 3:address:array:screen-cell/deref @@ -275,9 +275,9 @@ scenario print-at-right-margin [ scenario print-newline-character [ run [ #? $start-tracing #? 3 - 1:address:screen <- new-fake-screen 3:literal/width, 2:literal/height - 1:address:screen <- print-character 1:address:screen, 97:literal # 'a' - 1:address:screen <- print-character 1:address:screen, 10:literal/newline + 1:address:screen <- new-fake-screen 3/width, 2/height + 1:address:screen <- print-character 1:address:screen, 97 # 'a' + 1:address:screen <- print-character 1:address:screen, 10/newline 2:number <- get 1:address:screen/deref, cursor-row:offset 3:number <- get 1:address:screen/deref, cursor-column:offset 4:address:array:screen-cell <- get 1:address:screen/deref, data:offset @@ -295,10 +295,10 @@ scenario print-newline-character [ scenario print-newline-at-bottom-line [ run [ - 1:address:screen <- new-fake-screen 3:literal/width, 2:literal/height - 1:address:screen <- print-character 1:address:screen, 10:literal/newline - 1:address:screen <- print-character 1:address:screen, 10:literal/newline - 1:address:screen <- print-character 1:address:screen, 10:literal/newline + 1:address:screen <- new-fake-screen 3/width, 2/height + 1:address:screen <- print-character 1:address:screen, 10/newline + 1:address:screen <- print-character 1:address:screen, 10/newline + 1:address:screen <- print-character 1:address:screen, 10/newline 2:number <- get 1:address:screen/deref, cursor-row:offset 3:number <- get 1:address:screen/deref, cursor-column:offset ] @@ -310,13 +310,13 @@ scenario print-newline-at-bottom-line [ scenario print-at-bottom-right [ run [ - 1:address:screen <- new-fake-screen 2:literal/width, 2:literal/height - 1:address:screen <- print-character 1:address:screen, 10:literal/newline - 1:address:screen <- print-character 1:address:screen, 97:literal # 'a' - 1:address:screen <- print-character 1:address:screen, 98:literal # 'b' - 1:address:screen <- print-character 1:address:screen, 99:literal # 'c' - 1:address:screen <- print-character 1:address:screen, 10:literal/newline - 1:address:screen <- print-character 1:address:screen, 100:literal # 'd' + 1:address:screen <- new-fake-screen 2/width, 2/height + 1:address:screen <- print-character 1:address:screen, 10/newline + 1:address:screen <- print-character 1:address:screen, 97 # 'a' + 1:address:screen <- print-character 1:address:screen, 98 # 'b' + 1:address:screen <- print-character 1:address:screen, 99 # 'c' + 1:address:screen <- print-character 1:address:screen, 10/newline + 1:address:screen <- print-character 1:address:screen, 100 # 'd' 2:number <- get 1:address:screen/deref, cursor-row:offset 3:number <- get 1:address:screen/deref, cursor-column:offset 4:address:array:screen-cell <- get 1:address:screen/deref, data:offset @@ -350,8 +350,8 @@ recipe clear-line [ # space over the entire line #? $start-tracing #? 1 { -#? $print column:address:number/deref, 10:literal/newline - right:number <- subtract width:number, 1:literal +#? $print column:address:number/deref, 10/newline + right:number <- subtract width:number, 1 done?:boolean <- greater-or-equal column:address:number/deref, right:number break-if done?:boolean print-character x:address:screen, [ ] # implicitly updates 'column' @@ -402,11 +402,11 @@ recipe move-cursor [ scenario clear-line-erases-printed-characters [ run [ #? $start-tracing #? 4 - 1:address:screen <- new-fake-screen 3:literal/width, 2:literal/height + 1:address:screen <- new-fake-screen 3/width, 2/height # print a character - 1:address:screen <- print-character 1:address:screen, 97:literal # 'a' + 1:address:screen <- print-character 1:address:screen, 97 # 'a' # move cursor to start of line - 1:address:screen <- move-cursor 1:address:screen, 0:literal/row, 0:literal/column + 1:address:screen <- move-cursor 1:address:screen, 0/row, 0/column # clear line 1:address:screen <- clear-line 1:address:screen 2:address:array:screen-cell <- get 1:address:screen/deref, data:offset @@ -440,13 +440,13 @@ recipe cursor-down [ # if row < height-1 height:number <- get x:address:screen/deref, num-rows:offset row:address:number <- get-address x:address:screen/deref, cursor-row:offset - max:number <- subtract height:number, 1:literal + max:number <- subtract height:number, 1 at-bottom?:boolean <- greater-or-equal row:address:number/deref, max:number break-if at-bottom?:boolean # row = row+1 -#? $print [AAA: ], row:address:number, [ -> ], row:address:number/deref, 10:literal/newline - row:address:number/deref <- add row:address:number/deref, 1:literal -#? $print [BBB: ], row:address:number, [ -> ], row:address:number/deref, 10:literal/newline +#? $print [AAA: ], row:address:number, [ -> ], row:address:number/deref, 10/newline + row:address:number/deref <- add row:address:number/deref, 1 +#? $print [BBB: ], row:address:number, [ -> ], row:address:number/deref, 10/newline #? $start-tracing #? 1 } reply x:address:screen/same-as-ingredient:0 @@ -465,10 +465,10 @@ recipe cursor-up [ { # if row > 0 row:address:number <- get-address x:address:screen/deref, cursor-row:offset - at-top?:boolean <- lesser-or-equal row:address:number/deref, 0:literal + at-top?:boolean <- lesser-or-equal row:address:number/deref, 0 break-if at-top?:boolean # row = row-1 - row:address:number/deref <- subtract row:address:number/deref, 1:literal + row:address:number/deref <- subtract row:address:number/deref, 1 } reply x:address:screen/same-as-ingredient:0 } @@ -487,11 +487,11 @@ recipe cursor-right [ # if column < width-1 width:number <- get x:address:screen/deref, num-columns:offset column:address:number <- get-address x:address:screen/deref, cursor-column:offset - max:number <- subtract width:number, 1:literal + max:number <- subtract width:number, 1 at-bottom?:boolean <- greater-or-equal column:address:number/deref, max:number break-if at-bottom?:boolean # column = column+1 - column:address:number/deref <- add column:address:number/deref, 1:literal + column:address:number/deref <- add column:address:number/deref, 1 } reply x:address:screen/same-as-ingredient:0 } @@ -509,10 +509,10 @@ recipe cursor-left [ { # if column > 0 column:address:number <- get-address x:address:screen/deref, cursor-column:offset - at-top?:boolean <- lesser-or-equal column:address:number/deref, 0:literal + at-top?:boolean <- lesser-or-equal column:address:number/deref, 0 break-if at-top?:boolean # column = column-1 - column:address:number/deref <- subtract column:address:number/deref, 1:literal + column:address:number/deref <- subtract column:address:number/deref, 1 } reply x:address:screen/same-as-ingredient:0 } @@ -525,7 +525,7 @@ recipe cursor-to-start-of-line [ local-scope x:address:screen <- next-ingredient row:number, _, x:address:screen <- cursor-position x:address:screen - column:number <- copy 0:literal + column:number <- copy 0 x:address:screen <- move-cursor x:address:screen, row:number, column:number reply x:address:screen/same-as-ingredient:0 ] @@ -626,22 +626,22 @@ recipe print-string [ { # default color to white break-if color-found?:boolean - color:number <- copy 7:literal/white + color:number <- copy 7/white } bg-color:number, bg-color-found?:boolean <- next-ingredient { # default bg-color to black break-if bg-color-found?:boolean - bg-color:number <- copy 0:literal/black + bg-color:number <- copy 0/black } len:number <- length s:address:array:character/deref - i:number <- copy 0:literal + i:number <- copy 0 { done?:boolean <- greater-or-equal i:number, len:number break-if done?:boolean c:character <- index s:address:array:character/deref, i:number print-character x:address:screen, c:character, color:number, bg-color:number - i:number <- add i:number, 1:literal + i:number <- add i:number, 1 loop } reply x:address:screen/same-as-ingredient:0 @@ -649,7 +649,7 @@ recipe print-string [ scenario print-string-stops-at-right-margin [ run [ - 1:address:screen <- new-fake-screen 3:literal/width, 2:literal/height + 1:address:screen <- new-fake-screen 3/width, 2/height 2:address:array:character <- new [abcd] 1:address:screen <- print-string 1:address:screen, 2:address:array:character 3:address:array:screen-cell <- get 1:address:screen/deref, data:offset @@ -675,13 +675,13 @@ recipe print-integer [ { # default color to white break-if color-found?:boolean - color:number <- copy 7:literal/white + color:number <- copy 7/white } bg-color:number, bg-color-found?:boolean <- next-ingredient { # default bg-color to black break-if bg-color-found?:boolean - bg-color:number <- copy 0:literal/black + bg-color:number <- copy 0/black } # todo: other bases besides decimal s:address:array:character <- integer-to-decimal-string n:number diff --git a/072scenario_screen.cc b/072scenario_screen.cc index d456a8d8..2b885d58 100644 --- a/072scenario_screen.cc +++ b/072scenario_screen.cc @@ -7,9 +7,9 @@ :(scenarios run_mu_scenario) :(scenario screen_in_scenario) scenario screen-in-scenario [ - assume-screen 5:literal/width, 3:literal/height + assume-screen 5/width, 3/height run [ - screen:address <- print-character screen:address, 97:literal # 'a' + screen:address <- print-character screen:address, 97 # 'a' ] screen-should-contain [ # 01234 @@ -21,10 +21,10 @@ scenario screen-in-scenario [ :(scenario screen_in_scenario_unicode) scenario screen-in-scenario-unicode-color [ - assume-screen 5:literal/width, 3:literal/height + assume-screen 5/width, 3/height run [ - screen:address <- print-character screen:address, 955:literal/greek-small-lambda, 1:literal/red - screen:address <- print-character screen:address, 97:literal/a + screen:address <- print-character screen:address, 955/greek-small-lambda, 1/red + screen:address <- print-character screen:address, 97/a ] screen-should-contain [ # 01234 @@ -37,10 +37,10 @@ scenario screen-in-scenario-unicode-color [ :(scenario screen_in_scenario_color) # screen-should-contain can check unicode characters in the fake screen scenario screen-in-scenario-color [ - assume-screen 5:literal/width, 3:literal/height + assume-screen 5/width, 3/height run [ - screen:address <- print-character screen:address, 955:literal/greek-small-lambda, 1:literal/red - screen:address <- print-character screen:address, 97:literal/a, 7:literal/white + screen:address <- print-character screen:address, 955/greek-small-lambda, 1/red + screen:address <- print-character screen:address, 97/a, 7/white ] # screen-should-contain shows everything screen-should-contain [ @@ -51,14 +51,14 @@ scenario screen-in-scenario-color [ ] # screen-should-contain-in-color filters out everything except the given # color, all you see is the 'a' in white. - screen-should-contain-in-color 7:literal/white, [ + screen-should-contain-in-color 7/white, [ # 01234 . a . . . . . ] # ..and the λ in red. - screen-should-contain-in-color 1:literal/red, [ + screen-should-contain-in-color 1/red, [ # 01234 .λ . . . @@ -70,9 +70,9 @@ scenario screen-in-scenario-color [ % Scenario_testing_scenario = true; % Hide_warnings = true; scenario screen-in-scenario-error [ - assume-screen 5:literal/width, 3:literal/height + assume-screen 5/width, 3/height run [ - screen:address <- print-character screen:address, 97:literal # 'a' + screen:address <- print-character screen:address, 97 # 'a' ] screen-should-contain [ # 01234 @@ -88,11 +88,11 @@ scenario screen-in-scenario-error [ % Hide_warnings = true; # screen-should-contain can check unicode characters in the fake screen scenario screen-in-scenario-color [ - assume-screen 5:literal/width, 3:literal/height + assume-screen 5/width, 3/height run [ - screen:address <- print-character screen:address, 97:literal/a, 1:literal/red + screen:address <- print-character screen:address, 97/a, 1/red ] - screen-should-contain-in-color 2:literal/green, [ + screen-should-contain-in-color 2/green, [ # 01234 .a . . . diff --git a/073scenario_screen_test.mu b/073scenario_screen_test.mu index fa1a026c..79831ca0 100644 --- a/073scenario_screen_test.mu +++ b/073scenario_screen_test.mu @@ -1,9 +1,9 @@ # To check our support for screens in scenarios, rewrite tests from print.mu scenario print-character-at-top-left2 [ - assume-screen 3:literal/width, 2:literal/height + assume-screen 3/width, 2/height run [ - screen:address <- print-character screen:address, 97:literal # 'a' + screen:address <- print-character screen:address, 97/a ] screen-should-contain [ .a . @@ -12,12 +12,12 @@ scenario print-character-at-top-left2 [ ] scenario clear-line-erases-printed-characters2 [ - assume-screen 5:literal/width, 3:literal/height + assume-screen 5/width, 3/height run [ # print a character - screen:address <- print-character screen:address, 97:literal # 'a' + screen:address <- print-character screen:address, 97/a # move cursor to start of line - screen:address <- move-cursor screen:address, 0:literal/row, 0:literal/column + screen:address <- move-cursor screen:address, 0/row, 0/column # clear line screen:address <- clear-line screen:address ] diff --git a/074console.mu b/074console.mu index 9c0b2bea..d405f6bd 100644 --- a/074console.mu +++ b/074console.mu @@ -27,7 +27,7 @@ recipe new-fake-console [ buf:address:address:array:character/deref <- next-ingredient #? $stop-tracing #? 1 idx:address:number <- get-address result:address:console/deref, index:offset - idx:address:number/deref <- copy 0:literal + idx:address:number/deref <- copy 0 reply result:address:console ] @@ -43,16 +43,16 @@ recipe read-event [ done?:boolean <- greater-or-equal idx:address:number/deref, max:number break-unless done?:boolean dummy:address:event <- new event:type - reply dummy:address:event/deref, x:address:console/same-as-ingredient:0, 1:literal/found, 1:literal/quit + reply dummy:address:event/deref, x:address:console/same-as-ingredient:0, 1/found, 1/quit } result:event <- index buf:address:array:event/deref, idx:address:number/deref - idx:address:number/deref <- add idx:address:number/deref, 1:literal - reply result:event, x:address:console/same-as-ingredient:0, 1:literal/found, 0:literal/quit + idx:address:number/deref <- add idx:address:number/deref, 1 + reply result:event, x:address:console/same-as-ingredient:0, 1/found, 0/quit } # real event source is infrequent; avoid polling it too much switch result:event, found?:boolean <- check-for-interaction - reply result:event, x:address:console/same-as-ingredient:0, found?:boolean, 0:literal/quit + reply result:event, x:address:console/same-as-ingredient:0, found?:boolean, 0/quit ] # variant of read-event for just keyboard events. Discards everything that @@ -66,14 +66,14 @@ recipe read-key [ console:address <- next-ingredient x:event, console:address, found?:boolean, quit?:boolean <- read-event console:address #? $print [aaa 1] #? 1 - reply-if quit?:boolean, 0:literal, console:address/same-as-ingredient:0, found?:boolean, quit?:boolean + reply-if quit?:boolean, 0, console:address/same-as-ingredient:0, found?:boolean, quit?:boolean #? $print [aaa 2] #? 1 - reply-unless found?:boolean, 0:literal, console:address/same-as-ingredient:0, found?:boolean, quit?:boolean + reply-unless found?:boolean, 0, console:address/same-as-ingredient:0, found?:boolean, quit?:boolean #? $print [aaa 3] #? 1 c:address:character <- maybe-convert x:event, text:variant - reply-unless c:address:character, 0:literal, console:address/same-as-ingredient:0, 0:literal/found, 0:literal/quit + reply-unless c:address:character, 0, console:address/same-as-ingredient:0, 0/found, 0/quit #? $print [aaa 4] #? 1 - reply c:address:character/deref, console:address/same-as-ingredient:0, 1:literal/found, 0:literal/quit + reply c:address:character/deref, console:address/same-as-ingredient:0, 1/found, 0/quit ] recipe send-keys-to-channel [ @@ -108,7 +108,7 @@ recipe has-more-events? [ { break-unless console:address # fake consoles should be plenty fast; never skip - reply 0:literal/false + reply 0/false } result:boolean <- interactions-left? reply result:boolean diff --git a/081run_interactive.cc b/081run_interactive.cc index 2924c330..0299863e 100644 --- a/081run_interactive.cc +++ b/081run_interactive.cc @@ -3,14 +3,14 @@ :(scenario run_interactive_code) recipe main [ - 2:address:array:character <- new [1:number <- copy 34:literal] + 2:address:array:character <- new [1:number <- copy 34] run-interactive 2:address:array:character ] +mem: storing 34 in location 1 :(scenario run_interactive_empty) recipe main [ - 1:address:array:character <- run-interactive 0:literal + 1:address:array:character <- run-interactive 0 ] # result is null +mem: storing 0 in location 1 @@ -100,7 +100,7 @@ bool run_interactive(long long int address) { :(scenario "run_interactive_returns_stringified_result") recipe main [ # try to interactively add 2 and 2 - 1:address:array:character <- new [add 2:literal, 2:literal] + 1:address:array:character <- new [add 2, 2] 2:address:array:character <- run-interactive 1:address:array:character 10:array:character <- copy 2:address:array:character/deref ] diff --git a/Readme.md b/Readme.md index f8f1062c..febce9ec 100644 --- a/Readme.md +++ b/Readme.md @@ -93,7 +93,7 @@ number of them. In particular you can have any number of products. For example, you can perform integer division as follows: ``` - quotient:number, remainder:number <- divide-with-remainder 11:literal, 3:literal + quotient:number, remainder:number <- divide-with-remainder 11, 3 ``` Each reagent provides its name as well as its type separated by a colon. Types @@ -255,14 +255,14 @@ inserting code at them. after +base-case [ # if n=0 return 1 - zero?:boolean <- equal n:number, 0:literal + zero?:boolean <- equal n:number, 0 break-unless zero?:boolean - reply 1:literal + reply 1 ] after +recursive-case [ # return n * factorial(n-1) - x:number <- subtract n:number, 1:literal + x:number <- subtract n:number, 1 subresult:number <- factorial x:number result:number <- multiply subresult:number, n:number reply result:number @@ -289,14 +289,14 @@ Another example, this time with concurrency. recipe main [ start-running thread2:recipe { - $print 34:literal + $print 34 loop } ] recipe thread2 [ { - $print 35:literal + $print 35 loop } ] diff --git a/callcc.mu b/callcc.mu index a08f9c8a..5e8661bb 100644 --- a/callcc.mu +++ b/callcc.mu @@ -12,6 +12,6 @@ recipe f [ recipe g [ c:continuation <- current-continuation # <-- loop back to here - $print 1:literal + $print 1 reply c:continuation # threaded through unmodified after first iteration ] diff --git a/channel.mu b/channel.mu index 94cb2521..eb5b9641 100644 --- a/channel.mu +++ b/channel.mu @@ -5,15 +5,15 @@ recipe producer [ local-scope chan:address:channel <- next-ingredient # n = 0 - n:number <- copy 0:literal + n:number <- copy 0 { - done?:boolean <- lesser-than n:number, 5:literal + done?:boolean <- lesser-than n:number, 5 break-unless done?:boolean # other threads might get between these prints $print [produce: ], n:number, [ ] chan:address:channel <- write chan:address:channel, n:number - n:number <- add n:number, 1:literal + n:number <- add n:number, 1 loop } ] @@ -34,7 +34,7 @@ recipe consumer [ recipe main [ local-scope - chan:address:channel <- new-channel 3:literal + chan:address:channel <- new-channel 3 # create two background 'routines' that communicate by a channel routine1:number <- start-running producer:recipe, chan:address:channel routine2:number <- start-running consumer:recipe, chan:address:channel diff --git a/chessboard.mu b/chessboard.mu index 638b8367..7a0b9d1a 100644 --- a/chessboard.mu +++ b/chessboard.mu @@ -17,7 +17,7 @@ recipe main [ # # Here the console and screen are both 0, which usually indicates real # hardware rather than a fake for testing as you'll see below. - 0:literal/screen, 0:literal/console <- chessboard 0:literal/screen, 0:literal/console + 0/screen, 0/console <- chessboard 0/screen, 0/console close-console # cleanup screen, keyboard and mouse ] @@ -27,7 +27,7 @@ recipe main [ scenario print-board-and-read-move [ $close-trace # administrivia: most scenarios save and check traces, but this one gets too large/slow # we'll make the screen really wide because the program currently prints out a long line - assume-screen 120:literal/width, 20:literal/height + assume-screen 120/width, 20/height # initialize keyboard to type in a move assume-console [ type [a2-a4 @@ -38,7 +38,7 @@ scenario print-board-and-read-move [ #? $browse-trace #? 1 #? $close-trace #? 1 # icon for the cursor - screen:address <- print-character screen:address, 9251:literal # '␣' + screen:address <- print-character screen:address, 9251/␣ ] screen-should-contain [ # 1 2 3 4 5 6 7 8 9 10 11 @@ -74,13 +74,13 @@ recipe chessboard [ local-scope screen:address <- next-ingredient console:address <- next-ingredient -#? $print [screen: ], screen:address, [, console: ], console:address, 10:literal/newline +#? $print [screen: ], screen:address, [, console: ], console:address, 10/newline board:address:array:address:array:character <- initial-position # hook up stdin - stdin:address:channel <- new-channel 10:literal/capacity + stdin:address:channel <- new-channel 10/capacity start-running send-keys-to-channel:recipe, console:address, stdin:address:channel, screen:address # buffer lines in stdin - buffered-stdin:address:channel <- new-channel 10:literal/capacity + buffered-stdin:address:channel <- new-channel 10/capacity start-running buffer-lines:recipe, stdin:address:channel, buffered-stdin:address:channel { msg:address:array:character <- new [Stupid text-mode chessboard. White pieces in uppercase; black pieces in lowercase. No checking for legal moves. @@ -119,17 +119,17 @@ recipe new-board [ initial-position:address:array:number <- next-ingredient # assert(length(initial-position) == 64) len:number <- length initial-position:address:array:number/deref - correct-length?:boolean <- equal len:number, 64:literal + correct-length?:boolean <- equal len:number, 64 assert correct-length?:boolean, [chessboard had incorrect size] # board is an array of pointers to files; file is an array of characters - board:address:array:address:array:character <- new location:type, 8:literal - col:number <- copy 0:literal + board:address:array:address:array:character <- new location:type, 8 + col:number <- copy 0 { - done?:boolean <- equal col:number, 8:literal + done?:boolean <- equal col:number, 8 break-if done?:boolean file:address:address:array:character <- index-address board:address:array:address:array:character/deref, col:number file:address:address:array:character/deref <- new-file initial-position:address:array:number, col:number - col:number <- add col:number, 1:literal + col:number <- add col:number, 1 loop } reply board:address:array:address:array:character @@ -139,16 +139,16 @@ recipe new-file [ local-scope position:address:array:number <- next-ingredient index:number <- next-ingredient - index:number <- multiply index:number, 8:literal - result:address:array:character <- new character:type, 8:literal - row:number <- copy 0:literal + index:number <- multiply index:number, 8 + result:address:array:character <- new character:type, 8 + row:number <- copy 0 { - done?:boolean <- equal row:number, 8:literal + done?:boolean <- equal row:number, 8 break-if done?:boolean dest:address:character <- index-address result:address:array:character/deref, row:number dest:address:character/deref <- index position:address:array:number/deref, index:number - row:number <- add row:number, 1:literal - index:number <- add index:number, 1:literal + row:number <- add row:number, 1 + index:number <- add index:number, 1 loop } reply result:address:array:character @@ -158,31 +158,31 @@ recipe print-board [ local-scope screen:address <- next-ingredient board:address:array:address:array:character <- next-ingredient - row:number <- copy 7:literal # start printing from the top of the board + row:number <- copy 7 # start printing from the top of the board # print each row -#? $print [printing board to screen ], screen:address, 10:literal/newline +#? $print [printing board to screen ], screen:address, 10/newline { - done?:boolean <- lesser-than row:number, 0:literal + done?:boolean <- lesser-than row:number, 0 break-if done?:boolean -#? $print [printing rank ], row:number, 10:literal/newline +#? $print [printing rank ], row:number, 10/newline # print rank number as a legend - rank:number <- add row:number, 1:literal + rank:number <- add row:number, 1 print-integer screen:address, rank:number s:address:array:character <- new [ | ] print-string screen:address, s:address:array:character # print each square in the row - col:number <- copy 0:literal + col:number <- copy 0 { - done?:boolean <- equal col:number, 8:literal + done?:boolean <- equal col:number, 8 break-if done?:boolean f:address:array:character <- index board:address:array:address:array:character/deref, col:number c:character <- index f:address:array:character/deref, row:number print-character screen:address, c:character - print-character screen:address, 32:literal # ' ' - col:number <- add col:number, 1:literal + print-character screen:address, 32/space + col:number <- add col:number, 1 loop } - row:number <- subtract row:number, 1:literal + row:number <- subtract row:number, 1 cursor-to-next-line screen:address loop } @@ -192,7 +192,7 @@ recipe print-board [ s:address:array:character <- new [ +----------------] print-string screen:address, s:address:array:character screen:address <- cursor-to-next-line screen:address -#? screen:address <- print-character screen:address, 97:literal #? 1 +#? screen:address <- print-character screen:address, 97 #? 1 s:address:array:character <- new [ a b c d e f g h] screen:address <- print-string screen:address, s:address:array:character screen:address <- cursor-to-next-line screen:address @@ -212,21 +212,21 @@ recipe initial-position [ # B P _ _ _ _ p B # N P _ _ _ _ p n # R P _ _ _ _ p r - initial-position:address:array:number <- new-array 82:literal/R, 80:literal/P, 32:literal/blank, 32:literal/blank, 32:literal/blank, 32:literal/blank, 112:literal/p, 114:literal/r, 78:literal/N, 80:literal/P, 32:literal/blank, 32:literal/blank, 32:literal/blank, 32:literal/blank, 112:literal/p, 110:literal/n, 66:literal/B, 80:literal/P, 32:literal/blank, 32:literal/blank, 32:literal/blank, 32:literal/blank, 112:literal/p, 98:literal/b, 81:literal/Q, 80:literal/P, 32:literal/blank, 32:literal/blank, 32:literal/blank, 32:literal/blank, 112:literal/p, 113:literal/q, 75:literal/K, 80:literal/P, 32:literal/blank, 32:literal/blank, 32:literal/blank, 32:literal/blank, 112:literal/p, 107:literal/k, 66:literal/B, 80:literal/P, 32:literal/blank, 32:literal/blank, 32:literal/blank, 32:literal/blank, 112:literal/p, 98:literal/b, 78:literal/N, 80:literal/P, 32:literal/blank, 32:literal/blank, 32:literal/blank, 32:literal/blank, 112:literal/p, 110:literal/n, 82:literal/R, 80:literal/P, 32:literal/blank, 32:literal/blank, 32:literal/blank, 32:literal/blank, 112:literal/p, 114:literal/r -#? 82:literal/R, 80:literal/P, 32:literal/blank, 32:literal/blank, 32:literal/blank, 32:literal/blank, 112:literal/p, 114:literal/r, -#? 78:literal/N, 80:literal/P, 32:literal/blank, 32:literal/blank, 32:literal/blank, 32:literal/blank, 112:literal/p, 110:literal/n, -#? 66:literal/B, 80:literal/P, 32:literal/blank, 32:literal/blank, 32:literal/blank, 32:literal/blank, 112:literal/p, 98:literal/b, -#? 81:literal/Q, 80:literal/P, 32:literal/blank, 32:literal/blank, 32:literal/blank, 32:literal/blank, 112:literal/p, 113:literal/q, -#? 75:literal/K, 80:literal/P, 32:literal/blank, 32:literal/blank, 32:literal/blank, 32:literal/blank, 112:literal/p, 107:literal/k, -#? 66:literal/B, 80:literal/P, 32:literal/blank, 32:literal/blank, 32:literal/blank, 32:literal/blank, 112:literal/p, 98:literal/b, -#? 78:literal/N, 80:literal/P, 32:literal/blank, 32:literal/blank, 32:literal/blank, 32:literal/blank, 112:literal/p, 110:literal/n, -#? 82:literal/R, 80:literal/P, 32:literal/blank, 32:literal/blank, 32:literal/blank, 32:literal/blank, 112:literal/p, 114:literal/r + initial-position:address:array:number <- new-array 82/R, 80/P, 32/blank, 32/blank, 32/blank, 32/blank, 112/p, 114/r, 78/N, 80/P, 32/blank, 32/blank, 32/blank, 32/blank, 112/p, 110/n, 66/B, 80/P, 32/blank, 32/blank, 32/blank, 32/blank, 112/p, 98/b, 81/Q, 80/P, 32/blank, 32/blank, 32/blank, 32/blank, 112/p, 113/q, 75/K, 80/P, 32/blank, 32/blank, 32/blank, 32/blank, 112/p, 107/k, 66/B, 80/P, 32/blank, 32/blank, 32/blank, 32/blank, 112/p, 98/b, 78/N, 80/P, 32/blank, 32/blank, 32/blank, 32/blank, 112/p, 110/n, 82/R, 80/P, 32/blank, 32/blank, 32/blank, 32/blank, 112/p, 114/r +#? 82/R, 80/P, 32/blank, 32/blank, 32/blank, 32/blank, 112/p, 114/r, +#? 78/N, 80/P, 32/blank, 32/blank, 32/blank, 32/blank, 112/p, 110/n, +#? 66/B, 80/P, 32/blank, 32/blank, 32/blank, 32/blank, 112/p, 98/b, +#? 81/Q, 80/P, 32/blank, 32/blank, 32/blank, 32/blank, 112/p, 113/q, +#? 75/K, 80/P, 32/blank, 32/blank, 32/blank, 32/blank, 112/p, 107/k, +#? 66/B, 80/P, 32/blank, 32/blank, 32/blank, 32/blank, 112/p, 98/b, +#? 78/N, 80/P, 32/blank, 32/blank, 32/blank, 32/blank, 112/p, 110/n, +#? 82/R, 80/P, 32/blank, 32/blank, 32/blank, 32/blank, 112/p, 114/r board:address:array:address:array:character <- new-board initial-position:address:array:number reply board:address:array:address:array:character ] scenario printing-the-board [ - assume-screen 30:literal/width, 12:literal/height + assume-screen 30/width, 12/height run [ 1:address:array:address:array:character/board <- initial-position screen:address <- print-board screen:address, 1:address:array:address:array:character/board @@ -267,8 +267,8 @@ recipe read-move [ screen:address <- next-ingredient #? $print screen:address #? 1 from-file:number, quit?:boolean, error?:boolean <- read-file stdin:address:channel, screen:address - reply-if quit?:boolean, 0:literal/dummy, quit?:boolean, error?:boolean - reply-if error?:boolean, 0:literal/dummy, quit?:boolean, error?:boolean + reply-if quit?:boolean, 0/dummy, quit?:boolean, error?:boolean + reply-if error?:boolean, 0/dummy, quit?:boolean, error?:boolean #? close-console #? 1 # construct the move object result:address:move <- new move:type @@ -276,21 +276,21 @@ recipe read-move [ x:address:number/deref <- copy from-file:number x:address:number <- get-address result:address:move/deref, from-rank:offset x:address:number/deref, quit?:boolean, error?:boolean <- read-rank stdin:address:channel, screen:address - reply-if quit?:boolean, 0:literal/dummy, quit?:boolean, error?:boolean - reply-if error?:boolean, 0:literal/dummy, quit?:boolean, error?:boolean - error?:boolean <- expect-from-channel stdin:address:channel, 45:literal/dash, screen:address - reply-if error?:boolean, 0:literal/dummy, 0:literal/quit, error?:boolean + reply-if quit?:boolean, 0/dummy, quit?:boolean, error?:boolean + reply-if error?:boolean, 0/dummy, quit?:boolean, error?:boolean + error?:boolean <- expect-from-channel stdin:address:channel, 45/dash, screen:address + reply-if error?:boolean, 0/dummy, 0/quit, error?:boolean x:address:number <- get-address result:address:move/deref, to-file:offset x:address:number/deref, quit?:boolean, error?:boolean <- read-file stdin:address:channel, screen:address - reply-if quit?:boolean, 0:literal/dummy, quit?:boolean, error?:boolean - reply-if error?:boolean, 0:literal/dummy, quit?:boolean, error?:boolean + reply-if quit?:boolean, 0/dummy, quit?:boolean, error?:boolean + reply-if error?:boolean, 0/dummy, quit?:boolean, error?:boolean x:address:number <- get-address result:address:move/deref, to-rank:offset x:address:number/deref, quit?:boolean, error?:boolean <- read-rank stdin:address:channel, screen:address - reply-if quit?:boolean, 0:literal/dummy, quit?:boolean, error?:boolean - reply-if error?:boolean, 0:literal/dummy, quit?:boolean, error?:boolean + reply-if quit?:boolean, 0/dummy, quit?:boolean, error?:boolean + reply-if error?:boolean, 0/dummy, quit?:boolean, error?:boolean #? $exit #? 1 - error?:boolean <- expect-from-channel stdin:address:channel, 10:literal/newline, screen:address - reply-if error?:boolean, 0:literal/dummy, 0:literal/quit, error?:boolean + error?:boolean <- expect-from-channel stdin:address:channel, 10/newline, screen:address + reply-if error?:boolean, 0/dummy, 0/quit, error?:boolean reply result:address:move, quit?:boolean, error?:boolean ] @@ -302,48 +302,48 @@ recipe read-file [ screen:address <- next-ingredient c:character, stdin:address:channel <- read stdin:address:channel { - q-pressed?:boolean <- equal c:character, 81:literal # 'Q' + q-pressed?:boolean <- equal c:character, 81/Q break-unless q-pressed?:boolean - reply 0:literal/dummy, 1:literal/quit, 0:literal/error + reply 0/dummy, 1/quit, 0/error } { - q-pressed?:boolean <- equal c:character, 113:literal # 'q' + q-pressed?:boolean <- equal c:character, 113/q break-unless q-pressed?:boolean - reply 0:literal/dummy, 1:literal/quit, 0:literal/error + reply 0/dummy, 1/quit, 0/error } { - empty-fake-keyboard?:boolean <- equal c:character, 0:literal/eof + empty-fake-keyboard?:boolean <- equal c:character, 0/eof break-unless empty-fake-keyboard?:boolean - reply 0:literal/dummy, 1:literal/quit, 0:literal/error + reply 0/dummy, 1/quit, 0/error } { - newline?:boolean <- equal c:character, 10:literal/newline + newline?:boolean <- equal c:character, 10/newline break-unless newline?:boolean error-message:address:array:character <- new [that's not enough] print-string screen:address, error-message:address:array:character - reply 0:literal/dummy, 0:literal/quit, 1:literal/error + reply 0/dummy, 0/quit, 1/error } - file:number <- subtract c:character, 97:literal # 'a' -#? $print file:number, 10:literal/newline + file:number <- subtract c:character, 97/a +#? $print file:number, 10/newline # 'a' <= file <= 'h' { - above-min:boolean <- greater-or-equal file:number, 0:literal + above-min:boolean <- greater-or-equal file:number, 0 break-if above-min:boolean error-message:address:array:character <- new [file too low: ] print-string screen:address, error-message:address:array:character print-character screen:address, c:character cursor-to-next-line screen:address - reply 0:literal/dummy, 0:literal/quit, 1:literal/error + reply 0/dummy, 0/quit, 1/error } { - below-max:boolean <- lesser-than file:number, 8:literal + below-max:boolean <- lesser-than file:number, 8 break-if below-max:boolean error-message:address:array:character <- new [file too high: ] print-string screen:address, error-message:address:array:character print-character screen:address, c:character - reply 0:literal/dummy, 0:literal/quit, 1:literal/error + reply 0/dummy, 0/quit, 1/error } - reply file:number, 0:literal/quit, 0:literal/error + reply file:number, 0/quit, 0/error ] # rank:number <- read-rank stdin:address:channel, screen:address @@ -354,42 +354,42 @@ recipe read-rank [ screen:address <- next-ingredient c:character, stdin:address:channel <- read stdin:address:channel { - q-pressed?:boolean <- equal c:character, 81:literal # 'Q' + q-pressed?:boolean <- equal c:character, 8/Q break-unless q-pressed?:boolean - reply 0:literal/dummy, 1:literal/quit, 0:literal/error + reply 0/dummy, 1/quit, 0/error } { - q-pressed?:boolean <- equal c:character, 113:literal # 'q' + q-pressed?:boolean <- equal c:character, 113/q break-unless q-pressed?:boolean - reply 0:literal/dummy, 1:literal/quit, 0:literal/error + reply 0/dummy, 1/quit, 0/error } { - newline?:boolean <- equal c:character, 10:literal # newline + newline?:boolean <- equal c:character, 10 # newline break-unless newline?:boolean error-message:address:array:character <- new [that's not enough] print-string screen:address, error-message:address:array:character - reply 0:literal/dummy, 0:literal/quit, 1:literal/error + reply 0/dummy, 0/quit, 1/error } - rank:number <- subtract c:character, 49:literal # '1' -#? $print rank:number, 10:literal/newline + rank:number <- subtract c:character, 49/'1' +#? $print rank:number, 10/newline # assert'1' <= rank <= '8' { - above-min:boolean <- greater-or-equal rank:number, 0:literal + above-min:boolean <- greater-or-equal rank:number, 0 break-if above-min:boolean error-message:address:array:character <- new [rank too low: ] print-string screen:address, error-message:address:array:character print-character screen:address, c:character - reply 0:literal/dummy, 0:literal/quit, 1:literal/error + reply 0/dummy, 0/quit, 1/error } { - below-max:boolean <- lesser-or-equal rank:number, 7:literal + below-max:boolean <- lesser-or-equal rank:number, 7 break-if below-max:boolean error-message:address:array:character <- new [rank too high: ] print-string screen:address, error-message:address:array:character print-character screen:address, c:character - reply 0:literal/dummy, 0:literal/quit, 1:literal/error + reply 0/dummy, 0/quit, 1/error } - reply rank:number, 0:literal/quit, 0:literal/error + reply rank:number, 0/quit, 0/error ] # read a character from the given channel and check that it's what we expect @@ -411,80 +411,80 @@ recipe expect-from-channel [ ] scenario read-move-blocking [ - assume-screen 20:literal/width, 2:literal/height + assume-screen 20/width, 2/height run [ #? $start-tracing #? 1 - 1:address:channel <- new-channel 2:literal -#? $print [aaa channel address: ], 1:address:channel, 10:literal/newline + 1:address:channel <- new-channel 2 +#? $print [aaa channel address: ], 1:address:channel, 10/newline 2:number/routine <- start-running read-move:recipe, 1:address:channel, screen:address # 'read-move' is waiting for input wait-for-routine 2:number -#? $print [bbb channel address: ], 1:address:channel, 10:literal/newline +#? $print [bbb channel address: ], 1:address:channel, 10/newline 3:number <- routine-state 2:number/id -#? $print [I: routine ], 2:number, [ state ], 3:number 10:literal/newline - 4:boolean/waiting? <- equal 3:number/routine-state, 2:literal/waiting +#? $print [I: routine ], 2:number, [ state ], 3:number 10/newline + 4:boolean/waiting? <- equal 3:number/routine-state, 2/waiting assert 4:boolean/waiting?, [ F read-move-blocking: routine failed to pause after coming up (before any keys were pressed)] # press 'a' -#? $print [ccc channel address: ], 1:address:channel, 10:literal/newline +#? $print [ccc channel address: ], 1:address:channel, 10/newline #? $exit #? 1 - 1:address:channel <- write 1:address:channel, 97:literal # 'a' + 1:address:channel <- write 1:address:channel, 97/a restart 2:number/routine # 'read-move' still waiting for input wait-for-routine 2:number 3:number <- routine-state 2:number/id -#? $print [II: routine ], 2:number, [ state ], 3:number 10:literal/newline - 4:boolean/waiting? <- equal 3:number/routine-state, 2:literal/waiting +#? $print [II: routine ], 2:number, [ state ], 3:number 10/newline + 4:boolean/waiting? <- equal 3:number/routine-state, 2/waiting assert 4:boolean/waiting?, [ F read-move-blocking: routine failed to pause after rank 'a'] # press '2' - 1:address:channel <- write 1:address:channel, 50:literal # '2' + 1:address:channel <- write 1:address:channel, 50/'2' restart 2:number/routine # 'read-move' still waiting for input wait-for-routine 2:number 3:number <- routine-state 2:number/id -#? $print [III: routine ], 2:number, [ state ], 3:number 10:literal/newline - 4:boolean/waiting? <- equal 3:number/routine-state, 2:literal/waiting +#? $print [III: routine ], 2:number, [ state ], 3:number 10/newline + 4:boolean/waiting? <- equal 3:number/routine-state, 2/waiting assert 4:boolean/waiting?, [ F read-move-blocking: routine failed to pause after file 'a2'] # press '-' - 1:address:channel <- write 1:address:channel, 45:literal # '-' + 1:address:channel <- write 1:address:channel, 45/'-' restart 2:number/routine # 'read-move' still waiting for input wait-for-routine 2:number 3:number <- routine-state 2:number -#? $print [IV: routine ], 2:number, [ state ], 3:number 10:literal/newline - 4:boolean/waiting? <- equal 3:number/routine-state, 2:literal/waiting +#? $print [IV: routine ], 2:number, [ state ], 3:number 10/newline + 4:boolean/waiting? <- equal 3:number/routine-state, 2/waiting assert 4:boolean/waiting?/routine-state, [ F read-move-blocking: routine failed to pause after hyphen 'a2-'] # press 'a' - 1:address:channel <- write 1:address:channel, 97:literal # 'a' + 1:address:channel <- write 1:address:channel, 97/a restart 2:number/routine # 'read-move' still waiting for input wait-for-routine 2:number 3:number <- routine-state 2:number -#? $print [V: routine ], 2:number, [ state ], 3:number 10:literal/newline - 4:boolean/waiting? <- equal 3:number/routine-state, 2:literal/waiting +#? $print [V: routine ], 2:number, [ state ], 3:number 10/newline + 4:boolean/waiting? <- equal 3:number/routine-state, 2/waiting assert 4:boolean/waiting?/routine-state, [ F read-move-blocking: routine failed to pause after rank 'a2-a'] # press '4' - 1:address:channel <- write 1:address:channel, 52:literal # '4' + 1:address:channel <- write 1:address:channel, 52/'4' restart 2:number/routine # 'read-move' still waiting for input wait-for-routine 2:number 3:number <- routine-state 2:number -#? $print [VI: routine ], 2:number, [ state ], 3:number 10:literal/newline - 4:boolean/waiting? <- equal 3:number/routine-state, 2:literal/waiting +#? $print [VI: routine ], 2:number, [ state ], 3:number 10/newline + 4:boolean/waiting? <- equal 3:number/routine-state, 2/waiting assert 4:boolean/waiting?, [ F read-move-blocking: routine failed to pause after file 'a2-a4'] # press 'newline' - 1:address:channel <- write 1:address:channel, 10:literal # newline + 1:address:channel <- write 1:address:channel, 10 # newline restart 2:number/routine # 'read-move' now completes wait-for-routine 2:number 3:number <- routine-state 2:number -#? $print [VII: routine ], 2:number, [ state ], 3:number 10:literal/newline - 4:boolean/completed? <- equal 3:number/routine-state, 1:literal/completed +#? $print [VII: routine ], 2:number, [ state ], 3:number 10/newline + 4:boolean/completed? <- equal 3:number/routine-state, 1/completed assert 4:boolean/completed?, [ F read-move-blocking: routine failed to terminate on newline] trace [test], [reached end] @@ -495,23 +495,23 @@ F read-move-blocking: routine failed to terminate on newline] ] scenario read-move-quit [ - assume-screen 20:literal/width, 2:literal/height + assume-screen 20/width, 2/height run [ - 1:address:channel <- new-channel 2:literal + 1:address:channel <- new-channel 2 2:number/routine <- start-running read-move:recipe, 1:address:channel, screen:address # 'read-move' is waiting for input wait-for-routine 2:number 3:number <- routine-state 2:number/id - 4:boolean/waiting? <- equal 3:number/routine-state, 2:literal/waiting + 4:boolean/waiting? <- equal 3:number/routine-state, 2/waiting assert 4:boolean/waiting?, [ F read-move-quit: routine failed to pause after coming up (before any keys were pressed)] # press 'q' - 1:address:channel <- write 1:address:channel, 113:literal # 'q' + 1:address:channel <- write 1:address:channel, 113/q restart 2:number/routine # 'read-move' completes wait-for-routine 2:number 3:number <- routine-state 2:number/id - 4:boolean/completed? <- equal 3:number/routine-state, 1:literal/completed + 4:boolean/completed? <- equal 3:number/routine-state, 1/completed assert 4:boolean/completed?, [ F read-move-quit: routine failed to terminate on 'q'] trace [test], [reached end] @@ -522,17 +522,17 @@ F read-move-quit: routine failed to terminate on 'q'] ] scenario read-move-illegal-file [ - assume-screen 20:literal/width, 2:literal/height + assume-screen 20/width, 2/height run [ - 1:address:channel <- new-channel 2:literal + 1:address:channel <- new-channel 2 2:number/routine <- start-running read-move:recipe, 1:address:channel, screen:address # 'read-move' is waiting for input wait-for-routine 2:number 3:number <- routine-state 2:number/id - 4:boolean/waiting? <- equal 3:number/routine-state, 2:literal/waiting + 4:boolean/waiting? <- equal 3:number/routine-state, 2/waiting assert 4:boolean/waiting?, [ F read-move-file: routine failed to pause after coming up (before any keys were pressed)] - 1:address:channel <- write 1:address:channel, 50:literal # '2' + 1:address:channel <- write 1:address:channel, 50/'2' restart 2:number/routine wait-for-routine 2:number ] @@ -543,18 +543,18 @@ F read-move-file: routine failed to pause after coming up (before any keys were ] scenario read-move-illegal-rank [ - assume-screen 20:literal/width, 2:literal/height + assume-screen 20/width, 2/height run [ - 1:address:channel <- new-channel 2:literal + 1:address:channel <- new-channel 2 2:number/routine <- start-running read-move:recipe, 1:address:channel, screen:address # 'read-move' is waiting for input wait-for-routine 2:number 3:number <- routine-state 2:number/id - 4:boolean/waiting? <- equal 3:number/routine-state, 2:literal/waiting + 4:boolean/waiting? <- equal 3:number/routine-state, 2/waiting assert 4:boolean/waiting?, [ F read-move-file: routine failed to pause after coming up (before any keys were pressed)] - 1:address:channel <- write 1:address:channel, 97:literal # 'a' - 1:address:channel <- write 1:address:channel, 97:literal # 'a' + 1:address:channel <- write 1:address:channel, 97/a + 1:address:channel <- write 1:address:channel, 97/a restart 2:number/routine wait-for-routine 2:number ] @@ -565,18 +565,18 @@ F read-move-file: routine failed to pause after coming up (before any keys were ] scenario read-move-empty [ - assume-screen 20:literal/width, 2:literal/height + assume-screen 20/width, 2/height run [ - 1:address:channel <- new-channel 2:literal + 1:address:channel <- new-channel 2 2:number/routine <- start-running read-move:recipe, 1:address:channel, screen:address # 'read-move' is waiting for input wait-for-routine 2:number 3:number <- routine-state 2:number/id - 4:boolean/waiting? <- equal 3:number/routine-state, 2:literal/waiting + 4:boolean/waiting? <- equal 3:number/routine-state, 2/waiting assert 4:boolean/waiting?, [ F read-move-file: routine failed to pause after coming up (before any keys were pressed)] - 1:address:channel <- write 1:address:channel, 10:literal/newline - 1:address:channel <- write 1:address:channel, 97:literal # 'a' + 1:address:channel <- write 1:address:channel, 10/newline + 1:address:channel <- write 1:address:channel, 97/a restart 2:number/routine wait-for-routine 2:number ] @@ -591,36 +591,36 @@ recipe make-move [ b:address:array:address:array:character <- next-ingredient m:address:move <- next-ingredient from-file:number <- get m:address:move/deref, from-file:offset -#? $print from-file:number, 10:literal/newline +#? $print from-file:number, 10/newline from-rank:number <- get m:address:move/deref, from-rank:offset -#? $print from-rank:number, 10:literal/newline +#? $print from-rank:number, 10/newline to-file:number <- get m:address:move/deref, to-file:offset -#? $print to-file:number, 10:literal/newline +#? $print to-file:number, 10/newline to-rank:number <- get m:address:move/deref, to-rank:offset -#? $print to-rank:number, 10:literal/newline +#? $print to-rank:number, 10/newline f:address:array:character <- index b:address:array:address:array:character/deref, from-file:number src:address:character/square <- index-address f:address:array:character/deref, from-rank:number f:address:array:character <- index b:address:array:address:array:character/deref, to-file:number dest:address:character/square <- index-address f:address:array:character/deref, to-rank:number -#? $print src:address:character/deref, 10:literal/newline +#? $print src:address:character/deref, 10/newline dest:address:character/deref/square <- copy src:address:character/deref/square - src:address:character/deref/square <- copy 32:literal # ' ' + src:address:character/deref/square <- copy 32/space reply b:address:array:address:array:character/same-as-ingredient:0 ] scenario making-a-move [ - assume-screen 30:literal/width, 12:literal/height + assume-screen 30/width, 12/height run [ 2:address:array:address:array:character/board <- initial-position 3:address:move <- new move:type 4:address:number <- get-address 3:address:move/deref, from-file:offset - 4:address:number/deref <- copy 6:literal/g + 4:address:number/deref <- copy 6/g 5:address:number <- get-address 3:address:move/deref, from-rank:offset - 5:address:number/deref <- copy 1:literal/2 + 5:address:number/deref <- copy 1/'2' 6:address:number <- get-address 3:address:move/deref, to-file:offset - 6:address:number/deref <- copy 6:literal/g + 6:address:number/deref <- copy 6/g 7:address:number <- get-address 3:address:move/deref, to-rank:offset - 7:address:number/deref <- copy 3:literal/4 + 7:address:number/deref <- copy 3/'4' 2:address:array:address:array:character/board <- make-move 2:address:array:address:array:character/board, 3:address:move screen:address <- print-board screen:address, 2:address:array:address:array:character/board ] diff --git a/console.mu b/console.mu index 4073fb9e..0dd59212 100644 --- a/console.mu +++ b/console.mu @@ -7,7 +7,7 @@ recipe main [ { _, found?:boolean <- check-for-interaction break-if found?:boolean - print-character-to-display 97:literal, 7:literal/white + print-character-to-display 97, 7/white loop } close-console diff --git a/counters.mu b/counters.mu index 2d57943d..6428ff9b 100644 --- a/counters.mu +++ b/counters.mu @@ -2,7 +2,7 @@ # (spaces) recipe new-counter [ - default-space:address:array:location <- new location:type, 30:literal + default-space:address:array:location <- new location:type, 30 n:number <- next-ingredient reply default-space:address:array:location ] @@ -18,13 +18,13 @@ recipe increment-counter [ recipe main [ local-scope # counter A - a:address:array:location <- new-counter 34:literal + a:address:array:location <- new-counter 34 # counter B - b:address:array:location <- new-counter 23:literal + b:address:array:location <- new-counter 23 # increment both by 2 but in different ways - increment-counter a:address:array:location, 1:literal - b-value:number <- increment-counter b:address:array:location, 2:literal - a-value:number <- increment-counter a:address:array:location, 1:literal + increment-counter a:address:array:location, 1 + b-value:number <- increment-counter b:address:array:location, 2 + a-value:number <- increment-counter a:address:array:location, 1 # check results $print [Contents of counters ] diff --git a/display.mu b/display.mu index f01c1b43..d00163a1 100644 --- a/display.mu +++ b/display.mu @@ -2,14 +2,14 @@ recipe main [ open-console - print-character-to-display 97:literal, 1:literal/red, 2:literal/green + print-character-to-display 97, 1/red, 2/green 1:number/raw, 2:number/raw <- cursor-position-on-display wait-for-some-interaction clear-display - move-cursor-on-display 0:literal, 4:literal - print-character-to-display 98:literal + move-cursor-on-display 0, 4 + print-character-to-display 98 wait-for-some-interaction - move-cursor-on-display 0:literal, 0:literal + move-cursor-on-display 0, 0 clear-line-on-display wait-for-some-interaction move-cursor-down-on-display diff --git a/edit.mu b/edit.mu index fabae84b..a599fcea 100644 --- a/edit.mu +++ b/edit.mu @@ -5,11 +5,11 @@ recipe main [ open-console initial-recipe:address:array:character <- restore [recipes.mu] initial-sandbox:address:array:character <- new [] - env:address:programming-environment-data <- new-programming-environment 0:literal/screen, initial-recipe:address:array:character, initial-sandbox:address:array:character + env:address:programming-environment-data <- new-programming-environment 0/screen, initial-recipe:address:array:character, initial-sandbox:address:array:character env:address:programming-environment-data <- restore-sandboxes env:address:programming-environment-data - render-all 0:literal/screen, env:address:programming-environment-data - show-screen 0:literal/screen - event-loop 0:literal/screen, 0:literal/console, env:address:programming-environment-data + render-all 0/screen, env:address:programming-environment-data + show-screen 0/screen + event-loop 0/screen, 0/console, env:address:programming-environment-data # never gets here ] @@ -30,22 +30,22 @@ recipe new-programming-environment [ height:number <- screen-height screen:address # top menu result:address:programming-environment-data <- new programming-environment-data:type - draw-horizontal screen:address, 0:literal, 0:literal/left, width:number, 32:literal/space, 0:literal/black, 238:literal/grey - button-start:number <- subtract width:number, 20:literal - button-on-screen?:boolean <- greater-or-equal button-start:number, 0:literal + draw-horizontal screen:address, 0, 0/left, width:number, 32/space, 0/black, 238/grey + button-start:number <- subtract width:number, 20 + button-on-screen?:boolean <- greater-or-equal button-start:number, 0 assert button-on-screen?:boolean, [screen too narrow for menu] - move-cursor screen:address, 0:literal/row, button-start:number/column + move-cursor screen:address, 0/row, button-start:number/column run-button:address:array:character <- new [ run (F4) ] - print-string screen:address, run-button:address:array:character, 255:literal/white, 161:literal/reddish + print-string screen:address, run-button:address:array:character, 255/white, 161/reddish # dotted line down the middle - divider:number, _ <- divide-with-remainder width:number, 2:literal - draw-vertical screen:address, divider:number, 1:literal/top, height:number, 9482:literal/vertical-dotted + divider:number, _ <- divide-with-remainder width:number, 2 + draw-vertical screen:address, divider:number, 1/top, height:number, 9482/vertical-dotted # recipe editor on the left recipes:address:address:editor-data <- get-address result:address:programming-environment-data/deref, recipes:offset - recipes:address:address:editor-data/deref <- new-editor initial-recipe-contents:address:array:character, screen:address, 0:literal/left, divider:number/right + recipes:address:address:editor-data/deref <- new-editor initial-recipe-contents:address:array:character, screen:address, 0/left, divider:number/right # sandbox editor on the right - new-left:number <- add divider:number, 1:literal - new-right:number <- add new-left:number, 5:literal + new-left:number <- add divider:number, 1 + new-right:number <- add new-left:number, 5 current-sandbox:address:address:editor-data <- get-address result:address:programming-environment-data/deref, current-sandbox:offset current-sandbox:address:address:editor-data/deref <- new-editor initial-sandbox-contents:address:array:character, screen:address, new-left:number, width:number screen:address <- render-all screen:address, result:address:programming-environment-data @@ -53,10 +53,10 @@ recipe new-programming-environment [ ] scenario editor-initially-prints-string-to-screen [ - assume-screen 10:literal/width, 5:literal/height + assume-screen 10/width, 5/height run [ 1:address:array:character <- new [abc] - new-editor 1:address:array:character, screen:address, 0:literal/left, 10:literal/right + new-editor 1:address:array:character, screen:address, 0/left, 10/right ] screen-should-contain [ . . @@ -94,7 +94,7 @@ recipe new-editor [ # no clipping of bounds left:number <- next-ingredient right:number <- next-ingredient - right:number <- subtract right:number, 1:literal + right:number <- subtract right:number, 1 result:address:editor-data <- new editor-data:type # initialize screen-related fields x:address:number <- get-address result:address:editor-data/deref, left:offset @@ -103,18 +103,18 @@ recipe new-editor [ x:address:number/deref <- copy right:number # initialize cursor x:address:number <- get-address result:address:editor-data/deref, cursor-row:offset - x:address:number/deref <- copy 1:literal/top + x:address:number/deref <- copy 1/top x:address:number <- get-address result:address:editor-data/deref, cursor-column:offset x:address:number/deref <- copy left:number init:address:address:duplex-list <- get-address result:address:editor-data/deref, data:offset - init:address:address:duplex-list/deref <- push-duplex 167:literal/§, 0:literal/tail + init:address:address:duplex-list/deref <- push-duplex 167/§, 0/tail y:address:address:duplex-list <- get-address result:address:editor-data/deref, before-cursor:offset y:address:address:duplex-list/deref <- copy init:address:address:duplex-list/deref # early exit if s is empty reply-unless s:address:array:character, result:address:editor-data len:number <- length s:address:array:character/deref reply-unless len:number, result:address:editor-data - idx:number <- copy 0:literal + idx:number <- copy 0 # now we can start appending the rest, character by character curr:address:duplex-list <- copy init:address:address:duplex-list/deref { @@ -124,7 +124,7 @@ recipe new-editor [ insert-duplex c:character, curr:address:duplex-list # next iter curr:address:duplex-list <- next-duplex curr:address:duplex-list - idx:number <- add idx:number, 1:literal + idx:number <- add idx:number, 1 loop } # initialize cursor to top of screen @@ -136,9 +136,9 @@ recipe new-editor [ ] scenario editor-initializes-without-data [ - assume-screen 5:literal/width, 3:literal/height + assume-screen 5/width, 3/height run [ - 1:address:editor-data <- new-editor 0:literal/data, screen:address, 2:literal/left, 5:literal/right + 1:address:editor-data <- new-editor 0/data, screen:address, 2/left, 5/right 2:editor-data <- copy 1:address:editor-data/deref ] memory-should-contain [ @@ -161,20 +161,20 @@ recipe render [ local-scope screen:address <- next-ingredient editor:address:editor-data <- next-ingredient - reply-unless editor:address:editor-data, 1:literal/top, screen:address/same-as-ingredient:0 + reply-unless editor:address:editor-data, 1/top, screen:address/same-as-ingredient:0 left:number <- get editor:address:editor-data/deref, left:offset screen-height:number <- screen-height screen:address right:number <- get editor:address:editor-data/deref, right:offset hide-screen screen:address # highlight mu code with color - color:number <- copy 7:literal/white - highlighting-state:number <- copy 0:literal/normal + color:number <- copy 7/white + highlighting-state:number <- copy 0/normal # traversing editor curr:address:duplex-list <- get editor:address:editor-data/deref, data:offset prev:address:duplex-list <- copy curr:address:duplex-list curr:address:duplex-list <- next-duplex curr:address:duplex-list # traversing screen - row:number <- copy 1:literal/top + row:number <- copy 1/top column:number <- copy left:number cursor-row:address:number <- get-address editor:address:editor-data/deref, cursor-row:offset cursor-column:address:number <- get-address editor:address:editor-data/deref, cursor-column:offset @@ -199,7 +199,7 @@ recipe render [ color:number, highlighting-state:number <- get-color color:number, highlighting-state:number, c:character { # newline? move to left rather than 0 - newline?:boolean <- equal c:character, 10:literal/newline + newline?:boolean <- equal c:character, 10/newline break-unless newline?:boolean # adjust cursor if necessary { @@ -213,7 +213,7 @@ recipe render [ # clear rest of line in this window clear-line-delimited screen:address, column:number, right:number # skip to next line - row:number <- add row:number, 1:literal + row:number <- add row:number, 1 column:number <- copy left:number move-cursor screen:address, row:number, column:number curr:address:duplex-list <- next-duplex curr:address:duplex-list @@ -226,9 +226,9 @@ recipe render [ at-right?:boolean <- equal column:number, right:number break-unless at-right?:boolean # print wrap icon - print-character screen:address, 8617:literal/loop-back-to-left, 245:literal/grey + print-character screen:address, 8617/loop-back-to-left, 245/grey column:number <- copy left:number - row:number <- add row:number, 1:literal + row:number <- add row:number, 1 move-cursor screen:address, row:number, column:number # don't increment curr loop +next-character:label @@ -236,7 +236,7 @@ recipe render [ print-character screen:address, c:character, color:number curr:address:duplex-list <- next-duplex curr:address:duplex-list prev:address:duplex-list <- next-duplex prev:address:duplex-list - column:number <- add column:number, 1:literal + column:number <- add column:number, 1 loop } # is cursor to the right of the last line? move to end @@ -254,7 +254,7 @@ recipe render [ too-far-right?:boolean <- greater-than cursor-column:address:number/deref, right:number break-unless too-far-right?:boolean cursor-column:address:number/deref <- copy left:number - cursor-row:address:number/deref <- add cursor-row:address:number/deref, 1:literal + cursor-row:address:number/deref <- add cursor-row:address:number/deref, 1 above-screen-bottom?:boolean <- lesser-than cursor-row:address:number/deref, screen-height:number assert above-screen-bottom?:boolean, [unimplemented: wrapping cursor past bottom of screen] } @@ -277,12 +277,12 @@ recipe render-string [ right:number <- next-ingredient color:number <- next-ingredient row:number <- next-ingredient - row:number <- add row:number, 1:literal + row:number <- add row:number, 1 reply-unless s:address:array:character, row:number/same-as-ingredient:5, screen:address/same-as-ingredient:0 column:number <- copy left:number move-cursor screen:address, row:number, column:number screen-height:number <- screen-height screen:address - i:number <- copy 0:literal + i:number <- copy 0 len:number <- length s:address:array:character/deref { +next-character @@ -296,40 +296,40 @@ recipe render-string [ at-right?:boolean <- equal column:number, right:number break-unless at-right?:boolean # print wrap icon - print-character screen:address, 8617:literal/loop-back-to-left, 245:literal/grey + print-character screen:address, 8617/loop-back-to-left, 245/grey column:number <- copy left:number - row:number <- add row:number, 1:literal + row:number <- add row:number, 1 move-cursor screen:address, row:number, column:number loop +next-character:label # retry i } - i:number <- add i:number, 1:literal + i:number <- add i:number, 1 { # newline? move to left rather than 0 - newline?:boolean <- equal c:character, 10:literal/newline + newline?:boolean <- equal c:character, 10/newline break-unless newline?:boolean # clear rest of line in this window { done?:boolean <- greater-than column:number, right:number break-if done?:boolean - print-character screen:address, 32:literal/space - column:number <- add column:number, 1:literal + print-character screen:address, 32/space + column:number <- add column:number, 1 loop } - row:number <- add row:number, 1:literal + row:number <- add row:number, 1 column:number <- copy left:number move-cursor screen:address, row:number, column:number loop +next-character:label } print-character screen:address, c:character, color:number - column:number <- add column:number, 1:literal + column:number <- add column:number, 1 loop } { # clear rest of current line line-done?:boolean <- greater-than column:number, right:number break-if line-done?:boolean - print-character screen:address, 32:literal/space - column:number <- add column:number, 1:literal + print-character screen:address, 32/space + column:number <- add column:number, 1 loop } reply row:number/same-as-ingredient:5, screen:address/same-as-ingredient:0 @@ -345,23 +345,23 @@ recipe render-screen [ left:number <- next-ingredient right:number <- next-ingredient row:number <- next-ingredient - row:number <- add row:number, 1:literal + row:number <- add row:number, 1 reply-unless s:address:screen, row:number/same-as-ingredient:4, screen:address/same-as-ingredient:0 # print 'screen:' header:address:array:character <- new [screen:] - row:number <- subtract row:number, 1:literal # compensate for render-string below - row:number <- render-string screen:address, header:address:array:character, left:number, right:number, 245:literal/grey, row:number + row:number <- subtract row:number, 1 # compensate for render-string below + row:number <- render-string screen:address, header:address:array:character, left:number, right:number, 245/grey, row:number # newline - row:number <- add row:number, 1:literal + row:number <- add row:number, 1 move-cursor screen:address, row:number, left:number # start printing s column:number <- copy left:number s-width:number <- screen-width s:address:screen s-height:number <- screen-height s:address:screen buf:address:array:screen-cell <- get s:address:screen/deref, data:offset - stop-printing:number <- add left:number, s-width:number, 3:literal + stop-printing:number <- add left:number, s-width:number, 3 max-column:number <- min stop-printing:number, right:number - i:number <- copy 0:literal + i:number <- copy 0 len:number <- length buf:address:array:screen-cell/deref screen-height:number <- screen-height screen:address { @@ -372,33 +372,33 @@ recipe render-screen [ column:number <- copy left:number move-cursor screen:address, row:number, column:number # initial leader for each row: two spaces and a '.' - print-character screen:address, 32:literal/space, 245:literal/grey - print-character screen:address, 32:literal/space, 245:literal/grey - print-character screen:address, 46:literal/full-stop, 245:literal/grey - column:number <- add left:number, 3:literal + print-character screen:address, 32/space, 245/grey + print-character screen:address, 32/space, 245/grey + print-character screen:address, 46/full-stop, 245/grey + column:number <- add left:number, 3 { # print row row-done?:boolean <- greater-or-equal column:number, max-column:number break-if row-done?:boolean curr:screen-cell <- index buf:address:array:screen-cell/deref, i:number c:character <- get curr:screen-cell, contents:offset - print-character screen:address, c:character, 245:literal/grey - column:number <- add column:number, 1:literal - i:number <- add i:number, 1:literal + print-character screen:address, c:character, 245/grey + column:number <- add column:number, 1 + i:number <- add i:number, 1 loop } # print final '.' - print-character screen:address, 46:literal/full-stop, 245:literal/grey - column:number <- add column:number, 1:literal + print-character screen:address, 46/full-stop, 245/grey + column:number <- add column:number, 1 { # clear rest of current line line-done?:boolean <- greater-than column:number, right:number break-if line-done?:boolean - print-character screen:address, 32:literal/space - column:number <- add column:number, 1:literal + print-character screen:address, 32/space + column:number <- add column:number, 1 loop } - row:number <- add row:number, 1:literal + row:number <- add row:number, 1 loop } reply row:number/same-as-ingredient:4, screen:address/same-as-ingredient:0 @@ -413,18 +413,18 @@ recipe clear-line-delimited [ { done?:boolean <- greater-than column:number, right:number break-if done?:boolean - print-character screen:address, 32:literal/space - column:number <- add column:number, 1:literal + print-character screen:address, 32/space + column:number <- add column:number, 1 loop } ] scenario editor-initially-prints-multiple-lines [ - assume-screen 5:literal/width, 5:literal/height + assume-screen 5/width, 5/height run [ s:address:array:character <- new [abc def] - new-editor s:address:array:character, screen:address, 0:literal/left, 5:literal/right + new-editor s:address:array:character, screen:address, 0/left, 5/right ] screen-should-contain [ . . @@ -435,10 +435,10 @@ def] ] scenario editor-initially-handles-offsets [ - assume-screen 5:literal/width, 5:literal/height + assume-screen 5/width, 5/height run [ s:address:array:character <- new [abc] - new-editor s:address:array:character, screen:address, 1:literal/left, 5:literal/right + new-editor s:address:array:character, screen:address, 1/left, 5/right ] screen-should-contain [ . . @@ -448,11 +448,11 @@ scenario editor-initially-handles-offsets [ ] scenario editor-initially-prints-multiple-lines-at-offset [ - assume-screen 5:literal/width, 5:literal/height + assume-screen 5/width, 5/height run [ s:address:array:character <- new [abc def] - new-editor s:address:array:character, screen:address, 1:literal/left, 5:literal/right + new-editor s:address:array:character, screen:address, 1/left, 5/right ] screen-should-contain [ . . @@ -463,10 +463,10 @@ def] ] scenario editor-initially-wraps-long-lines [ - assume-screen 5:literal/width, 5:literal/height + assume-screen 5/width, 5/height run [ s:address:array:character <- new [abc def] - new-editor s:address:array:character, screen:address, 0:literal/left, 5:literal/right + new-editor s:address:array:character, screen:address, 0/left, 5/right ] screen-should-contain [ . . @@ -474,7 +474,7 @@ scenario editor-initially-wraps-long-lines [ .def . . . ] - screen-should-contain-in-color 245:literal/grey [ + screen-should-contain-in-color 245/grey [ . . . ↩. . . @@ -483,10 +483,10 @@ scenario editor-initially-wraps-long-lines [ ] scenario editor-initially-wraps-barely-long-lines [ - assume-screen 5:literal/width, 5:literal/height + assume-screen 5/width, 5/height run [ s:address:array:character <- new [abcde] - new-editor s:address:array:character, screen:address, 0:literal/left, 5:literal/right + new-editor s:address:array:character, screen:address, 0/left, 5/right ] # still wrap, even though the line would fit. We need room to click on the # end of the line @@ -496,7 +496,7 @@ scenario editor-initially-wraps-barely-long-lines [ .e . . . ] - screen-should-contain-in-color 245:literal/grey [ + screen-should-contain-in-color 245/grey [ . . . ↩. . . @@ -505,10 +505,10 @@ scenario editor-initially-wraps-barely-long-lines [ ] scenario editor-initializes-empty-text [ - assume-screen 5:literal/width, 5:literal/height + assume-screen 5/width, 5/height run [ 1:address:array:character <- new [] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address, 0:literal/left, 5:literal/right + 2:address:editor-data <- new-editor 1:address:array:character, screen:address, 0/left, 5/right 3:number <- get 2:address:editor-data/deref, cursor-row:offset 4:number <- get 2:address:editor-data/deref, cursor-column:offset ] @@ -526,12 +526,12 @@ scenario editor-initializes-empty-text [ ## highlighting mu code scenario render-colors-comments [ - assume-screen 5:literal/width, 5:literal/height + assume-screen 5/width, 5/height run [ s:address:array:character <- new [abc # de f] - new-editor s:address:array:character, screen:address, 0:literal/left, 5:literal/right + new-editor s:address:array:character, screen:address, 0/left, 5/right ] screen-should-contain [ . . @@ -540,14 +540,14 @@ f] .f . . . ] - screen-should-contain-in-color 12:literal/lightblue, [ + screen-should-contain-in-color 12/lightblue, [ . . . . .# de . . . . . ] - screen-should-contain-in-color 7:literal/white, [ + screen-should-contain-in-color 7/white, [ . . .abc . . . @@ -562,42 +562,42 @@ recipe get-color [ color:number <- next-ingredient highlighting-state:number <- next-ingredient c:character <- next-ingredient - color-is-white?:boolean <- equal color:number, 7:literal/white -#? $print [character: ], c:character, 10:literal/newline #? 1 + color-is-white?:boolean <- equal color:number, 7/white +#? $print [character: ], c:character, 10/newline #? 1 # if color is white and next character is '#', switch color to blue { break-unless color-is-white?:boolean - starting-comment?:boolean <- equal c:character, 35:literal/# + starting-comment?:boolean <- equal c:character, 35/# break-unless starting-comment?:boolean -#? $print [switch color back to blue], 10:literal/newline #? 1 - color:number <- copy 12:literal/lightblue +#? $print [switch color back to blue], 10/newline #? 1 + color:number <- copy 12/lightblue jump +exit:label } # if color is blue and next character is newline, switch color to white { - color-is-blue?:boolean <- equal color:number, 12:literal/lightblue + color-is-blue?:boolean <- equal color:number, 12/lightblue break-unless color-is-blue?:boolean - ending-comment?:boolean <- equal c:character, 10:literal/newline + ending-comment?:boolean <- equal c:character, 10/newline break-unless ending-comment?:boolean -#? $print [switch color back to white], 10:literal/newline #? 1 - color:number <- copy 7:literal/white +#? $print [switch color back to white], 10/newline #? 1 + color:number <- copy 7/white jump +exit:label } # if color is white (no comments) and next character is '<', switch color to red { break-unless color-is-white?:boolean - starting-assignment?:boolean <- equal c:character, 60:literal/< + starting-assignment?:boolean <- equal c:character, 60/< break-unless starting-assignment?:boolean - color:number <- copy 1:literal/red + color:number <- copy 1/red jump +exit:label } # if color is red and next character is space, switch color to white { - color-is-red?:boolean <- equal color:number, 1:literal/red + color-is-red?:boolean <- equal color:number, 1/red break-unless color-is-red?:boolean - ending-assignment?:boolean <- equal c:character, 32:literal/space + ending-assignment?:boolean <- equal c:character, 32/space break-unless ending-assignment?:boolean - color:number <- copy 7:literal/white + color:number <- copy 7/white jump +exit:label } # otherwise no change @@ -606,12 +606,12 @@ recipe get-color [ ] scenario render-colors-assignment [ - assume-screen 8:literal/width, 5:literal/height + assume-screen 8/width, 5/height run [ s:address:array:character <- new [abc d <- e f] - new-editor s:address:array:character, screen:address, 0:literal/left, 8:literal/right + new-editor s:address:array:character, screen:address, 0/left, 8/right ] screen-should-contain [ . . @@ -620,7 +620,7 @@ f] .f . . . ] - screen-should-contain-in-color 1:literal/red, [ + screen-should-contain-in-color 1/red, [ . . . . . <- . @@ -652,7 +652,7 @@ recipe event-loop [ break-unless k:address:number # F4? load all code and run all sandboxes. { - do-run?:boolean <- equal k:address:number/deref, 65532:literal/F4 + do-run?:boolean <- equal k:address:number/deref, 65532/F4 break-unless do-run?:boolean run-sandboxes env:address:programming-environment-data # F4 might update warnings and results on both sides @@ -667,7 +667,7 @@ recipe event-loop [ break-unless c:address:character # ctrl-n? - switch focus { - ctrl-n?:boolean <- equal c:address:character/deref, 14:literal/ctrl-n + ctrl-n?:boolean <- equal c:address:character/deref, 14/ctrl-n break-unless ctrl-n?:boolean sandbox-in-focus?:address:boolean/deref <- not sandbox-in-focus?:address:boolean/deref update-cursor screen:address, recipes:address:editor-data, current-sandbox:address:editor-data, sandbox-in-focus?:address:boolean/deref @@ -682,14 +682,14 @@ recipe event-loop [ # ignore all but 'left-click' events for now # todo: test this touch-type:number <- get t:address:touch-event/deref, type:offset - is-left-click?:boolean <- equal touch-type:number, 65513:literal/mouse-left + is-left-click?:boolean <- equal touch-type:number, 65513/mouse-left loop-unless is-left-click?:boolean, +next-event:label # on a sandbox delete icon? process delete { was-delete?:boolean <- delete-sandbox t:address:touch-event/deref, env:address:programming-environment-data break-unless was-delete?:boolean #? trace [app], [delete clicked] #? 1 - screen:address <- render-sandbox-side screen:address, env:address:programming-environment-data, 1:literal/clear + screen:address <- render-sandbox-side screen:address, env:address:programming-environment-data, 1/clear update-cursor screen:address, recipes:address:editor-data, current-sandbox:address:editor-data, sandbox-in-focus?:address:boolean/deref show-screen screen:address loop +next-event:label @@ -751,7 +751,7 @@ recipe editor-event-loop [ # clear next line, in case we just processed a backspace left:number <- get editor:address:editor-data/deref, left:offset right:number <- get editor:address:editor-data/deref, right:offset - row:number <- add row:number, 1:literal + row:number <- add row:number, 1 move-cursor screen:address, row:number, left:number clear-line-delimited screen:address, left:number, right:number loop @@ -772,45 +772,45 @@ recipe handle-event [ ## check for special characters # backspace - delete character before cursor { - backspace?:boolean <- equal c:address:character/deref, 8:literal/backspace + backspace?:boolean <- equal c:address:character/deref, 8/backspace break-unless backspace?:boolean delete-before-cursor editor:address:editor-data reply } # ctrl-a - move cursor to start of line { - ctrl-a?:boolean <- equal c:address:character/deref, 1:literal/ctrl-a + ctrl-a?:boolean <- equal c:address:character/deref, 1/ctrl-a break-unless ctrl-a?:boolean move-to-start-of-line editor:address:editor-data reply } # ctrl-e - move cursor to end of line { - ctrl-e?:boolean <- equal c:address:character/deref, 5:literal/ctrl-e + ctrl-e?:boolean <- equal c:address:character/deref, 5/ctrl-e break-unless ctrl-e?:boolean move-to-end-of-line editor:address:editor-data reply } # ctrl-u - delete until start of line (excluding cursor) { - ctrl-u?:boolean <- equal c:address:character/deref, 21:literal/ctrl-u + ctrl-u?:boolean <- equal c:address:character/deref, 21/ctrl-u break-unless ctrl-u?:boolean delete-to-start-of-line editor:address:editor-data reply } # ctrl-k - delete until end of line (including cursor) { - ctrl-k?:boolean <- equal c:address:character/deref, 11:literal/ctrl-k + ctrl-k?:boolean <- equal c:address:character/deref, 11/ctrl-k break-unless ctrl-k?:boolean delete-to-end-of-line editor:address:editor-data reply } # tab - insert two spaces { - tab?:boolean <- equal c:address:character/deref, 9:literal/tab + tab?:boolean <- equal c:address:character/deref, 9/tab break-unless tab?:boolean - insert-at-cursor editor:address:editor-data, 32:literal/space, screen:address - insert-at-cursor editor:address:editor-data, 32:literal/space, screen:address + insert-at-cursor editor:address:editor-data, 32/space, screen:address + insert-at-cursor editor:address:editor-data, 32/space, screen:address reply } # otherwise type it in @@ -830,7 +830,7 @@ recipe handle-event [ # arrows; update cursor-row and cursor-column, leave before-cursor to 'render'. # right arrow { - move-to-next-character?:boolean <- equal k:address:number/deref, 65514:literal/right-arrow + move-to-next-character?:boolean <- equal k:address:number/deref, 65514/right-arrow break-unless move-to-next-character?:boolean # if not at end of text old-cursor:address:duplex-list <- next-duplex before-cursor:address:address:duplex-list/deref @@ -840,9 +840,9 @@ recipe handle-event [ # if crossed a newline, move cursor to start of next row { old-cursor-character:character <- get before-cursor:address:address:duplex-list/deref/deref, value:offset - was-at-newline?:boolean <- equal old-cursor-character:character, 10:literal/newline + was-at-newline?:boolean <- equal old-cursor-character:character, 10/newline break-unless was-at-newline?:boolean - cursor-row:address:number/deref <- add cursor-row:address:number/deref, 1:literal + cursor-row:address:number/deref <- add cursor-row:address:number/deref, 1 cursor-column:address:number/deref <- copy left:number # todo: what happens when cursor is too far down? screen-height:number <- screen-height screen:address @@ -853,16 +853,16 @@ recipe handle-event [ # if the line wraps, move cursor to start of next row { # if we're at the column just before the wrap indicator - wrap-column:number <- subtract right:number, 1:literal + wrap-column:number <- subtract right:number, 1 at-wrap?:boolean <- equal cursor-column:address:number/deref, wrap-column:number break-unless at-wrap?:boolean # and if next character isn't newline new-cursor:address:duplex-list <- next-duplex old-cursor:address:duplex-list break-unless new-cursor:address:duplex-list next-character:character <- get new-cursor:address:duplex-list/deref, value:offset - newline?:boolean <- equal next-character:character, 10:literal/newline + newline?:boolean <- equal next-character:character, 10/newline break-if newline?:boolean - cursor-row:address:number/deref <- add cursor-row:address:number/deref, 1:literal + cursor-row:address:number/deref <- add cursor-row:address:number/deref, 1 cursor-column:address:number/deref <- copy left:number # todo: what happens when cursor is too far down? above-screen-bottom?:boolean <- lesser-than cursor-row:address:number/deref, screen-height:number @@ -870,11 +870,11 @@ recipe handle-event [ reply } # otherwise move cursor one character right - cursor-column:address:number/deref <- add cursor-column:address:number/deref, 1:literal + cursor-column:address:number/deref <- add cursor-column:address:number/deref, 1 } # left arrow { - move-to-previous-character?:boolean <- equal k:address:number/deref, 65515:literal/left-arrow + move-to-previous-character?:boolean <- equal k:address:number/deref, 65515/left-arrow break-unless move-to-previous-character?:boolean #? trace [app], [left arrow] #? 1 # if not at start of text (before-cursor at § sentinel) @@ -882,10 +882,10 @@ recipe handle-event [ break-unless prev:address:duplex-list # if cursor not at left margin, move one character left { - at-left-margin?:boolean <- equal cursor-column:address:number/deref, 0:literal + at-left-margin?:boolean <- equal cursor-column:address:number/deref, 0 break-if at-left-margin?:boolean #? trace [app], [decrementing] #? 1 - cursor-column:address:number/deref <- subtract cursor-column:address:number/deref, 1:literal + cursor-column:address:number/deref <- subtract cursor-column:address:number/deref, 1 reply } # if at left margin, there's guaranteed to be a previous line, since we're @@ -893,54 +893,54 @@ recipe handle-event [ { # if before-cursor is at newline, figure out how long the previous line is prevc:character <- get before-cursor:address:address:duplex-list/deref/deref, value:offset - previous-character-is-newline?:boolean <- equal prevc:character, 10:literal/newline + previous-character-is-newline?:boolean <- equal prevc:character, 10/newline break-unless previous-character-is-newline?:boolean #? trace [app], [previous line] #? 1 # compute length of previous line end-of-line:number <- previous-line-length before-cursor:address:address:duplex-list/deref, d:address:duplex-list - cursor-row:address:number/deref <- subtract cursor-row:address:number/deref, 1:literal + cursor-row:address:number/deref <- subtract cursor-row:address:number/deref, 1 cursor-column:address:number/deref <- copy end-of-line:number reply } # if before-cursor is not at newline, we're just at a wrapped line assert cursor-row:address:number/deref, [unimplemented: moving cursor above top of screen] - cursor-row:address:number/deref <- subtract cursor-row:address:number/deref, 1:literal - cursor-column:address:number/deref <- subtract right:number, 1:literal # leave room for wrap icon + cursor-row:address:number/deref <- subtract cursor-row:address:number/deref, 1 + cursor-column:address:number/deref <- subtract right:number, 1 # leave room for wrap icon } # down arrow { - move-to-next-line?:boolean <- equal k:address:number/deref, 65516:literal/down-arrow + move-to-next-line?:boolean <- equal k:address:number/deref, 65516/down-arrow break-unless move-to-next-line?:boolean # todo: support scrolling already-at-bottom?:boolean <- greater-or-equal cursor-row:address:number/deref, screen-height:number break-if already-at-bottom?:boolean #? $print [moving down #? ] #? 1 - cursor-row:address:number/deref <- add cursor-row:address:number/deref, 1:literal + cursor-row:address:number/deref <- add cursor-row:address:number/deref, 1 # that's it; render will adjust cursor-column as necessary } # up arrow { - move-to-previous-line?:boolean <- equal k:address:number/deref, 65517:literal/up-arrow + move-to-previous-line?:boolean <- equal k:address:number/deref, 65517/up-arrow break-unless move-to-previous-line?:boolean # todo: support scrolling - already-at-top?:boolean <- lesser-or-equal cursor-row:address:number/deref, 1:literal/top + already-at-top?:boolean <- lesser-or-equal cursor-row:address:number/deref, 1/top break-if already-at-top?:boolean #? $print [moving up #? ] #? 1 - cursor-row:address:number/deref <- subtract cursor-row:address:number/deref, 1:literal + cursor-row:address:number/deref <- subtract cursor-row:address:number/deref, 1 # that's it; render will adjust cursor-column as necessary } # home { - home?:boolean <- equal k:address:number/deref, 65521:literal/home + home?:boolean <- equal k:address:number/deref, 65521/home break-unless home?:boolean move-to-start-of-line editor:address:editor-data reply } # end { - end?:boolean <- equal k:address:number/deref, 65520:literal/end + end?:boolean <- equal k:address:number/deref, 65520/end break-unless end?:boolean move-to-end-of-line editor:address:editor-data reply @@ -954,21 +954,21 @@ recipe move-cursor-in-editor [ screen:address <- next-ingredient editor:address:editor-data <- next-ingredient t:touch-event <- next-ingredient - reply-unless editor:address:editor-data, 0:literal/false + reply-unless editor:address:editor-data, 0/false click-column:number <- get t:touch-event, column:offset left:number <- get editor:address:editor-data/deref, left:offset too-far-left?:boolean <- lesser-than click-column:number, left:number - reply-if too-far-left?:boolean, 0:literal/false + reply-if too-far-left?:boolean, 0/false right:number <- get editor:address:editor-data/deref, right:offset too-far-right?:boolean <- greater-than click-column:number, right:number - reply-if too-far-right?:boolean, 0:literal/false + reply-if too-far-right?:boolean, 0/false # update cursor cursor-row:address:number <- get-address editor:address:editor-data/deref, cursor-row:offset cursor-row:address:number/deref <- get t:touch-event, row:offset cursor-column:address:number <- get-address editor:address:editor-data/deref, cursor-column:offset cursor-column:address:number/deref <- get t:touch-event, column:offset # gain focus - reply 1:literal/true + reply 1/true ] recipe insert-at-cursor [ @@ -976,7 +976,7 @@ recipe insert-at-cursor [ editor:address:editor-data <- next-ingredient c:character <- next-ingredient screen:address <- next-ingredient -#? $print [insert ], c:character, 10:literal/newline #? 1 +#? $print [insert ], c:character, 10/newline #? 1 before-cursor:address:address:duplex-list <- get-address editor:address:editor-data/deref, before-cursor:offset insert-duplex c:character, before-cursor:address:address:duplex-list/deref before-cursor:address:address:duplex-list/deref <- next-duplex before-cursor:address:address:duplex-list/deref @@ -987,22 +987,22 @@ recipe insert-at-cursor [ # update cursor: if newline, move cursor to start of next line # todo: bottom of screen { - newline?:boolean <- equal c:character, 10:literal/newline + newline?:boolean <- equal c:character, 10/newline break-unless newline?:boolean - cursor-row:address:number/deref <- add cursor-row:address:number/deref, 1:literal + cursor-row:address:number/deref <- add cursor-row:address:number/deref, 1 cursor-column:address:number/deref <- copy left:number # indent if necessary -#? $print [computing indent], 10:literal/newline #? 1 +#? $print [computing indent], 10/newline #? 1 d:address:duplex-list <- get editor:address:editor-data/deref, data:offset end-of-previous-line:address:duplex-list <- prev-duplex before-cursor:address:address:duplex-list/deref indent:number <- line-indent end-of-previous-line:address:duplex-list, d:address:duplex-list -#? $print indent:number, 10:literal/newline #? 1 - i:number <- copy 0:literal +#? $print indent:number, 10/newline #? 1 + i:number <- copy 0 { indent-done?:boolean <- greater-or-equal i:number, indent:number break-if indent-done?:boolean - insert-at-cursor editor:address:editor-data, 32:literal/space, screen:address - i:number <- add i:number, 1:literal + insert-at-cursor editor:address:editor-data, 32/space, screen:address + i:number <- add i:number, 1 loop } reply @@ -1010,14 +1010,14 @@ recipe insert-at-cursor [ # if the line wraps at the cursor, move cursor to start of next row { # if we're at the column just before the wrap indicator - wrap-column:number <- subtract right:number, 1:literal -#? $print [wrap? ], cursor-column:address:number/deref, [ vs ], wrap-column:number, 10:literal/newline + wrap-column:number <- subtract right:number, 1 +#? $print [wrap? ], cursor-column:address:number/deref, [ vs ], wrap-column:number, 10/newline at-wrap?:boolean <- greater-or-equal cursor-column:address:number/deref, wrap-column:number break-unless at-wrap?:boolean #? $print [wrap! #? ] #? 1 cursor-column:address:number/deref <- subtract cursor-column:address:number/deref, wrap-column:number - cursor-row:address:number/deref <- add cursor-row:address:number/deref, 1:literal + cursor-row:address:number/deref <- add cursor-row:address:number/deref, 1 # todo: what happens when cursor is too far down? screen-height:number <- screen-height screen:address above-screen-bottom?:boolean <- lesser-than cursor-row:address:number/deref, screen-height:number @@ -1027,7 +1027,7 @@ recipe insert-at-cursor [ reply } # otherwise move cursor right - cursor-column:address:number/deref <- add cursor-column:address:number/deref, 1:literal + cursor-column:address:number/deref <- add cursor-column:address:number/deref, 1 ] recipe delete-before-cursor [ @@ -1044,8 +1044,8 @@ recipe delete-before-cursor [ # update cursor before-cursor:address:address:duplex-list/deref <- copy prev:address:duplex-list cursor-column:address:number <- get-address editor:address:editor-data/deref, cursor-column:offset - cursor-column:address:number/deref <- subtract cursor-column:address:number/deref, 1:literal -#? $print [delete-before-cursor: ], cursor-column:address:number/deref, 10:literal/newline + cursor-column:address:number/deref <- subtract cursor-column:address:number/deref, 1 +#? $print [delete-before-cursor: ], cursor-column:address:number/deref, 10/newline ] # takes a pointer 'curr' into the doubly-linked list and its sentinel, counts @@ -1054,7 +1054,7 @@ recipe previous-line-length [ local-scope curr:address:duplex-list <- next-ingredient start:address:duplex-list <- next-ingredient - result:number <- copy 0:literal + result:number <- copy 0 reply-unless curr:address:duplex-list, result:number at-start?:boolean <- equal curr:address:duplex-list, start:address:duplex-list reply-if at-start?:boolean, result:number @@ -1064,9 +1064,9 @@ recipe previous-line-length [ at-start?:boolean <- equal curr:address:duplex-list, start:address:duplex-list break-if at-start?:boolean c:character <- get curr:address:duplex-list/deref, value:offset - at-newline?:boolean <- equal c:character 10:literal/newline + at-newline?:boolean <- equal c:character 10/newline break-if at-newline?:boolean - result:number <- add result:number, 1:literal + result:number <- add result:number, 1 loop } reply result:number @@ -1078,33 +1078,33 @@ recipe line-indent [ local-scope curr:address:duplex-list <- next-ingredient start:address:duplex-list <- next-ingredient - result:number <- copy 0:literal + result:number <- copy 0 reply-unless curr:address:duplex-list, result:number -#? $print [a0], 10:literal/newline #? 1 +#? $print [a0], 10/newline #? 1 at-start?:boolean <- equal curr:address:duplex-list, start:address:duplex-list reply-if at-start?:boolean, result:number -#? $print [a1], 10:literal/newline #? 1 +#? $print [a1], 10/newline #? 1 { curr:address:duplex-list <- prev-duplex curr:address:duplex-list break-unless curr:address:duplex-list -#? $print [a2], 10:literal/newline #? 1 +#? $print [a2], 10/newline #? 1 at-start?:boolean <- equal curr:address:duplex-list, start:address:duplex-list break-if at-start?:boolean -#? $print [a3], 10:literal/newline #? 1 +#? $print [a3], 10/newline #? 1 c:character <- get curr:address:duplex-list/deref, value:offset - at-newline?:boolean <- equal c:character, 10:literal/newline + at-newline?:boolean <- equal c:character, 10/newline break-if at-newline?:boolean -#? $print [a4], 10:literal/newline #? 1 +#? $print [a4], 10/newline #? 1 # if c is a space, increment result - is-space?:boolean <- equal c:character, 32:literal/space + is-space?:boolean <- equal c:character, 32/space { break-unless is-space?:boolean - result:number <- add result:number, 1:literal + result:number <- add result:number, 1 } # if c is not a space, reset result { break-if is-space?:boolean - result:number <- copy 0:literal + result:number <- copy 0 } loop } @@ -1126,7 +1126,7 @@ recipe move-to-start-of-line [ at-start-of-text?:boolean <- equal before-cursor:address:address:duplex-list/deref, init:address:duplex-list break-if at-start-of-text?:boolean prev:character <- get before-cursor:address:address:duplex-list/deref/deref, value:offset - at-start-of-line?:boolean <- equal prev:character, 10:literal/newline + at-start-of-line?:boolean <- equal prev:character, 10/newline break-if at-start-of-line?:boolean before-cursor:address:address:duplex-list/deref <- prev-duplex before-cursor:address:address:duplex-list/deref assert before-cursor:address:address:duplex-list/deref, [move-to-start-of-line tried to move before start of text] @@ -1144,14 +1144,14 @@ recipe move-to-end-of-line [ next:address:duplex-list <- next-duplex before-cursor:address:address:duplex-list/deref break-unless next:address:duplex-list # end of text nextc:character <- get next:address:duplex-list/deref, value:offset - at-end-of-line?:boolean <- equal nextc:character, 10:literal/newline + at-end-of-line?:boolean <- equal nextc:character, 10/newline break-if at-end-of-line?:boolean before-cursor:address:address:duplex-list/deref <- copy next:address:duplex-list - cursor-column:address:number/deref <- add cursor-column:address:number/deref, 1:literal + cursor-column:address:number/deref <- add cursor-column:address:number/deref, 1 loop } # move one past end of line - cursor-column:address:number/deref <- add cursor-column:address:number/deref, 1:literal + cursor-column:address:number/deref <- add cursor-column:address:number/deref, 1 ] recipe delete-to-start-of-line [ @@ -1166,7 +1166,7 @@ recipe delete-to-start-of-line [ at-start-of-text?:boolean <- equal start:address:duplex-list, init:address:duplex-list break-if at-start-of-text?:boolean curr:character <- get start:address:duplex-list/deref, value:offset - at-start-of-line?:boolean <- equal curr:character, 10:literal/newline + at-start-of-line?:boolean <- equal curr:character, 10/newline break-if at-start-of-line?:boolean start:address:duplex-list <- prev-duplex start:address:duplex-list assert start:address:duplex-list, [delete-to-start-of-line tried to move before start of text] @@ -1191,10 +1191,10 @@ recipe delete-to-end-of-line [ start:address:duplex-list <- get editor:address:editor-data/deref, before-cursor:offset end:address:duplex-list <- next-duplex start:address:duplex-list { - at-end-of-text?:boolean <- equal end:address:duplex-list, 0:literal/null + at-end-of-text?:boolean <- equal end:address:duplex-list, 0/null break-if at-end-of-text?:boolean curr:character <- get end:address:duplex-list/deref, value:offset - at-end-of-line?:boolean <- equal curr:character, 10:literal/newline + at-end-of-line?:boolean <- equal curr:character, 10/newline break-if at-end-of-line?:boolean end:address:duplex-list <- next-duplex end:address:duplex-list loop @@ -1213,8 +1213,8 @@ recipe render-all [ local-scope screen:address <- next-ingredient env:address:programming-environment-data <- next-ingredient - screen:address <- render-recipes screen:address, env:address:programming-environment-data, 1:literal/clear-below - screen:address <- render-sandbox-side screen:address, env:address:programming-environment-data, 1:literal/clear-below + screen:address <- render-recipes screen:address, env:address:programming-environment-data, 1/clear-below + screen:address <- render-sandbox-side screen:address, env:address:programming-environment-data, 1/clear-below recipes:address:editor-data <- get env:address:programming-environment-data/deref, recipes:offset current-sandbox:address:editor-data <- get env:address:programming-environment-data/deref, current-sandbox:offset sandbox-in-focus?:boolean <- get env:address:programming-environment-data/deref, sandbox-in-focus?:offset @@ -1261,17 +1261,17 @@ recipe render-recipes [ { # print any warnings break-unless recipe-warnings:address:array:character - row:number, screen:address <- render-string screen:address, recipe-warnings:address:array:character, left:number, right:number, 1:literal/red, row:number + row:number, screen:address <- render-string screen:address, recipe-warnings:address:array:character, left:number, right:number, 1/red, row:number } { # no warnings? move to next line break-if recipe-warnings:address:array:character - row:number <- add row:number, 1:literal + row:number <- add row:number, 1 } # draw dotted line after recipes - draw-horizontal screen:address, row:number, left:number, right:number, 9480:literal/horizontal-dotted + draw-horizontal screen:address, row:number, left:number, right:number, 9480/horizontal-dotted # clear next line, in case we just processed a backspace - row:number <- add row:number, 1:literal + row:number <- add row:number, 1 move-cursor screen:address, row:number, left:number clear-line-delimited screen:address, left:number, right:number # clear rest of screen in this column, if requested @@ -1282,7 +1282,7 @@ recipe render-recipes [ break-if at-bottom-of-screen?:boolean move-cursor screen:address, row:number, left:number clear-line-delimited screen:address, left:number, right:number - row:number <- add row:number, 1:literal + row:number <- add row:number, 1 loop } reply screen:address/same-as-ingredient:0 @@ -1312,9 +1312,9 @@ recipe update-cursor [ ] scenario editor-handles-empty-event-queue [ - assume-screen 10:literal/width, 5:literal/height + assume-screen 10/width, 5/height 1:address:array:character <- new [abc] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address, 0:literal/left, 10:literal/right + 2:address:editor-data <- new-editor 1:address:array:character, screen:address, 0/left, 10/right assume-console [] run [ editor-event-loop screen:address, console:address, 2:address:editor-data @@ -1327,9 +1327,9 @@ scenario editor-handles-empty-event-queue [ ] scenario editor-handles-mouse-clicks [ - assume-screen 10:literal/width, 5:literal/height + assume-screen 10/width, 5/height 1:address:array:character <- new [abc] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address, 0:literal/left, 10:literal/right + 2:address:editor-data <- new-editor 1:address:array:character, screen:address, 0/left, 10/right assume-console [ left-click 1, 1 # on the 'b' ] @@ -1350,9 +1350,9 @@ scenario editor-handles-mouse-clicks [ ] scenario editor-handles-mouse-clicks-outside-text [ - assume-screen 10:literal/width, 5:literal/height + assume-screen 10/width, 5/height 1:address:array:character <- new [abc] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address, 0:literal/left, 10:literal/right + 2:address:editor-data <- new-editor 1:address:array:character, screen:address, 0/left, 10/right assume-console [ left-click 1, 7 # last line, to the right of text ] @@ -1368,10 +1368,10 @@ scenario editor-handles-mouse-clicks-outside-text [ ] scenario editor-handles-mouse-clicks-outside-text-2 [ - assume-screen 10:literal/width, 5:literal/height + assume-screen 10/width, 5/height 1:address:array:character <- new [abc def] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address, 0:literal/left, 10:literal/right + 2:address:editor-data <- new-editor 1:address:array:character, screen:address, 0/left, 10/right assume-console [ left-click 1, 7 # interior line, to the right of text ] @@ -1387,10 +1387,10 @@ def] ] scenario editor-handles-mouse-clicks-outside-text-3 [ - assume-screen 10:literal/width, 5:literal/height + assume-screen 10/width, 5/height 1:address:array:character <- new [abc def] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address, 0:literal/left, 10:literal/right + 2:address:editor-data <- new-editor 1:address:array:character, screen:address, 0/left, 10/right assume-console [ left-click 3, 7 # below text ] @@ -1406,10 +1406,10 @@ def] ] scenario editor-handles-mouse-clicks-outside-column [ - assume-screen 10:literal/width, 5:literal/height + assume-screen 10/width, 5/height 1:address:array:character <- new [abc] # editor occupies only left half of screen - 2:address:editor-data <- new-editor 1:address:array:character, screen:address, 0:literal/left, 5:literal/right + 2:address:editor-data <- new-editor 1:address:array:character, screen:address, 0/left, 5/right assume-console [ # click on right half of screen left-click 3, 8 @@ -1431,9 +1431,9 @@ scenario editor-handles-mouse-clicks-outside-column [ ] scenario editor-inserts-characters-into-empty-editor [ - assume-screen 10:literal/width, 5:literal/height + assume-screen 10/width, 5/height 1:address:array:character <- new [] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address, 0:literal/left, 5:literal/right + 2:address:editor-data <- new-editor 1:address:array:character, screen:address, 0/left, 5/right assume-console [ type [abc] ] @@ -1448,9 +1448,9 @@ scenario editor-inserts-characters-into-empty-editor [ ] scenario editor-inserts-characters-at-cursor [ - assume-screen 10:literal/width, 5:literal/height + assume-screen 10/width, 5/height 1:address:array:character <- new [abc] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address, 0:literal/left, 10:literal/right + 2:address:editor-data <- new-editor 1:address:array:character, screen:address, 0/left, 10/right assume-console [ type [0] left-click 1, 2 @@ -1467,9 +1467,9 @@ scenario editor-inserts-characters-at-cursor [ ] scenario editor-inserts-characters-at-cursor-2 [ - assume-screen 10:literal/width, 5:literal/height + assume-screen 10/width, 5/height 1:address:array:character <- new [abc] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address, 0:literal/left, 10:literal/right + 2:address:editor-data <- new-editor 1:address:array:character, screen:address, 0/left, 10/right assume-console [ left-click 1, 5 # right of last line type [d] # should append @@ -1485,9 +1485,9 @@ scenario editor-inserts-characters-at-cursor-2 [ ] scenario editor-inserts-characters-at-cursor-3 [ - assume-screen 10:literal/width, 5:literal/height + assume-screen 10/width, 5/height 1:address:array:character <- new [abc] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address, 0:literal/left, 10:literal/right + 2:address:editor-data <- new-editor 1:address:array:character, screen:address, 0/left, 10/right assume-console [ left-click 3, 5 # below all text type [d] # should append @@ -1503,10 +1503,10 @@ scenario editor-inserts-characters-at-cursor-3 [ ] scenario editor-inserts-characters-at-cursor-4 [ - assume-screen 10:literal/width, 5:literal/height + assume-screen 10/width, 5/height 1:address:array:character <- new [abc d] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address, 0:literal/left, 10:literal/right + 2:address:editor-data <- new-editor 1:address:array:character, screen:address, 0/left, 10/right assume-console [ left-click 3, 5 # below all text type [e] # should append @@ -1523,10 +1523,10 @@ d] ] scenario editor-inserts-characters-at-cursor-5 [ - assume-screen 10:literal/width, 5:literal/height + assume-screen 10/width, 5/height 1:address:array:character <- new [abc d] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address, 0:literal/left, 10:literal/right + 2:address:editor-data <- new-editor 1:address:array:character, screen:address, 0/left, 10/right assume-console [ left-click 3, 5 # below all text type [ef] # should append multiple characters in order @@ -1543,9 +1543,9 @@ d] ] scenario editor-wraps-line-on-insert [ - assume-screen 5:literal/width, 5:literal/height + assume-screen 5/width, 5/height 1:address:array:character <- new [abc] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address, 0:literal/left, 5:literal/right + 2:address:editor-data <- new-editor 1:address:array:character, screen:address, 0/left, 5/right # type a letter assume-console [ type [e] @@ -1577,9 +1577,9 @@ scenario editor-wraps-line-on-insert [ ] scenario editor-moves-cursor-after-inserting-characters [ - assume-screen 10:literal/width, 5:literal/height + assume-screen 10/width, 5/height 1:address:array:character <- new [ab] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address, 0:literal/left, 5:literal/right + 2:address:editor-data <- new-editor 1:address:array:character, screen:address, 0/left, 5/right assume-console [ type [01] ] @@ -1594,9 +1594,9 @@ scenario editor-moves-cursor-after-inserting-characters [ ] scenario editor-wraps-cursor-after-inserting-characters [ - assume-screen 10:literal/width, 5:literal/height + assume-screen 10/width, 5/height 1:address:array:character <- new [abcde] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address, 0:literal/left, 5:literal/right + 2:address:editor-data <- new-editor 1:address:array:character, screen:address, 0/left, 5/right assume-console [ left-click 1, 4 # line is full; no wrap icon yet type [f] @@ -1619,9 +1619,9 @@ scenario editor-wraps-cursor-after-inserting-characters [ ] scenario editor-wraps-cursor-after-inserting-characters-2 [ - assume-screen 10:literal/width, 5:literal/height + assume-screen 10/width, 5/height 1:address:array:character <- new [abcde] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address, 0:literal/left, 5:literal/right + 2:address:editor-data <- new-editor 1:address:array:character, screen:address, 0/left, 5/right assume-console [ left-click 1, 3 # right before the wrap icon type [f] @@ -1644,9 +1644,9 @@ scenario editor-wraps-cursor-after-inserting-characters-2 [ ] scenario editor-moves-cursor-down-after-inserting-newline [ - assume-screen 10:literal/width, 5:literal/height + assume-screen 10/width, 5/height 1:address:array:character <- new [abc] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address, 0:literal/left, 10:literal/right + 2:address:editor-data <- new-editor 1:address:array:character, screen:address, 0/left, 10/right assume-console [ type [0 1] @@ -1663,9 +1663,9 @@ scenario editor-moves-cursor-down-after-inserting-newline [ ] scenario editor-moves-cursor-down-after-inserting-newline-2 [ - assume-screen 10:literal/width, 5:literal/height + assume-screen 10/width, 5/height 1:address:array:character <- new [abc] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address, 1:literal/left, 10:literal/right + 2:address:editor-data <- new-editor 1:address:array:character, screen:address, 1/left, 10/right assume-console [ type [0 1] @@ -1682,9 +1682,9 @@ scenario editor-moves-cursor-down-after-inserting-newline-2 [ ] scenario editor-clears-previous-line-completely-after-inserting-newline [ - assume-screen 10:literal/width, 5:literal/height + assume-screen 10/width, 5/height 1:address:array:character <- new [abcde] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address, 0:literal/left, 5:literal/right + 2:address:editor-data <- new-editor 1:address:array:character, screen:address, 0/left, 5/right # press just a 'newline' assume-console [ type [ @@ -1711,11 +1711,11 @@ scenario editor-clears-previous-line-completely-after-inserting-newline [ ] scenario editor-inserts-indent-after-newline [ - assume-screen 10:literal/width, 10:literal/height + assume-screen 10/width, 10/height 1:address:array:character <- new [ab cd ef] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address, 0:literal/left, 10:literal/right + 2:address:editor-data <- new-editor 1:address:array:character, screen:address, 0/left, 10/right # position cursor after 'cd' and hit 'newline' assume-console [ left-click 2, 8 @@ -1735,15 +1735,15 @@ ef] ] scenario editor-handles-backspace-key [ - assume-screen 10:literal/width, 5:literal/height + assume-screen 10/width, 5/height 1:address:array:character <- new [abc] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address, 0:literal/left, 10:literal/right + 2:address:editor-data <- new-editor 1:address:array:character, screen:address, 0/left, 10/right assume-console [ left-click 1, 1 type [«] ] - 3:event/backspace <- merge 0:literal/text, 8:literal/backspace, 0:literal/dummy, 0:literal/dummy - replace-in-console 171:literal/«, 3:event/backspace + 3:event/backspace <- merge 0/text, 8/backspace, 0/dummy, 0/dummy + replace-in-console 171/«, 3:event/backspace run [ editor-event-loop screen:address, console:address, 2:address:editor-data 4:number <- get 2:address:editor-data/deref, cursor-row:offset @@ -1761,17 +1761,17 @@ scenario editor-handles-backspace-key [ ] scenario editor-clears-last-line-on-backspace [ - assume-screen 10:literal/width, 5:literal/height + assume-screen 10/width, 5/height # just one character in final line 1:address:array:character <- new [ab cd] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address, 0:literal/left, 5:literal/right + 2:address:editor-data <- new-editor 1:address:array:character, screen:address, 0/left, 5/right assume-console [ left-click 2, 0 # cursor at only character in final line type [«] ] - 3:event/backspace <- merge 0:literal/text, 8:literal/backspace, 0:literal/dummy, 0:literal/dummy - replace-in-console 171:literal/«, 3:event/backspace + 3:event/backspace <- merge 0/text, 8/backspace, 0/dummy, 0/dummy + replace-in-console 171/«, 3:event/backspace run [ editor-event-loop screen:address, console:address, 2:address:editor-data ] @@ -1783,16 +1783,16 @@ cd] ] scenario editor-inserts-two-spaces-on-tab [ - assume-screen 10:literal/width, 5:literal/height + assume-screen 10/width, 5/height # just one character in final line 1:address:array:character <- new [ab cd] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address, 0:literal/left, 5:literal/right + 2:address:editor-data <- new-editor 1:address:array:character, screen:address, 0/left, 5/right assume-console [ type [»] ] - 3:event/tab <- merge 0:literal/text, 9:literal/tab, 0:literal/dummy, 0:literal/dummy - replace-in-console 187:literal/», 3:event/tab + 3:event/tab <- merge 0/text, 9/tab, 0/dummy, 0/dummy + replace-in-console 187/», 3:event/tab run [ editor-event-loop screen:address, console:address, 2:address:editor-data ] @@ -1804,9 +1804,9 @@ cd] ] scenario editor-moves-cursor-right-with-key [ - assume-screen 10:literal/width, 5:literal/height + assume-screen 10/width, 5/height 1:address:array:character <- new [abc] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address, 0:literal/left, 10:literal/right + 2:address:editor-data <- new-editor 1:address:array:character, screen:address, 0/left, 10/right assume-console [ press 65514 # right arrow type [0] @@ -1822,10 +1822,10 @@ scenario editor-moves-cursor-right-with-key [ ] scenario editor-moves-cursor-to-next-line-with-right-arrow [ - assume-screen 10:literal/width, 5:literal/height + assume-screen 10/width, 5/height 1:address:array:character <- new [abc d] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address, 0:literal/left, 10:literal/right + 2:address:editor-data <- new-editor 1:address:array:character, screen:address, 0/left, 10/right assume-console [ press 65514 # right arrow press 65514 # right arrow @@ -1845,10 +1845,10 @@ d] ] scenario editor-moves-cursor-to-next-line-with-right-arrow-2 [ - assume-screen 10:literal/width, 5:literal/height + assume-screen 10/width, 5/height 1:address:array:character <- new [abc d] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address, 1:literal/left, 10:literal/right + 2:address:editor-data <- new-editor 1:address:array:character, screen:address, 1/left, 10/right assume-console [ press 65514 # right arrow press 65514 # right arrow @@ -1868,9 +1868,9 @@ d] ] scenario editor-moves-cursor-to-next-wrapped-line-with-right-arrow [ - assume-screen 10:literal/width, 5:literal/height + assume-screen 10/width, 5/height 1:address:array:character <- new [abcdef] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address, 0:literal/left, 5:literal/right + 2:address:editor-data <- new-editor 1:address:array:character, screen:address, 0/left, 5/right assume-console [ left-click 1, 3 press 65514 # right arrow @@ -1893,10 +1893,10 @@ scenario editor-moves-cursor-to-next-wrapped-line-with-right-arrow [ ] scenario editor-moves-cursor-to-next-wrapped-line-with-right-arrow-2 [ - assume-screen 10:literal/width, 5:literal/height + assume-screen 10/width, 5/height # line just barely wrapping 1:address:array:character <- new [abcde] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address, 0:literal/left, 5:literal/right + 2:address:editor-data <- new-editor 1:address:array:character, screen:address, 0/left, 5/right # position cursor at last character before wrap and hit right-arrow assume-console [ left-click 1, 3 @@ -1927,9 +1927,9 @@ scenario editor-moves-cursor-to-next-wrapped-line-with-right-arrow-2 [ ] scenario editor-moves-cursor-to-next-wrapped-line-with-right-arrow-3 [ - assume-screen 10:literal/width, 5:literal/height + assume-screen 10/width, 5/height 1:address:array:character <- new [abcdef] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address, 1:literal/left, 6:literal/right + 2:address:editor-data <- new-editor 1:address:array:character, screen:address, 1/left, 6/right assume-console [ left-click 1, 4 press 65514 # right arrow @@ -1952,10 +1952,10 @@ scenario editor-moves-cursor-to-next-wrapped-line-with-right-arrow-3 [ ] scenario editor-moves-cursor-to-next-line-with-right-arrow-at-end-of-line [ - assume-screen 10:literal/width, 5:literal/height + assume-screen 10/width, 5/height 1:address:array:character <- new [abc d] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address, 0:literal/left, 10:literal/right + 2:address:editor-data <- new-editor 1:address:array:character, screen:address, 0/left, 10/right assume-console [ left-click 1, 3 press 65514 # right arrow - next line @@ -1973,9 +1973,9 @@ d] ] scenario editor-moves-cursor-left-with-key [ - assume-screen 10:literal/width, 5:literal/height + assume-screen 10/width, 5/height 1:address:array:character <- new [abc] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address, 0:literal/left, 10:literal/right + 2:address:editor-data <- new-editor 1:address:array:character, screen:address, 0/left, 10/right assume-console [ left-click 1, 2 press 65515 # left arrow @@ -1992,11 +1992,11 @@ scenario editor-moves-cursor-left-with-key [ ] scenario editor-moves-cursor-to-previous-line-with-left-arrow-at-start-of-line [ - assume-screen 10:literal/width, 5:literal/height + assume-screen 10/width, 5/height # initialize editor with two lines 1:address:array:character <- new [abc d] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address, 0:literal/left, 10:literal/right + 2:address:editor-data <- new-editor 1:address:array:character, screen:address, 0/left, 10/right # position cursor at start of second line (so there's no previous newline) assume-console [ left-click 2, 0 @@ -2014,12 +2014,12 @@ d] ] scenario editor-moves-cursor-to-previous-line-with-left-arrow-at-start-of-line-2 [ - assume-screen 10:literal/width, 5:literal/height + assume-screen 10/width, 5/height # initialize editor with three lines 1:address:array:character <- new [abc def g] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address, 0:literal/left, 10:literal/right + 2:address:editor-data <- new-editor 1:address:array:character, screen:address, 0/left, 10/right # position cursor further down (so there's a newline before the character at # the cursor) assume-console [ @@ -2040,11 +2040,11 @@ g] ] scenario editor-moves-cursor-to-previous-line-with-left-arrow-at-start-of-line-3 [ - assume-screen 10:literal/width, 5:literal/height + assume-screen 10/width, 5/height 1:address:array:character <- new [abc def g] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address, 0:literal/left, 10:literal/right + 2:address:editor-data <- new-editor 1:address:array:character, screen:address, 0/left, 10/right # position cursor at start of text assume-console [ left-click 1, 0 @@ -2064,12 +2064,12 @@ g] ] scenario editor-moves-cursor-to-previous-line-with-left-arrow-at-start-of-line-4 [ - assume-screen 10:literal/width, 5:literal/height + assume-screen 10/width, 5/height # initialize editor with text containing an empty line 1:address:array:character <- new [abc d] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address, 0:literal/left, 10:literal/right + 2:address:editor-data <- new-editor 1:address:array:character, screen:address, 0/left, 10/right # position cursor right after empty line assume-console [ left-click 3, 0 @@ -2089,10 +2089,10 @@ d] ] scenario editor-moves-across-screen-lines-across-wrap-with-left-arrow [ - assume-screen 10:literal/width, 5:literal/height + assume-screen 10/width, 5/height # initialize editor with text containing an empty line 1:address:array:character <- new [abcdef] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address, 0:literal/left, 5:literal/right + 2:address:editor-data <- new-editor 1:address:array:character, screen:address, 0/left, 5/right screen-should-contain [ . . .abcd↩ . @@ -2116,10 +2116,10 @@ scenario editor-moves-across-screen-lines-across-wrap-with-left-arrow [ ] scenario editor-moves-to-previous-line-with-up-arrow [ - assume-screen 10:literal/width, 5:literal/height + assume-screen 10/width, 5/height 1:address:array:character <- new [abc def] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address, 0:literal/left, 10:literal/right + 2:address:editor-data <- new-editor 1:address:array:character, screen:address, 0/left, 10/right assume-console [ left-click 2, 1 press 65517 # up arrow @@ -2136,10 +2136,10 @@ def] ] scenario editor-moves-to-next-line-with-down-arrow [ - assume-screen 10:literal/width, 5:literal/height + assume-screen 10/width, 5/height 1:address:array:character <- new [abc def] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address, 0:literal/left, 10:literal/right + 2:address:editor-data <- new-editor 1:address:array:character, screen:address, 0/left, 10/right # cursor starts out at (1, 0) assume-console [ press 65516 # down arrow @@ -2157,10 +2157,10 @@ def] ] scenario editor-adjusts-column-at-previous-line [ - assume-screen 10:literal/width, 5:literal/height + assume-screen 10/width, 5/height 1:address:array:character <- new [ab def] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address, 0:literal/left, 10:literal/right + 2:address:editor-data <- new-editor 1:address:array:character, screen:address, 0/left, 10/right assume-console [ left-click 2, 3 press 65517 # up arrow @@ -2177,10 +2177,10 @@ def] ] scenario editor-adjusts-column-at-next-line [ - assume-screen 10:literal/width, 5:literal/height + assume-screen 10/width, 5/height 1:address:array:character <- new [abc de] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address, 0:literal/left, 10:literal/right + 2:address:editor-data <- new-editor 1:address:array:character, screen:address, 0/left, 10/right assume-console [ left-click 1, 3 press 65516 # down arrow @@ -2197,17 +2197,17 @@ de] ] scenario editor-moves-to-start-of-line-with-ctrl-a [ - assume-screen 10:literal/width, 5:literal/height + assume-screen 10/width, 5/height 1:address:array:character <- new [123 456] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address, 0:literal/left, 10:literal/right + 2:address:editor-data <- new-editor 1:address:array:character, screen:address, 0/left, 10/right # start on second line, press ctrl-a assume-console [ left-click 2, 3 type [a] # ctrl-a ] - 3:event/ctrl-a <- merge 0:literal/text, 1:literal/ctrl-a, 0:literal/dummy, 0:literal/dummy - replace-in-console 97:literal/a, 3:event/ctrl-a + 3:event/ctrl-a <- merge 0/text, 1/ctrl-a, 0/dummy, 0/dummy + replace-in-console 97/a, 3:event/ctrl-a run [ editor-event-loop screen:address, console:address, 2:address:editor-data 4:number <- get 2:address:editor-data/deref, cursor-row:offset @@ -2221,17 +2221,17 @@ scenario editor-moves-to-start-of-line-with-ctrl-a [ ] scenario editor-moves-to-start-of-line-with-ctrl-a-2 [ - assume-screen 10:literal/width, 5:literal/height + assume-screen 10/width, 5/height 1:address:array:character <- new [123 456] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address, 0:literal/left, 10:literal/right + 2:address:editor-data <- new-editor 1:address:array:character, screen:address, 0/left, 10/right # start on first line (no newline before), press ctrl-a assume-console [ left-click 1, 3 type [a] # ctrl-a ] - 3:event/ctrl-a <- merge 0:literal/text, 1:literal/ctrl-a, 0:literal/dummy, 0:literal/dummy - replace-in-console 97:literal/a, 3:event/ctrl-a + 3:event/ctrl-a <- merge 0/text, 1/ctrl-a, 0/dummy, 0/dummy + replace-in-console 97/a, 3:event/ctrl-a run [ editor-event-loop screen:address, console:address, 2:address:editor-data 4:number <- get 2:address:editor-data/deref, cursor-row:offset @@ -2245,10 +2245,10 @@ scenario editor-moves-to-start-of-line-with-ctrl-a-2 [ ] scenario editor-moves-to-start-of-line-with-home [ - assume-screen 10:literal/width, 5:literal/height + assume-screen 10/width, 5/height 1:address:array:character <- new [123 456] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address, 0:literal/left, 10:literal/right + 2:address:editor-data <- new-editor 1:address:array:character, screen:address, 0/left, 10/right # start on second line, press 'home' assume-console [ left-click 2, 3 @@ -2267,10 +2267,10 @@ scenario editor-moves-to-start-of-line-with-home [ ] scenario editor-moves-to-start-of-line-with-home-2 [ - assume-screen 10:literal/width, 5:literal/height + assume-screen 10/width, 5/height 1:address:array:character <- new [123 456] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address, 0:literal/left, 10:literal/right + 2:address:editor-data <- new-editor 1:address:array:character, screen:address, 0/left, 10/right # start on first line (no newline before), press 'home' assume-console [ left-click 1, 3 @@ -2289,17 +2289,17 @@ scenario editor-moves-to-start-of-line-with-home-2 [ ] scenario editor-moves-to-start-of-line-with-ctrl-e [ - assume-screen 10:literal/width, 5:literal/height + assume-screen 10/width, 5/height 1:address:array:character <- new [123 456] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address, 0:literal/left, 10:literal/right + 2:address:editor-data <- new-editor 1:address:array:character, screen:address, 0/left, 10/right # start on first line, press ctrl-e assume-console [ left-click 1, 1 type [e] # ctrl-e ] - 3:event/ctrl-e <- merge 0:literal/text, 5:literal/ctrl-e, 0:literal/dummy, 0:literal/dummy - replace-in-console 101:literal/e, 3:event/ctrl-e + 3:event/ctrl-e <- merge 0/text, 5/ctrl-e, 0/dummy, 0/dummy + replace-in-console 101/e, 3:event/ctrl-e run [ editor-event-loop screen:address, console:address, 2:address:editor-data 4:number <- get 2:address:editor-data/deref, cursor-row:offset @@ -2332,17 +2332,17 @@ scenario editor-moves-to-start-of-line-with-ctrl-e [ ] scenario editor-moves-to-end-of-line-with-ctrl-e-2 [ - assume-screen 10:literal/width, 5:literal/height + assume-screen 10/width, 5/height 1:address:array:character <- new [123 456] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address, 0:literal/left, 10:literal/right + 2:address:editor-data <- new-editor 1:address:array:character, screen:address, 0/left, 10/right # start on second line (no newline after), press ctrl-e assume-console [ left-click 2, 1 type [e] # ctrl-e ] - 3:event/ctrl-e <- merge 0:literal/text, 5:literal/ctrl-e, 0:literal/dummy, 0:literal/dummy - replace-in-console 101:literal/e, 3:event/ctrl-e + 3:event/ctrl-e <- merge 0/text, 5/ctrl-e, 0/dummy, 0/dummy + replace-in-console 101/e, 3:event/ctrl-e run [ editor-event-loop screen:address, console:address, 2:address:editor-data 4:number <- get 2:address:editor-data/deref, cursor-row:offset @@ -2356,10 +2356,10 @@ scenario editor-moves-to-end-of-line-with-ctrl-e-2 [ ] scenario editor-moves-to-end-of-line-with-end [ - assume-screen 10:literal/width, 5:literal/height + assume-screen 10/width, 5/height 1:address:array:character <- new [123 456] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address, 0:literal/left, 10:literal/right + 2:address:editor-data <- new-editor 1:address:array:character, screen:address, 0/left, 10/right # start on first line, press 'end' assume-console [ left-click 1, 1 @@ -2378,10 +2378,10 @@ scenario editor-moves-to-end-of-line-with-end [ ] scenario editor-moves-to-end-of-line-with-end-2 [ - assume-screen 10:literal/width, 5:literal/height + assume-screen 10/width, 5/height 1:address:array:character <- new [123 456] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address, 0:literal/left, 10:literal/right + 2:address:editor-data <- new-editor 1:address:array:character, screen:address, 0/left, 10/right # start on second line (no newline after), press 'end' assume-console [ left-click 2, 1 @@ -2400,17 +2400,17 @@ scenario editor-moves-to-end-of-line-with-end-2 [ ] scenario editor-deletes-to-start-of-line-with-ctrl-u [ - assume-screen 10:literal/width, 5:literal/height + assume-screen 10/width, 5/height 1:address:array:character <- new [123 456] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address, 0:literal/left, 10:literal/right + 2:address:editor-data <- new-editor 1:address:array:character, screen:address, 0/left, 10/right # start on second line, press ctrl-u assume-console [ left-click 2, 2 type [u] # ctrl-u ] - 3:event/ctrl-a <- merge 0:literal/text, 21:literal/ctrl-u, 0:literal/dummy, 0:literal/dummy - replace-in-console 117:literal/u, 3:event/ctrl-u + 3:event/ctrl-a <- merge 0/text, 21/ctrl-u, 0/dummy, 0/dummy + replace-in-console 117/u, 3:event/ctrl-u run [ editor-event-loop screen:address, console:address, 2:address:editor-data ] @@ -2424,17 +2424,17 @@ scenario editor-deletes-to-start-of-line-with-ctrl-u [ ] scenario editor-deletes-to-start-of-line-with-ctrl-u-2 [ - assume-screen 10:literal/width, 5:literal/height + assume-screen 10/width, 5/height 1:address:array:character <- new [123 456] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address, 0:literal/left, 10:literal/right + 2:address:editor-data <- new-editor 1:address:array:character, screen:address, 0/left, 10/right # start on first line (no newline before), press ctrl-u assume-console [ left-click 1, 2 type [u] # ctrl-u ] - 3:event/ctrl-u <- merge 0:literal/text, 21:literal/ctrl-a, 0:literal/dummy, 0:literal/dummy - replace-in-console 117:literal/a, 3:event/ctrl-u + 3:event/ctrl-u <- merge 0/text, 21/ctrl-a, 0/dummy, 0/dummy + replace-in-console 117/a, 3:event/ctrl-u run [ editor-event-loop screen:address, console:address, 2:address:editor-data ] @@ -2448,17 +2448,17 @@ scenario editor-deletes-to-start-of-line-with-ctrl-u-2 [ ] scenario editor-deletes-to-start-of-line-with-ctrl-u-3 [ - assume-screen 10:literal/width, 5:literal/height + assume-screen 10/width, 5/height 1:address:array:character <- new [123 456] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address, 0:literal/left, 10:literal/right + 2:address:editor-data <- new-editor 1:address:array:character, screen:address, 0/left, 10/right # start past end of line, press ctrl-u assume-console [ left-click 1, 3 type [u] # ctrl-u ] - 3:event/ctrl-u <- merge 0:literal/text, 21:literal/ctrl-a, 0:literal/dummy, 0:literal/dummy - replace-in-console 117:literal/a, 3:event/ctrl-u + 3:event/ctrl-u <- merge 0/text, 21/ctrl-a, 0/dummy, 0/dummy + replace-in-console 117/a, 3:event/ctrl-u run [ editor-event-loop screen:address, console:address, 2:address:editor-data ] @@ -2472,17 +2472,17 @@ scenario editor-deletes-to-start-of-line-with-ctrl-u-3 [ ] scenario editor-deletes-to-end-of-line-with-ctrl-k [ - assume-screen 10:literal/width, 5:literal/height + assume-screen 10/width, 5/height 1:address:array:character <- new [123 456] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address, 0:literal/left, 10:literal/right + 2:address:editor-data <- new-editor 1:address:array:character, screen:address, 0/left, 10/right # start on first line, press ctrl-k assume-console [ left-click 1, 1 type [k] # ctrl-k ] - 3:event/ctrl-k <- merge 0:literal/text, 11:literal/ctrl-k, 0:literal/dummy, 0:literal/dummy - replace-in-console 107:literal/k, 3:event/ctrl-k + 3:event/ctrl-k <- merge 0/text, 11/ctrl-k, 0/dummy, 0/dummy + replace-in-console 107/k, 3:event/ctrl-k run [ editor-event-loop screen:address, console:address, 2:address:editor-data ] @@ -2496,17 +2496,17 @@ scenario editor-deletes-to-end-of-line-with-ctrl-k [ ] scenario editor-deletes-to-end-of-line-with-ctrl-k-2 [ - assume-screen 10:literal/width, 5:literal/height + assume-screen 10/width, 5/height 1:address:array:character <- new [123 456] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address, 0:literal/left, 10:literal/right + 2:address:editor-data <- new-editor 1:address:array:character, screen:address, 0/left, 10/right # start on second line (no newline after), press ctrl-k assume-console [ left-click 2, 1 type [k] # ctrl-k ] - 3:event/ctrl-k <- merge 0:literal/text, 11:literal/ctrl-k, 0:literal/dummy, 0:literal/dummy - replace-in-console 107:literal/k, 3:event/ctrl-k + 3:event/ctrl-k <- merge 0/text, 11/ctrl-k, 0/dummy, 0/dummy + replace-in-console 107/k, 3:event/ctrl-k run [ editor-event-loop screen:address, console:address, 2:address:editor-data ] @@ -2520,17 +2520,17 @@ scenario editor-deletes-to-end-of-line-with-ctrl-k-2 [ ] scenario editor-deletes-to-end-of-line-with-ctrl-k-3 [ - assume-screen 10:literal/width, 5:literal/height + assume-screen 10/width, 5/height 1:address:array:character <- new [123 456] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address, 0:literal/left, 10:literal/right + 2:address:editor-data <- new-editor 1:address:array:character, screen:address, 0/left, 10/right # start at end of line assume-console [ left-click 1, 2 type [k] # ctrl-k ] - 3:event/ctrl-k <- merge 0:literal/text, 11:literal/ctrl-k, 0:literal/dummy, 0:literal/dummy - replace-in-console 107:literal/k, 3:event/ctrl-k + 3:event/ctrl-k <- merge 0/text, 11/ctrl-k, 0/dummy, 0/dummy + replace-in-console 107/k, 3:event/ctrl-k run [ editor-event-loop screen:address, console:address, 2:address:editor-data ] @@ -2544,17 +2544,17 @@ scenario editor-deletes-to-end-of-line-with-ctrl-k-3 [ ] scenario editor-deletes-to-end-of-line-with-ctrl-k-4 [ - assume-screen 10:literal/width, 5:literal/height + assume-screen 10/width, 5/height 1:address:array:character <- new [123 456] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address, 0:literal/left, 10:literal/right + 2:address:editor-data <- new-editor 1:address:array:character, screen:address, 0/left, 10/right # start past end of line assume-console [ left-click 1, 3 type [k] # ctrl-k ] - 3:event/ctrl-k <- merge 0:literal/text, 11:literal/ctrl-k, 0:literal/dummy, 0:literal/dummy - replace-in-console 107:literal/k, 3:event/ctrl-k + 3:event/ctrl-k <- merge 0/text, 11/ctrl-k, 0/dummy, 0/dummy + replace-in-console 107/k, 3:event/ctrl-k run [ editor-event-loop screen:address, console:address, 2:address:editor-data ] @@ -2568,17 +2568,17 @@ scenario editor-deletes-to-end-of-line-with-ctrl-k-4 [ ] scenario editor-deletes-to-end-of-line-with-ctrl-k-5 [ - assume-screen 10:literal/width, 5:literal/height + assume-screen 10/width, 5/height 1:address:array:character <- new [123 456] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address, 0:literal/left, 10:literal/right + 2:address:editor-data <- new-editor 1:address:array:character, screen:address, 0/left, 10/right # start at end of text assume-console [ left-click 2, 2 type [k] # ctrl-k ] - 3:event/ctrl-k <- merge 0:literal/text, 11:literal/ctrl-k, 0:literal/dummy, 0:literal/dummy - replace-in-console 107:literal/k, 3:event/ctrl-k + 3:event/ctrl-k <- merge 0/text, 11/ctrl-k, 0/dummy, 0/dummy + replace-in-console 107/k, 3:event/ctrl-k run [ editor-event-loop screen:address, console:address, 2:address:editor-data ] @@ -2592,17 +2592,17 @@ scenario editor-deletes-to-end-of-line-with-ctrl-k-5 [ ] scenario editor-deletes-to-end-of-line-with-ctrl-k-6 [ - assume-screen 10:literal/width, 5:literal/height + assume-screen 10/width, 5/height 1:address:array:character <- new [123 456] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address, 0:literal/left, 10:literal/right + 2:address:editor-data <- new-editor 1:address:array:character, screen:address, 0/left, 10/right # start past end of text assume-console [ left-click 2, 3 type [k] # ctrl-k ] - 3:event/ctrl-k <- merge 0:literal/text, 11:literal/ctrl-k, 0:literal/dummy, 0:literal/dummy - replace-in-console 107:literal/k, 3:event/ctrl-k + 3:event/ctrl-k <- merge 0/text, 11/ctrl-k, 0/dummy, 0/dummy + replace-in-console 107/k, 3:event/ctrl-k run [ editor-event-loop screen:address, console:address, 2:address:editor-data ] @@ -2617,7 +2617,7 @@ scenario editor-deletes-to-end-of-line-with-ctrl-k-6 [ scenario point-at-multiple-editors [ $close-trace - assume-screen 30:literal/width, 5:literal/height + assume-screen 30/width, 5/height # initialize both halves of screen 1:address:array:character <- new [abc] 2:address:array:character <- new [def] @@ -2643,7 +2643,7 @@ scenario point-at-multiple-editors [ scenario edit-multiple-editors [ $close-trace - assume-screen 30:literal/width, 5:literal/height + assume-screen 30/width, 5/height # initialize both halves of screen 1:address:array:character <- new [abc] 2:address:array:character <- new [def] @@ -2674,7 +2674,7 @@ scenario edit-multiple-editors [ ] # show the cursor at the right window run [ - screen:address <- print-character screen:address, 9251:literal/␣ + screen:address <- print-character screen:address, 9251/␣ ] screen-should-contain [ . run (F4) . @@ -2686,7 +2686,7 @@ scenario edit-multiple-editors [ scenario multiple-editors-cover-only-their-own-areas [ $close-trace - assume-screen 60:literal/width, 10:literal/height + assume-screen 60/width, 10/height run [ 1:address:array:character <- new [abc] 2:address:array:character <- new [def] @@ -2704,7 +2704,7 @@ scenario multiple-editors-cover-only-their-own-areas [ scenario editor-in-focus-keeps-cursor [ $close-trace - assume-screen 30:literal/width, 5:literal/height + assume-screen 30/width, 5/height 1:address:array:character <- new [abc] 2:address:array:character <- new [def] # initialize programming environment and highlight cursor @@ -2712,7 +2712,7 @@ scenario editor-in-focus-keeps-cursor [ run [ 3:address:programming-environment-data <- new-programming-environment screen:address, 1:address:array:character, 2:address:array:character event-loop screen:address, console:address, 3:address:programming-environment-data - screen:address <- print-character screen:address, 9251:literal/␣ + screen:address <- print-character screen:address, 9251/␣ ] # is cursor at the right place? screen-should-contain [ @@ -2728,7 +2728,7 @@ scenario editor-in-focus-keeps-cursor [ run [ 3:address:programming-environment-data <- new-programming-environment screen:address, 1:address:array:character, 2:address:array:character event-loop screen:address, console:address, 3:address:programming-environment-data - screen:address <- print-character screen:address, 9251:literal/␣ + screen:address <- print-character screen:address, 9251/␣ ] # cursor should still be right screen-should-contain [ @@ -2752,11 +2752,11 @@ container sandbox-data [ scenario run-and-show-results [ $close-trace # trace too long for github - assume-screen 100:literal/width, 15:literal/height + assume-screen 100/width, 15/height # recipe editor is empty 1:address:array:character <- new [] # sandbox editor contains an instruction without storing outputs - 2:address:array:character <- new [divide-with-remainder 11:literal, 3:literal] + 2:address:array:character <- new [divide-with-remainder 11, 3] 3:address:programming-environment-data <- new-programming-environment screen:address, 1:address:array:character, 2:address:array:character # run the code in the editors assume-console [ @@ -2771,24 +2771,24 @@ scenario run-and-show-results [ . ┊ . .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━. . ┊ x. - . ┊divide-with-remainder 11:literal, 3:literal . + . ┊divide-with-remainder 11, 3 . . ┊3 . . ┊2 . . ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━. . ┊ . ] - screen-should-contain-in-color 7:literal/white, [ + screen-should-contain-in-color 7/white, [ . . . . . . . . - . divide-with-remainder 11:literal, 3:literal . + . divide-with-remainder 11, 3 . . . . . . . . . ] - screen-should-contain-in-color 245:literal/grey, [ + screen-should-contain-in-color 245/grey, [ . . . ┊ . .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━. @@ -2802,7 +2802,7 @@ scenario run-and-show-results [ # run another command assume-console [ left-click 1, 80 - type [add 2:literal, 2:literal] + type [add 2, 2] press 65532 # F4 ] run [ @@ -2814,11 +2814,11 @@ scenario run-and-show-results [ . ┊ . .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━. . ┊ x. - . ┊add 2:literal, 2:literal . + . ┊add 2, 2 . . ┊4 . . ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━. . ┊ x. - . ┊divide-with-remainder 11:literal, 3:literal . + . ┊divide-with-remainder 11, 3 . . ┊3 . . ┊2 . . ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━. @@ -2854,18 +2854,18 @@ recipe run-sandboxes [ dest:address:address:sandbox-data/deref <- copy new-sandbox:address:sandbox-data # clear sandbox editor init:address:address:duplex-list <- get-address current-sandbox:address:editor-data/deref, data:offset - init:address:address:duplex-list/deref <- push-duplex 167:literal/§, 0:literal/tail + init:address:address:duplex-list/deref <- push-duplex 167/§, 0/tail } # save all sandboxes before running, just in case we die when running # first clear previous versions, in case we deleted some sandbox $system [rm lesson/[0-9]*] curr:address:sandbox-data <- get env:address:programming-environment-data/deref, sandbox:offset - filename:number <- copy 0:literal + filename:number <- copy 0 { break-unless curr:address:sandbox-data data:address:address:array:character <- get-address curr:address:sandbox-data/deref, data:offset save filename:number, data:address:address:array:character/deref - filename:number <- add filename:number, 1:literal + filename:number <- add filename:number, 1 curr:address:sandbox-data <- get curr:address:sandbox-data/deref, next-sandbox:offset loop } @@ -2878,7 +2878,7 @@ recipe run-sandboxes [ warnings:address:address:array:character <- get-address curr:address:sandbox-data/deref, warnings:offset fake-screen:address:address:screen <- get-address curr:address:sandbox-data/deref, screen:offset response:address:address:array:character/deref, warnings:address:address:array:character/deref, fake-screen:address:address:screen/deref <- run-interactive data:address:address:array:character/deref -#? $print warnings:address:address:array:character/deref, [ ], warnings:address:address:array:character/deref/deref, 10:literal/newline +#? $print warnings:address:address:array:character/deref, [ ], warnings:address:address:array:character/deref/deref, 10/newline curr:address:sandbox-data <- get curr:address:sandbox-data/deref, next-sandbox:offset loop } @@ -2894,12 +2894,12 @@ recipe render-sandbox-side [ left:number <- get current-sandbox:address:editor-data/deref, left:offset right:number <- get current-sandbox:address:editor-data/deref, right:offset row:number, screen:address <- render screen:address, current-sandbox:address:editor-data - row:number <- add row:number, 1:literal - draw-horizontal screen:address, row:number, left:number, right:number, 9473:literal/horizontal-double + row:number <- add row:number, 1 + draw-horizontal screen:address, row:number, left:number, right:number, 9473/horizontal-double sandbox:address:sandbox-data <- get env:address:programming-environment-data/deref, sandbox:offset row:number, screen:address <- render-sandboxes screen:address, sandbox:address:sandbox-data, left:number, right:number, row:number # clear next line, in case we just processed a backspace - row:number <- add row:number, 1:literal + row:number <- add row:number, 1 move-cursor screen:address, row:number, left:number clear-line-delimited screen:address, left:number, right:number reply-unless clear:boolean, screen:address/same-as-ingredient:0 @@ -2909,7 +2909,7 @@ recipe render-sandbox-side [ break-if at-bottom-of-screen?:boolean move-cursor screen:address, row:number, left:number clear-line-delimited screen:address, left:number, right:number - row:number <- add row:number, 1:literal + row:number <- add row:number, 1 loop } reply screen:address/same-as-ingredient:0 @@ -2926,25 +2926,25 @@ recipe render-sandboxes [ screen-height:number <- screen-height screen:address at-bottom?:boolean <- greater-or-equal row:number screen-height:number reply-if at-bottom?:boolean, row:number/same-as-ingredient:4, screen:address/same-as-ingredient:0 -#? $print [rendering sandbox ], sandbox:address:sandbox-data, 10:literal/newline +#? $print [rendering sandbox ], sandbox:address:sandbox-data, 10/newline # render sandbox menu - row:number <- add row:number, 1:literal + row:number <- add row:number, 1 move-cursor screen:address, row:number, left:number clear-line-delimited screen:address, left:number, right:number - print-character screen:address, 120:literal/x, 245:literal/grey + print-character screen:address, 120/x, 245/grey # save menu row so we can detect clicks to it later starting-row:address:number <- get-address sandbox:address:sandbox-data/deref, starting-row-on-screen:offset starting-row:address:number/deref <- copy row:number # render sandbox contents sandbox-data:address:array:character <- get sandbox:address:sandbox-data/deref, data:offset - row:number, screen:address <- render-string screen:address, sandbox-data:address:array:character, left:number, right:number, 7:literal/white, row:number + row:number, screen:address <- render-string screen:address, sandbox-data:address:array:character, left:number, right:number, 7/white, row:number # render sandbox warnings, screen or response, in that order sandbox-response:address:array:character <- get sandbox:address:sandbox-data/deref, response:offset sandbox-warnings:address:array:character <- get sandbox:address:sandbox-data/deref, warnings:offset sandbox-screen:address <- get sandbox:address:sandbox-data/deref, screen:offset { break-unless sandbox-warnings:address:array:character - row:number, screen:address <- render-string screen:address, sandbox-warnings:address:array:character, left:number, right:number, 1:literal/red, row:number + row:number, screen:address <- render-string screen:address, sandbox-warnings:address:array:character, left:number, right:number, 1/red, row:number } { break-if sandbox-warnings:address:array:character @@ -2955,12 +2955,12 @@ recipe render-sandboxes [ { break-if sandbox-warnings:address:array:character break-unless empty-screen?:boolean - row:number, screen:address <- render-string screen:address, sandbox-response:address:array:character, left:number, right:number, 245:literal/grey, row:number + row:number, screen:address <- render-string screen:address, sandbox-response:address:array:character, left:number, right:number, 245/grey, row:number } at-bottom?:boolean <- greater-or-equal row:number screen-height:number reply-if at-bottom?:boolean, row:number/same-as-ingredient:4, screen:address/same-as-ingredient:0 # draw solid line after sandbox - draw-horizontal screen:address, row:number, left:number, right:number, 9473:literal/horizontal-double + draw-horizontal screen:address, row:number, left:number, right:number, 9473/horizontal-double # draw next sandbox next-sandbox:address:sandbox-data <- get sandbox:address:sandbox-data/deref, next-sandbox:offset row:number, screen:address <- render-sandboxes screen:address, next-sandbox:address:sandbox-data, left:number, right:number, row:number @@ -2972,18 +2972,18 @@ recipe restore-sandboxes [ local-scope env:address:programming-environment-data <- next-ingredient # read all scenarios, pushing them to end of a list of scenarios - filename:number <- copy 0:literal + filename:number <- copy 0 curr:address:address:sandbox-data <- get-address env:address:programming-environment-data/deref, sandbox:offset { contents:address:array:character <- restore filename:number break-unless contents:address:array:character # stop at first error; assuming file didn't exist -#? $print contents:address:array:character, 10:literal/newline +#? $print contents:address:array:character, 10/newline # create new sandbox for file curr:address:address:sandbox-data/deref <- new sandbox-data:type data:address:address:array:character <- get-address curr:address:address:sandbox-data/deref/deref, data:offset data:address:address:array:character/deref <- copy contents:address:array:character # increment loop variables - filename:number <- add filename:number, 1:literal + filename:number <- add filename:number, 1 curr:address:address:sandbox-data <- get-address curr:address:address:sandbox-data/deref/deref, next-sandbox:offset loop } @@ -2998,14 +2998,14 @@ recipe delete-sandbox [ click-column:number <- get t:touch-event, column:offset current-sandbox:address:editor-data <- get env:address:programming-environment-data/deref, current-sandbox:offset right:number <- get current-sandbox:address:editor-data/deref, right:offset -#? $print [comparing column ], click-column:number, [ vs ], right:number, 10:literal/newline +#? $print [comparing column ], click-column:number, [ vs ], right:number, 10/newline at-right?:boolean <- equal click-column:number, right:number - reply-unless at-right?:boolean, 0:literal/false + reply-unless at-right?:boolean, 0/false #? $print [trying to delete #? ] #? 1 click-row:number <- get t:touch-event, row:offset prev:address:address:sandbox-data <- get-address env:address:programming-environment-data/deref, sandbox:offset -#? $print [prev: ], prev:address:address:sandbox-data, [ -> ], prev:address:address:sandbox-data/deref, 10:literal/newline +#? $print [prev: ], prev:address:address:sandbox-data, [ -> ], prev:address:address:sandbox-data/deref, 10/newline curr:address:sandbox-data <- get env:address:programming-environment-data/deref, sandbox:offset { #? $print [next sandbox @@ -3016,31 +3016,31 @@ recipe delete-sandbox [ #? $print [checking #? ] #? 1 target-row:number <- get curr:address:sandbox-data/deref, starting-row-on-screen:offset -#? $print [comparing row ], target-row:number, [ vs ], click-row:number, 10:literal/newline +#? $print [comparing row ], target-row:number, [ vs ], click-row:number, 10/newline delete-curr?:boolean <- equal target-row:number, click-row:number break-unless delete-curr?:boolean #? $print [found! #? ] #? 1 # delete this sandbox, rerender and stop prev:address:address:sandbox-data/deref <- get curr:address:sandbox-data/deref, next-sandbox:offset -#? $print [setting prev: ], prev:address:address:sandbox-data, [ -> ], prev:address:address:sandbox-data/deref, 10:literal/newline - reply 1:literal/true +#? $print [setting prev: ], prev:address:address:sandbox-data, [ -> ], prev:address:address:sandbox-data/deref, 10/newline + reply 1/true } prev:address:address:sandbox-data <- get-address curr:address:sandbox-data/deref, next-sandbox:offset -#? $print [prev: ], prev:address:address:sandbox-data, [ -> ], prev:address:address:sandbox-data/deref, 10:literal/newline +#? $print [prev: ], prev:address:address:sandbox-data, [ -> ], prev:address:address:sandbox-data/deref, 10/newline curr:address:sandbox-data <- get curr:address:sandbox-data/deref, next-sandbox:offset loop } - reply 0:literal/false + reply 0/false ] scenario run-updates-results [ $close-trace # trace too long for github - assume-screen 100:literal/width, 12:literal/height + assume-screen 100/width, 12/height # define a recipe (no indent for the 'add' line below so column numbers are more obvious) 1:address:array:character <- new [ recipe foo [ -z:number <- add 2:literal, 2:literal +z:number <- add 2, 2 ]] # sandbox editor contains an instruction without storing outputs 2:address:array:character <- new [foo] @@ -3057,7 +3057,7 @@ z:number <- add 2:literal, 2:literal . run (F4) . . ┊ . .recipe foo [ ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━. - .z:number <- add 2:literal, 2:literal ┊ x. + .z:number <- add 2, 2 ┊ x. .] ┊foo . .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊4 . . ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━. @@ -3069,8 +3069,8 @@ z:number <- add 2:literal, 2:literal type [«3] # replace press 65532 # F4 ] - 4:event/backspace <- merge 0:literal/text, 8:literal/backspace, 0:literal/dummy, 0:literal/dummy - replace-in-console 171:literal/«, 4:event/backspace + 4:event/backspace <- merge 0/text, 8/backspace, 0/dummy, 0/dummy + replace-in-console 171/«, 4:event/backspace run [ event-loop screen:address, console:address, 3:address:programming-environment-data ] @@ -3079,7 +3079,7 @@ z:number <- add 2:literal, 2:literal . run (F4) . . ┊ . .recipe foo [ ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━. - .z:number <- add 2:literal, 3:literal ┊ x. + .z:number <- add 2, 3 ┊ x. .] ┊foo . .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊5 . . ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━. @@ -3089,7 +3089,7 @@ z:number <- add 2:literal, 2:literal scenario run-instruction-and-print-warnings [ $close-trace # trace too long for github - assume-screen 100:literal/width, 10:literal/height + assume-screen 100/width, 10/height # left editor is empty 1:address:array:character <- new [] # right editor contains an illegal instruction @@ -3113,7 +3113,7 @@ scenario run-instruction-and-print-warnings [ . ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━. . ┊ . ] - screen-should-contain-in-color 7:literal/white, [ + screen-should-contain-in-color 7/white, [ . . . . . . @@ -3123,7 +3123,7 @@ scenario run-instruction-and-print-warnings [ . . . . ] - screen-should-contain-in-color 1:literal/red, [ + screen-should-contain-in-color 1/red, [ . . . . . . @@ -3132,7 +3132,7 @@ scenario run-instruction-and-print-warnings [ . unknown element foo in container number . . . ] - screen-should-contain-in-color 245:literal/grey, [ + screen-should-contain-in-color 245/grey, [ . . . ┊ . .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━. @@ -3146,7 +3146,7 @@ scenario run-instruction-and-print-warnings [ scenario run-instruction-and-print-warnings-only-once [ $close-trace # trace too long for github - assume-screen 100:literal/width, 10:literal/height + assume-screen 100/width, 10/height # left editor is empty 1:address:array:character <- new [] # right editor contains an illegal instruction @@ -3175,16 +3175,16 @@ scenario run-instruction-and-print-warnings-only-once [ scenario deleting-sandboxes [ $close-trace # trace too long for github - assume-screen 100:literal/width, 15:literal/height + assume-screen 100/width, 15/height 1:address:array:character <- new [] 2:address:array:character <- new [] 3:address:programming-environment-data <- new-programming-environment screen:address, 1:address:array:character, 2:address:array:character # run a few commands assume-console [ left-click 1, 80 - type [divide-with-remainder 11:literal, 3:literal] + type [divide-with-remainder 11, 3] press 65532 # F4 - type [add 2:literal, 2:literal] + type [add 2, 2] press 65532 # F4 ] run [ @@ -3195,11 +3195,11 @@ scenario deleting-sandboxes [ . ┊ . .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━. . ┊ x. - . ┊add 2:literal, 2:literal . + . ┊add 2, 2 . . ┊4 . . ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━. . ┊ x. - . ┊divide-with-remainder 11:literal, 3:literal . + . ┊divide-with-remainder 11, 3 . . ┊3 . . ┊2 . . ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━. @@ -3217,7 +3217,7 @@ scenario deleting-sandboxes [ . ┊ . .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━. . ┊ x. - . ┊add 2:literal, 2:literal . + . ┊add 2, 2 . . ┊4 . . ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━. . ┊ . @@ -3241,7 +3241,7 @@ scenario deleting-sandboxes [ scenario run-instruction-manages-screen-per-sandbox [ $close-trace # trace too long for github #? 1 - assume-screen 100:literal/width, 20:literal/height + assume-screen 100/width, 20/height # left editor is empty 1:address:array:character <- new [] # right editor contains an illegal instruction @@ -3276,12 +3276,12 @@ scenario run-instruction-manages-screen-per-sandbox [ recipe editor-contents [ local-scope editor:address:editor-data <- next-ingredient - buf:address:buffer <- new-buffer 80:literal + buf:address:buffer <- new-buffer 80 curr:address:duplex-list <- get editor:address:editor-data/deref, data:offset # skip § sentinel assert curr:address:duplex-list, [editor without data is illegal; must have at least a sentinel] curr:address:duplex-list <- next-duplex curr:address:duplex-list - reply-unless curr:address:duplex-list, 0:literal + reply-unless curr:address:duplex-list, 0 { break-unless curr:address:duplex-list c:character <- get curr:address:duplex-list/deref, value:offset @@ -3294,9 +3294,9 @@ recipe editor-contents [ ] scenario editor-provides-edited-contents [ - assume-screen 10:literal/width, 5:literal/height + assume-screen 10/width, 5/height 1:address:array:character <- new [abc] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address, 0:literal/left, 10:literal/right + 2:address:editor-data <- new-editor 1:address:array:character, screen:address, 0/left, 10/right assume-console [ left-click 1, 2 type [def] @@ -3315,7 +3315,7 @@ scenario editor-provides-edited-contents [ scenario run-shows-warnings-in-get [ $close-trace - assume-screen 100:literal/width, 15:literal/height + assume-screen 100/width, 15/height assume-console [ press 65532 # F4 ] @@ -3338,7 +3338,7 @@ recipe foo [ .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊ . . ┊ . ] - screen-should-contain-in-color 1:literal/red, [ + screen-should-contain-in-color 1/red, [ . . . . . . @@ -3351,7 +3351,7 @@ recipe foo [ scenario run-shows-missing-type-warnings [ $close-trace - assume-screen 100:literal/width, 15:literal/height + assume-screen 100/width, 15/height assume-console [ press 65532 # F4 ] @@ -3380,7 +3380,7 @@ recipe foo [ scenario run-shows-get-on-non-container-warnings [ $close-trace - assume-screen 100:literal/width, 15:literal/height + assume-screen 100/width, 15/height assume-console [ press 65532 # F4 ] @@ -3409,7 +3409,7 @@ recipe foo [ scenario run-shows-non-literal-get-argument-warnings [ $close-trace - assume-screen 100:literal/width, 15:literal/height + assume-screen 100/width, 15/height assume-console [ press 65532 # F4 ] @@ -3452,7 +3452,7 @@ recipe draw-box [ { # default color to white break-if color-found?:boolean - color:number <- copy 245:literal/grey + color:number <- copy 245/grey } # top border draw-horizontal screen:address, top:number, left:number, right:number, color:number @@ -3478,25 +3478,25 @@ recipe draw-horizontal [ style:character, style-found?:boolean <- next-ingredient { break-if style-found?:boolean - style:character <- copy 9472:literal/horizontal + style:character <- copy 9472/horizontal } color:number, color-found?:boolean <- next-ingredient { # default color to white break-if color-found?:boolean - color:number <- copy 245:literal/grey + color:number <- copy 245/grey } bg-color:number, bg-color-found?:boolean <- next-ingredient { break-if bg-color-found?:boolean - bg-color:number <- copy 0:literal/black + bg-color:number <- copy 0/black } move-cursor screen:address, row:number, x:number { continue?:boolean <- lesser-or-equal x:number, right:number # right is inclusive, to match editor-data semantics break-unless continue?:boolean print-character screen:address, style:character, color:number, bg-color:number - x:number <- add x:number, 1:literal + x:number <- add x:number, 1 loop } ] @@ -3510,20 +3510,20 @@ recipe draw-vertical [ style:character, style-found?:boolean <- next-ingredient { break-if style-found?:boolean - style:character <- copy 9474:literal/vertical + style:character <- copy 9474/vertical } color:number, color-found?:boolean <- next-ingredient { # default color to white break-if color-found?:boolean - color:number <- copy 245:literal/grey + color:number <- copy 245/grey } { continue?:boolean <- lesser-than x:number, bottom:number break-unless continue?:boolean move-cursor screen:address, x:number, col:number print-character screen:address, style:character, color:number - x:number <- add x:number, 1:literal + x:number <- add x:number, 1 loop } ] @@ -3537,10 +3537,10 @@ recipe draw-top-left [ { # default color to white break-if color-found?:boolean - color:number <- copy 245:literal/grey + color:number <- copy 245/grey } move-cursor screen:address, top:number, left:number - print-character screen:address, 9484:literal/down-right, color:number + print-character screen:address, 9484/down-right, color:number ] recipe draw-top-right [ @@ -3552,10 +3552,10 @@ recipe draw-top-right [ { # default color to white break-if color-found?:boolean - color:number <- copy 245:literal/grey + color:number <- copy 245/grey } move-cursor screen:address, top:number, right:number - print-character screen:address, 9488:literal/down-left, color:number + print-character screen:address, 9488/down-left, color:number ] recipe draw-bottom-left [ @@ -3567,10 +3567,10 @@ recipe draw-bottom-left [ { # default color to white break-if color-found?:boolean - color:number <- copy 245:literal/grey + color:number <- copy 245/grey } move-cursor screen:address, bottom:number, left:number - print-character screen:address, 9492:literal/up-right, color:number + print-character screen:address, 9492/up-right, color:number ] recipe draw-bottom-right [ @@ -3582,10 +3582,10 @@ recipe draw-bottom-right [ { # default color to white break-if color-found?:boolean - color:number <- copy 245:literal/grey + color:number <- copy 245/grey } move-cursor screen:address, bottom:number, right:number - print-character screen:address, 9496:literal/up-left, color:number + print-character screen:address, 9496/up-left, color:number ] recipe print-string-with-gradient-background [ @@ -3599,18 +3599,18 @@ recipe print-string-with-gradient-background [ color-range:number <- subtract bg-color2:number, bg-color1:number color-quantum:number <- divide color-range:number, len:number #? close-console #? 2 -#? $print len:number, [, ], color-range:number, [, ], color-quantum:number, 10:literal/newline +#? $print len:number, [, ], color-range:number, [, ], color-quantum:number, 10/newline #? #? $exit #? 3 bg-color:number <- copy bg-color1:number - i:number <- copy 0:literal + i:number <- copy 0 { done?:boolean <- greater-or-equal i:number, len:number break-if done?:boolean c:character <- index s:address:array:character/deref, i:number print-character x:address:screen, c:character, color:number, bg-color:number - i:number <- add i:number, 1:literal + i:number <- add i:number, 1 bg-color:number <- add bg-color:number, color-quantum:number -#? $print [=> ], bg-color:number, 10:literal/newline +#? $print [=> ], bg-color:number, 10/newline loop } #? $exit #? 1 diff --git a/factorial.mu b/factorial.mu index 6448bff1..23c247e0 100644 --- a/factorial.mu +++ b/factorial.mu @@ -2,7 +2,7 @@ recipe main [ local-scope - x:number <- factorial 5:literal + x:number <- factorial 5 $print [result: ], x:number, [ ] ] @@ -12,12 +12,12 @@ recipe factorial [ n:number <- next-ingredient { # if n=0 return 1 - zero?:boolean <- equal n:number, 0:literal + zero?:boolean <- equal n:number, 0 break-unless zero?:boolean - reply 1:literal + reply 1 } # return n * factorial(n-1) - x:number <- subtract n:number, 1:literal + x:number <- subtract n:number, 1 subresult:number <- factorial x:number result:number <- multiply subresult:number, n:number reply result:number @@ -26,7 +26,7 @@ recipe factorial [ # unit test scenario factorial-test [ run [ - 1:number <- factorial 5:literal + 1:number <- factorial 5 ] memory-should-contain [ 1 <- 120 diff --git a/fork.mu b/fork.mu index c3be8310..1d717181 100644 --- a/fork.mu +++ b/fork.mu @@ -3,14 +3,14 @@ recipe main [ start-running thread2:recipe { - $print 34:literal + $print 34 loop } ] recipe thread2 [ { - $print 35:literal + $print 35 loop } ] diff --git a/global.mu b/global.mu index 839926a7..756469c1 100644 --- a/global.mu +++ b/global.mu @@ -2,9 +2,9 @@ recipe main [ # allocate 5 locations for globals - global-space:address:array:location <- new location:type, 5:literal + global-space:address:array:location <- new location:type, 5 # read to globals by using /space:global - 1:number/space:global <- copy 3:literal + 1:number/space:global <- copy 3 foo ] diff --git a/mu.vim b/mu.vim index f8440bfb..49c322cc 100644 --- a/mu.vim +++ b/mu.vim @@ -41,6 +41,8 @@ highlight link muScreen muString " mu literals syntax match muNumber %[^ ]\+:literal/\?[^ ,]*% +syntax match muNumber %\<[0-9]\+\>% +syntax match muNumber %\<[0-9]\+/[^ ,]*% highlight link muNumber Constant syntax match muLabel "^\s\+[^ 0-9a-zA-Z{}\[\]][^ ]*\s*$" syntax match muLabel %[^ ]\+:label/\?[^ ,]*% diff --git a/screen.mu b/screen.mu index 7a2390e8..b1e4e5b4 100644 --- a/screen.mu +++ b/screen.mu @@ -5,23 +5,23 @@ recipe main [ open-console - print-character 0:literal/screen, 97:literal, 2:literal/red - 1:number/raw, 2:number/raw <- cursor-position 0:literal/screen - wait-for-event 0:literal/console - clear-screen 0:literal/screen - move-cursor 0:literal/screen, 0:literal/row, 4:literal/column - print-character 0:literal/screen, 98:literal - wait-for-event 0:literal/console - move-cursor 0:literal/screen, 0:literal/row, 0:literal/column - clear-line 0:literal/screen - wait-for-event 0:literal/console - cursor-down 0:literal/screen - wait-for-event 0:literal/console - cursor-right 0:literal/screen - wait-for-event 0:literal/console - cursor-left 0:literal/screen - wait-for-event 0:literal/console - cursor-up 0:literal/screen - wait-for-event 0:literal/console + print-character 0/screen, 97/a, 2/red + 1:number/raw, 2:number/raw <- cursor-position 0/screen + wait-for-event 0/console + clear-screen 0/screen + move-cursor 0/screen, 0/row, 4/column + print-character 0/screen, 98/b + wait-for-event 0/console + move-cursor 0/screen, 0/row, 0/column + clear-line 0/screen + wait-for-event 0/console + cursor-down 0/screen + wait-for-event 0/console + cursor-right 0/screen + wait-for-event 0/console + cursor-left 0/screen + wait-for-event 0/console + cursor-up 0/screen + wait-for-event 0/console close-console ] diff --git a/tangle.mu b/tangle.mu index 8ac7abe6..121bfbcc 100644 --- a/tangle.mu +++ b/tangle.mu @@ -17,21 +17,21 @@ recipe factorial [ after +base-case [ # if n=0 return 1 - zero?:boolean <- equal n:number, 0:literal + zero?:boolean <- equal n:number, 0 break-unless zero?:boolean - reply 1:literal + reply 1 ] after +recursive-case [ # return n * factorial(n - 1) - x:number <- subtract n:number, 1:literal + x:number <- subtract n:number, 1 subresult:number <- factorial x:number result:number <- multiply subresult:number, n:number reply result:number ] recipe main [ - 1:number <- factorial 5:literal + 1:number <- factorial 5 $print [result: ], 1:number, [ ] ] diff --git a/x.mu b/x.mu index 15dded23..8771381b 100644 --- a/x.mu +++ b/x.mu @@ -1,8 +1,8 @@ # example program: add two numbers recipe main [ - 11:number <- copy 1:literal - 12:number <- copy 3:literal + 11:number <- copy 1 + 12:number <- copy 3 13:number <- add 11:number, 12:number $dump-memory ] |