Fixed to display expressions by default.

This commit is contained in:
Bruce Hill 2019-01-23 15:36:09 -08:00
parent 967f172094
commit 113b916e4c

View File

@ -16,15 +16,32 @@ external:
To exit, type 'exit' or 'quit' and hit enter twice. To exit, type 'exit' or 'quit' and hit enter twice.
") ")
(tutorial) means:
(use "tools/tutorial").run_with {.extras = []}
exit
command line program with $args: command line program with $args:
say (" say ("
\(bright)\(underscore)Welcome to the Nomsu v\(Nomsu version) interactive console!\ \(bright)\(underscore)Welcome to the Nomsu v\(Nomsu version) interactive console!\
..\(reset color) ..\(reset color)
press 'enter' twice to run a command press 'enter' twice to run a command
type 'tutorial' to run the tutorial
") ")
# Best way I know of to detect the number of return values and only
print if it's >0:
(say results of (*extra arguments*)) means:
$N = (select "#" (*extra arguments*))
if ($N == 0):
return
for $ in 1 to $N:
$ret = (select $ (*extra arguments*))
if ($ret is "Text"):
$ret = (quote $ret)
say "\$ret"
repeat: repeat:
say (bright (yellow ">> ")) inline say (bright (yellow ">> ")) inline
$buff = [] $buff = []
@ -51,7 +68,7 @@ command line program with $args:
unless $tree: unless $tree:
do next do next
for $chunk in $tree: for $chunk in $tree:
try: try:
$lua = ($chunk as lua) $lua = ($chunk as lua)
@ -64,22 +81,9 @@ command line program with $args:
so that stuff mostly works across multiple lines. It would be so that stuff mostly works across multiple lines. It would be
nicer if local variables actually worked. nicer if local variables actually worked.
$lua, remove free vars $lua, remove free vars
if (load "return \($lua, text)"):
$lua, prepend "return "
try: try:
$ret = (run $lua) say results of (run $lua)
..if it fails with $err: say $err ..if it fails with $err: say $err
..if it succeeds:
if (lua 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"