From 3369875ccd0e42a8639509a400d2d9cb1356d79a Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Sat, 20 Aug 2016 19:29:45 -0700 Subject: 3233 - change how Mu escapes strings Thanks Sam Putman for helping think through this idea. When you encounter a backslash, strip it out and pass through any following run of backslashes. If we 'escaped' a single following character like C, then the character '\' would be the same as: '\\' escaped once '\\\\' escaped twice '\\\\\\\\' escaped thrice (8 backslashes) ..and so on, the number of backslashes doubling each time. Instead, our approach is to make the character '\' the same as: '\\' escaped once '\\\' escaped twice '\\\\' escaped thrice ..and so on, the number of backslashes merely increasing by one each time. This approach only works as long as backslashes aren't also overloaded to create special characters. So Mu doesn't follow C's approach of overloading backslashes both to escape quote characters and also as a notation for unprintable characters like '\n'. --- sandbox/011-errors.mu | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'sandbox/011-errors.mu') diff --git a/sandbox/011-errors.mu b/sandbox/011-errors.mu index e326e446..f2652aaa 100644 --- a/sandbox/011-errors.mu +++ b/sandbox/011-errors.mu @@ -362,10 +362,9 @@ scenario run-shows-unbalanced-bracket-errors [ assume-screen 50/width, 20/height # recipe is incomplete (unbalanced '[') 1:address:array:character <- new [ -recipe foo « +recipe foo \\[ x <- copy 0 ] - replace 1:address:array:character, 171/«, 91 # '[' 2:address:array:character <- new [foo] 3:address:programming-environment-data <- new-programming-environment screen:address:screen, 2:address:array:character assume-console [ @@ -380,8 +379,8 @@ recipe foo « .━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━. .0 edit copy delete . .foo . - .9: unbalanced '\\\[' for recipe . - .9: unbalanced '\\\[' for recipe . + .9: unbalanced '\\[' for recipe . + .9: unbalanced '\\[' for recipe . .━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━. . . ] -- cgit 1.4.1-2-gfad0