aboutsummaryrefslogtreecommitdiff
path: root/tools/repl.nom
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2019-01-14 15:42:48 -0800
committerBruce Hill <bruce@bruce-hill.com>2019-01-14 15:43:24 -0800
commitc1c32688a4afc43f6addb99b8b5fa878944a70e3 (patch)
treec886f21b5b08a9053aa74fcba4b241dae5ede76d /tools/repl.nom
parent2309b696fc34b24f05f6658b94f9105ca8ee76e4 (diff)
Overhaul in progress, mostly working. Moved all the nomsu packages into
lib/, including core/*. Changes to how nomsu environments and importing work.
Diffstat (limited to 'tools/repl.nom')
-rwxr-xr-xtools/repl.nom84
1 files changed, 0 insertions, 84 deletions
diff --git a/tools/repl.nom b/tools/repl.nom
deleted file mode 100755
index 175d068..0000000
--- a/tools/repl.nom
+++ /dev/null
@@ -1,84 +0,0 @@
-#!/usr/bin/env nomsu -V6.14
-#
- This file defines a Read-Evaluate-Print-Loop (REPL) for Nomsu
-
-use "lib/consolecolor"
-use "lib/os"
-
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-externally (help) means:
- say ("
- This is the Nomsu v\(Nomsu version) interactive console.
- You can type in Nomsu code here and hit 'enter' twice to run it.
- To exit, type 'exit' or 'quit' and hit enter twice.
- ")
-
-say ("
-
- \(bright)\(underscore)Welcome to the Nomsu v\(Nomsu version) interactive console!\
- ..\(reset color)
- press 'enter' twice to run a command
-
-")
-
-repeat:
- say (bright (yellow ">> ")) inline
- $buff = []
- repeat:
- say (bright) inline
- $line = ($io.read "*L")
- say (reset color) inline
- if (($line == "\n") or (not $line)):
- if ((size of $buff) > 0):
- # clear the line
- say "\027[1A\027[2K" inline
- go to (run buffer)
- $buff, add ($line, with "\t" -> " ")
- say (dim (yellow ".. ")) inline
-
- --- (run buffer) ---
-
- if ((size of $buff) == 0): stop
- $buff = ($buff, joined)
- spoof file $buff
- try:
- $tree = ($buff parsed)
- ..if it fails with $err:
- say $err
- do next
-
- unless $tree:
- do next
-
- for $chunk in $tree:
- try:
- $lua = ($chunk as lua)
- ..if it fails with $err: say $err
-
- unless $lua:
- do next
-
- # TODO: this is a bit hacky, it just defaults variables to global
- so that stuff mostly works across multiple lines. It would be
- nicer if local variables actually worked.
- $lua, remove free vars
- try:
- $ret = (run $lua)
- ..if it fails with $err: say $err
- ..if it succeeds:
- if (type of $ret) is:
- "nil":
- do nothing
-
- "boolean":
- say "= \("yes" if $ret else "no")"
-
- "table":
- if $ret.as_nomsu:
- say "= \($ret, as nomsu)"
- ..else:
- say "= \$ret"
-
- else:
- say "= \$ret"