diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2016-10-22 12:08:10 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2016-10-22 12:08:10 -0700 |
commit | ada5eb55cb185edf30dcac48b25cc485d44677ef (patch) | |
tree | e147838f053a582e33146ac4fc4ab30ac8434e0e /sandbox | |
parent | a6deb48067f8049922f16ed3489896f7749fd39f (diff) | |
download | mu-ada5eb55cb185edf30dcac48b25cc485d44677ef.tar.gz |
3552
Stop requiring jump instructions to explicitly provide a ':label' type for jump targets. This has been a source of repeated confusion for my students: a) They'd add the ':label' to the label definition rather than the jump target (label use) b) They'd spend time thinking about whether the initial '+' prefix was part of the label name. In the process I cleaned up a couple of things: - the space of names is more cleanly partitioned into labels and non-labels (clarifying that '_' and '-' are non-label prefixes) - you can't use label names as regular variables anymore - you can infer the type of a label just from its name
Diffstat (limited to 'sandbox')
-rw-r--r-- | sandbox/001-editor.mu | 12 | ||||
-rw-r--r-- | sandbox/002-typing.mu | 6 | ||||
-rw-r--r-- | sandbox/004-programming-environment.mu | 22 | ||||
-rw-r--r-- | sandbox/005-sandbox.mu | 10 | ||||
-rw-r--r-- | sandbox/006-sandbox-copy.mu | 2 | ||||
-rw-r--r-- | sandbox/007-sandbox-delete.mu | 2 | ||||
-rw-r--r-- | sandbox/008-sandbox-edit.mu | 2 | ||||
-rw-r--r-- | sandbox/009-sandbox-test.mu | 4 | ||||
-rw-r--r-- | sandbox/010-sandbox-trace.mu | 2 | ||||
-rw-r--r-- | sandbox/011-errors.mu | 2 | ||||
-rw-r--r-- | sandbox/012-editor-undo.mu | 8 |
11 files changed, 36 insertions, 36 deletions
diff --git a/sandbox/001-editor.mu b/sandbox/001-editor.mu index 7f799445..034d4cc9 100644 --- a/sandbox/001-editor.mu +++ b/sandbox/001-editor.mu @@ -180,7 +180,7 @@ def render screen:&:screen, editor:&:editor -> last-row:num, last-column:num, sc screen <- move-cursor screen, row, column curr <- next curr prev <- next prev - loop +next-character:label + loop +next-character } { # at right? wrap. even if there's only one more letter left; we need @@ -194,7 +194,7 @@ def render screen:&:screen, editor:&:editor -> last-row:num, last-column:num, sc row <- add row, 1 screen <- move-cursor screen, row, column # don't increment curr - loop +next-character:label + loop +next-character } print screen, c, color curr <- next curr @@ -414,7 +414,7 @@ def get-color color:num, c:char -> color:num [ break-unless starting-comment? trace 90, [app], [switch color back to blue] color <- copy 12/lightblue - jump +exit:label + jump +exit } # if color is blue and next character is newline, switch color to white { @@ -424,7 +424,7 @@ def get-color color:num, c:char -> color:num [ break-unless ending-comment? trace 90, [app], [switch color back to white] color <- copy 7/white - jump +exit:label + jump +exit } # if color is white (no comments) and next character is '<', switch color to red { @@ -432,7 +432,7 @@ def get-color color:num, c:char -> color:num [ starting-assignment?:bool <- equal c, 60/< break-unless starting-assignment? color <- copy 1/red - jump +exit:label + jump +exit } # if color is red and next character is space, switch color to white { @@ -441,7 +441,7 @@ def get-color color:num, c:char -> color:num [ ending-assignment?:bool <- equal c, 32/space break-unless ending-assignment? color <- copy 7/white - jump +exit:label + jump +exit } # otherwise no change +exit diff --git a/sandbox/002-typing.mu b/sandbox/002-typing.mu index 2f94f362..12448e18 100644 --- a/sandbox/002-typing.mu +++ b/sandbox/002-typing.mu @@ -29,7 +29,7 @@ def editor-event-loop screen:&:screen, console:&:console, editor:&:editor -> scr { break-unless is-touch? move-cursor-in-editor screen, editor, t - loop +next-event:label + loop +next-event } # keyboard events { @@ -125,7 +125,7 @@ def snap-cursor screen:&:screen, editor:&:editor, target-row:num, target-column: column <- copy left curr <- next curr prev <- next prev - loop +next-character:label + loop +next-character } { # at right? wrap. even if there's only one more letter left; we need @@ -135,7 +135,7 @@ def snap-cursor screen:&:screen, editor:&:editor, target-row:num, target-column: column <- copy left row <- add row, 1 # don't increment curr/prev - loop +next-character:label + loop +next-character } curr <- next curr prev <- next prev diff --git a/sandbox/004-programming-environment.mu b/sandbox/004-programming-environment.mu index af136deb..76938021 100644 --- a/sandbox/004-programming-environment.mu +++ b/sandbox/004-programming-environment.mu @@ -73,14 +73,14 @@ def event-loop screen:&:screen, console:&:console, env:&:environment -> screen:& # todo: test this touch-type:num <- get t, type:offset is-left-click?:bool <- equal touch-type, 65513/mouse-left - loop-unless is-left-click?, +next-event:label + loop-unless is-left-click?, +next-event click-row:num <- get t, row:offset click-column:num <- get t, column:offset # later exceptions for non-editor touches will go here <global-touch> move-cursor-in-editor screen, current-sandbox, t screen <- update-cursor screen, current-sandbox, env - loop +next-event:label + loop +next-event } # 'resize' event - redraw editor # todo: test this after supporting resize in assume-console @@ -99,7 +99,7 @@ def event-loop screen:&:screen, console:&:console, env:&:environment -> screen:& screen <- render-all screen, env, render-without-moving-cursor render-all-on-no-more-events? <- copy 0/false # full render done } - loop +next-event:label + loop +next-event } # if it's not global and not a touch event, send to appropriate editor { @@ -111,7 +111,7 @@ def event-loop screen:&:screen, console:&:console, env:&:environment -> screen:& { break-unless more-events? render-all-on-no-more-events? <- copy 1/true # no rendering now, full rendering on some future event - jump +finish-event:label + jump +finish-event } { break-if more-events? @@ -120,13 +120,13 @@ def event-loop screen:&:screen, console:&:console, env:&:environment -> screen:& # no more events, and we have to force render screen <- render-all screen, env, render render-all-on-no-more-events? <- copy 0/false - jump +finish-event:label + jump +finish-event } # no more events, no force render { break-unless render? screen <- render-sandbox-side screen, env, render - jump +finish-event:label + jump +finish-event } } +finish-event @@ -206,7 +206,7 @@ def render-without-moving-cursor screen:&:screen, editor:&:editor -> last-row:nu screen <- move-cursor screen, row, column curr <- next curr prev <- next prev - loop +next-character:label + loop +next-character } { # at right? wrap. even if there's only one more letter left; we need @@ -220,7 +220,7 @@ def render-without-moving-cursor screen:&:screen, editor:&:editor -> last-row:nu row <- add row, 1 screen <- move-cursor screen, row, column # don't increment curr - loop +next-character:label + loop +next-character } print screen, c, color curr <- next curr @@ -312,7 +312,7 @@ def render-code screen:&:screen, s:text, left:num, right:num, row:num -> row:num column <- copy left row <- add row, 1 screen <- move-cursor screen, row, column - loop +next-character:label # retry i + loop +next-character # retry i } i <- add i, 1 { @@ -331,7 +331,7 @@ def render-code screen:&:screen, s:text, left:num, right:num, row:num -> row:num row <- add row, 1 column <- copy left screen <- move-cursor screen, row, column - loop +next-character:label + loop +next-character } print screen, c, color column <- add column, 1 @@ -354,7 +354,7 @@ after <global-type> [ break-unless redraw-screen? screen <- render-all screen, env:&:environment, render sync-screen screen - loop +next-event:label + loop +next-event } ] diff --git a/sandbox/005-sandbox.mu b/sandbox/005-sandbox.mu index 45dc259c..7787b50c 100644 --- a/sandbox/005-sandbox.mu +++ b/sandbox/005-sandbox.mu @@ -118,7 +118,7 @@ after <global-keypress> [ screen <- update-status screen, [ ], 245/grey } screen <- update-cursor screen, current-sandbox, env - loop +next-event:label + loop +next-event } ] @@ -366,7 +366,7 @@ def render-text screen:&:screen, s:text, left:num, right:num, color:num, row:num column <- copy left row <- add row, 1 screen <- move-cursor screen, row, column - loop +next-character:label # retry i + loop +next-character # retry i } i <- add i, 1 { @@ -385,7 +385,7 @@ def render-text screen:&:screen, s:text, left:num, right:num, color:num, row:num row <- add row, 1 column <- copy left screen <- move-cursor screen, row, column - loop +next-character:label + loop +next-character } print screen, c, color column <- add column, 1 @@ -708,7 +708,7 @@ after <global-keypress> [ hide-screen screen screen <- render-sandbox-side screen, env, render show-screen screen - jump +finish-event:label + jump +finish-event } ] @@ -737,7 +737,7 @@ after <global-keypress> [ hide-screen screen screen <- render-sandbox-side screen, env, render show-screen screen - jump +finish-event:label + jump +finish-event } ] diff --git a/sandbox/006-sandbox-copy.mu b/sandbox/006-sandbox-copy.mu index fdc1409a..ddec749f 100644 --- a/sandbox/006-sandbox-copy.mu +++ b/sandbox/006-sandbox-copy.mu @@ -136,7 +136,7 @@ after <global-touch> [ screen <- render-sandbox-side screen, env, render screen <- update-cursor screen, current-sandbox, env show-screen screen - loop +next-event:label + loop +next-event } ] diff --git a/sandbox/007-sandbox-delete.mu b/sandbox/007-sandbox-delete.mu index dba40a8f..9577a3b3 100644 --- a/sandbox/007-sandbox-delete.mu +++ b/sandbox/007-sandbox-delete.mu @@ -71,7 +71,7 @@ after <global-touch> [ screen <- render-sandbox-side screen, env, render screen <- update-cursor screen, current-sandbox, env show-screen screen - loop +next-event:label + loop +next-event } ] diff --git a/sandbox/008-sandbox-edit.mu b/sandbox/008-sandbox-edit.mu index 42778faa..f4fe0498 100644 --- a/sandbox/008-sandbox-edit.mu +++ b/sandbox/008-sandbox-edit.mu @@ -60,7 +60,7 @@ after <global-touch> [ screen <- render-sandbox-side screen, env, render screen <- update-cursor screen, current-sandbox, env show-screen screen - loop +next-event:label + loop +next-event } ] diff --git a/sandbox/009-sandbox-test.mu b/sandbox/009-sandbox-test.mu index f27b4a06..1c36a769 100644 --- a/sandbox/009-sandbox-test.mu +++ b/sandbox/009-sandbox-test.mu @@ -131,7 +131,7 @@ after <global-touch> [ screen <- update-cursor screen, current-sandbox, env # no change in cursor show-screen screen - loop +next-event:label + loop +next-event } ] @@ -194,7 +194,7 @@ after <render-sandbox-response> [ break-unless response-is-expected?:bool row, screen <- render-text screen, sandbox-response, left, right, 2/green, row } - jump +render-sandbox-end:label + jump +render-sandbox-end } ] diff --git a/sandbox/010-sandbox-trace.mu b/sandbox/010-sandbox-trace.mu index 15a4f931..3368c491 100644 --- a/sandbox/010-sandbox-trace.mu +++ b/sandbox/010-sandbox-trace.mu @@ -189,7 +189,7 @@ after <global-touch> [ screen <- update-cursor screen, current-sandbox, env # no change in cursor show-screen screen - loop +next-event:label + loop +next-event } ] diff --git a/sandbox/011-errors.mu b/sandbox/011-errors.mu index bd6d4e7c..6755af2d 100644 --- a/sandbox/011-errors.mu +++ b/sandbox/011-errors.mu @@ -120,7 +120,7 @@ after <render-sandbox-trace-done> [ } row, screen <- render-text screen, sandbox-errors, left, right, 1/red, row # don't try to print anything more for this sandbox - jump +render-sandbox-end:label + jump +render-sandbox-end } ] diff --git a/sandbox/012-editor-undo.mu b/sandbox/012-editor-undo.mu index ce8c9e21..27f49377 100644 --- a/sandbox/012-editor-undo.mu +++ b/sandbox/012-editor-undo.mu @@ -162,7 +162,7 @@ before <insert-character-end> [ typing <- put typing, after-column:offset, cursor-column typing <- put typing, after-top-of-screen:offset, top-after *op <- merge 0/insert-operation, typing - break +done-adding-insert-operation:label + break +done-adding-insert-operation } # if not, create a new operation insert-from:&:duplex-list:char <- next cursor-before @@ -742,7 +742,7 @@ before <move-cursor-end> [ move <- put move, after-column:offset, cursor-column move <- put move, after-top-of-screen:offset, top-after *op <- merge 1/move-operation, move - break +done-adding-move-operation:label + break +done-adding-move-operation } op:&:operation <- new operation:type *op <- merge 1/move-operation, cursor-row-before, cursor-column-before, top-before, cursor-row/after, cursor-column/after, top-after, undo-coalesce-tag @@ -1441,7 +1441,7 @@ before <backspace-character-end> [ deletion <- put deletion, after-column:offset, cursor-column deletion <- put deletion, after-top-of-screen:offset, top-after *op <- merge 2/delete-operation, deletion - break +done-adding-backspace-operation:label + break +done-adding-backspace-operation } # if not, create a new operation op:&:operation <- new operation:type @@ -1668,7 +1668,7 @@ before <delete-character-end> [ deletion <- put deletion, after-column:offset, cursor-column deletion <- put deletion, after-top-of-screen:offset, top-after *op <- merge 2/delete-operation, deletion - break +done-adding-delete-operation:label + break +done-adding-delete-operation } # if not, create a new operation op:&:operation <- new operation:type |