diff options
Diffstat (limited to 'shell')
-rw-r--r-- | shell/evaluate.mu | 9 | ||||
-rw-r--r-- | shell/parse.mu | 17 | ||||
-rw-r--r-- | shell/sandbox.mu | 17 | ||||
-rw-r--r-- | shell/tokenize.mu | 7 |
4 files changed, 47 insertions, 3 deletions
diff --git a/shell/evaluate.mu b/shell/evaluate.mu index 0a9aa5d5..fae2519c 100644 --- a/shell/evaluate.mu +++ b/shell/evaluate.mu @@ -85,6 +85,15 @@ fn evaluate _in: (addr handle cell), out: (addr handle cell), env-h: (handle cel trace-higher trace return } + compare *in-type, 3/stream + { + break-if-!= + # numbers are literals + trace-text trace, "eval", "stream" + copy-object _in, out + trace-higher trace + return + } compare *in-type, 2/symbol { break-if-!= diff --git a/shell/parse.mu b/shell/parse.mu index 1fc74214..03e0488e 100644 --- a/shell/parse.mu +++ b/shell/parse.mu @@ -175,9 +175,20 @@ fn parse-atom _curr-token: (addr cell), _out: (addr handle cell), trace: (addr t } return } - # default: symbol - # just copy token data - allocate-symbol _out + # default: copy either to a symbol or a stream + # stream token -> literal + var stream-token?/eax: boolean <- stream-token? curr-token + compare stream-token?, 0/false + { + break-if-= + allocate-stream _out + } + compare stream-token?, 0/false + { + break-if-!= + allocate-symbol _out + } + # copy token data var out/eax: (addr handle cell) <- copy _out var out-addr/eax: (addr cell) <- lookup *out var curr-token-data-ah/ecx: (addr handle stream byte) <- get curr-token, text-data diff --git a/shell/sandbox.mu b/shell/sandbox.mu index ad5c0a15..68ea1060 100644 --- a/shell/sandbox.mu +++ b/shell/sandbox.mu @@ -885,6 +885,23 @@ fn test-run-multiple-expressions-after-dot { # further errors may occur } +fn test-run-stream { + var sandbox-storage: sandbox + var sandbox/esi: (addr sandbox) <- address sandbox-storage + initialize-sandbox-with sandbox, "[a b]" + # eval + edit-sandbox sandbox, 0x13/ctrl-s, 0/no-globals, 0/no-disk, 0/no-screen, 0/no-tweak-screen + # setup: screen + var screen-on-stack: screen + var screen/edi: (addr screen) <- address screen-on-stack + initialize-screen screen, 0x80/width, 0x10/height, 0/no-pixel-graphics + # + render-sandbox screen, sandbox, 0/x, 0/y, 0x80/width, 0x10/height + check-screen-row screen, 0/y, "[a b] ", "F - test-run-stream/0" + check-screen-row screen, 1/y, "... ", "F - test-run-stream/1" + check-screen-row screen, 2/y, "=> [a b] ", "F - test-run-stream/2" +} + fn test-run-move-cursor-into-trace { var sandbox-storage: sandbox var sandbox/esi: (addr sandbox) <- address sandbox-storage diff --git a/shell/tokenize.mu b/shell/tokenize.mu index 1293e91f..46ca0a6b 100644 --- a/shell/tokenize.mu +++ b/shell/tokenize.mu @@ -624,6 +624,13 @@ fn number-token? _in: (addr cell) -> _/eax: boolean { fn bracket-token? _in: (addr cell) -> _/eax: boolean { var in/eax: (addr cell) <- copy _in + { + var in-type/eax: (addr int) <- get in, type + compare *in-type, 3/stream + break-if-!= + # streams are never paren tokens + return 0/false + } var in-data-ah/eax: (addr handle stream byte) <- get in, text-data var in-data/eax: (addr stream byte) <- lookup *in-data-ah rewind-stream in-data |