all repos — min @ 9e04fa3009e1ea6114defe2b282a04f6515e7477

A small but practical concatenative programming language.

Fixed some warnings; added putch and getch (ref: #59)
h3rald h3rald@h3rald.com
Tue, 16 Jun 2020 09:11:23 +0200
commit

9e04fa3009e1ea6114defe2b282a04f6515e7477

parent

fde9f8108d4d92b9441cbdd74d7a69b1e7dd1dd0

4 files changed, 18 insertions(+), 3 deletions(-)

jump to
M core/interpreter.nimcore/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.nimlib/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.nimlib/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.mdsite/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.#}