Fixed some warnings; added putch and getch (ref: #59)
h3rald h3rald@h3rald.com
Tue, 16 Jun 2020 09:11:23 +0200
4 files changed,
18 insertions(+),
3 deletions(-)
M
core/interpreter.nim
→
core/interpreter.nim
@@ -11,8 +11,8 @@ scope,
parser type - MinTrappedException* = ref object of Exception - MinRuntimeError* = ref object of Exception + MinTrappedException* = ref object of CatchableError + MinRuntimeError* = ref object of CatchableError data*: MinValue proc raiseRuntime*(msg: string, data: MinValue) {.extern:"min_exported_symbol_$1".}=
M
lib/min_http.nim
→
lib/min_http.nim
@@ -16,7 +16,7 @@ result = newDict(i.scope)
for k, v in headers: result = i.dset(result, k, v.newVal) -type MinServerExit = ref object of Exception +type MinServerExit = ref object of CatchableError # Http
M
lib/min_io.nim
→
lib/min_io.nim
@@ -66,6 +66,15 @@ def.symbol("gets") do (i: In):
var ed = initEditor() i.push ed.readLine().newVal + def.symbol("getchr") do (i: In): + i.push getchr().newVal + + def.symbol("putchr") do (i: In): + let ch = i.expect("string") + if ch[0].getString.len != 1: + raiseInvalid("Symbol putch requires a string containing a single character.") + putchr(ch[0].getString[0].cint) + def.symbol("password") do (i: In): var ed = initEditor() i.push ed.password("Enter Password: ").newVal
M
site/contents/reference-io.md
→
site/contents/reference-io.md
@@ -40,6 +40,9 @@
{#op||fwrite||{{s1}} {{s2}}||{{null}}|| Writes {{s1}} to the file {{s2}}, erasing all its contents first. #} +{#op||getchr||{{null}}||{{i}}|| +Reads single character from STDIN without waiting for ENTER key and places its ASCII code on top of the stack.#} + {#op||gets||{{null}}||{{s}}|| Reads a line from STDIN and places it on top of the stack as a string.#}@@ -60,6 +63,9 @@ Prints {{any}} to STDOUT.#}
{#op||print!||{{any}}||{{null}}|| Prints {{any}} to STDOUT and removes {{any}} from the stack.#} + +{#op||putchr||{{s}}||{{any}}|| +Prints {{s}} to STDOUT without printing a new line ({{s}} must contain only one character).#} {#op||puts||{{any}}||{{any}}|| Prints {{any}} and a new line to STDOUT.#}