-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add first pass of integer basic decoding
It doesn't do proper spacing yet - the intbasic code listing is extremely tricky to undestand.
- Loading branch information
Showing
8 changed files
with
382 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// Package basic contains routines useful for both Applesoft and | ||
// Integer BASIC. | ||
package basic | ||
|
||
import "regexp" | ||
|
||
var controlCharRegexp = regexp.MustCompile(`[\x00-\x1F]`) | ||
|
||
// ChevronControlCodes converts ASCII control characters like chr(4) | ||
// to chevron-surrounded codes like «ctrl-D». | ||
func ChevronControlCodes(s string) string { | ||
return controlCharRegexp.ReplaceAllStringFunc(s, func(s string) string { | ||
if s == "\n" || s == "\t" { | ||
return s | ||
} | ||
if s >= "\x01" && s <= "\x1a" { | ||
return "«ctrl-" + string('A'-1+s[0]) + "»" | ||
} | ||
code := "?" | ||
switch s[0] { | ||
case '\x00': | ||
code = "NUL" | ||
case '\x1C': | ||
code = "FS" | ||
case '\x1D': | ||
code = "GS" | ||
case '\x1E': | ||
code = "RS" | ||
case '\x1F': | ||
code = "US" | ||
} | ||
|
||
return "«" + code + "»" | ||
}) | ||
} |
Oops, something went wrong.