2020-01-05 14:02:39 +03:00
|
|
|
include "reader";
|
|
|
|
include "printer";
|
2020-01-05 17:03:09 +03:00
|
|
|
include "utils";
|
2020-01-05 14:02:39 +03:00
|
|
|
|
|
|
|
def read_line:
|
|
|
|
. as $in
|
|
|
|
| label $top
|
2020-01-08 17:36:57 +03:00
|
|
|
| _readline;
|
2020-01-05 14:02:39 +03:00
|
|
|
|
|
|
|
def READ:
|
2020-01-05 18:05:49 +03:00
|
|
|
read_str | read_form | .value;
|
2020-01-05 14:02:39 +03:00
|
|
|
|
|
|
|
def EVAL:
|
2020-01-05 18:05:49 +03:00
|
|
|
.;
|
2020-01-05 14:02:39 +03:00
|
|
|
|
|
|
|
def PRINT:
|
2020-01-05 17:03:09 +03:00
|
|
|
pr_str;
|
2020-01-05 14:02:39 +03:00
|
|
|
|
|
|
|
def rep:
|
2020-01-05 17:03:09 +03:00
|
|
|
READ | EVAL |
|
|
|
|
if . != null then
|
|
|
|
PRINT
|
|
|
|
else
|
|
|
|
null
|
|
|
|
end;
|
2020-01-05 14:02:39 +03:00
|
|
|
|
|
|
|
def repl_:
|
2020-01-06 10:30:26 +03:00
|
|
|
("user> " | _print) |
|
2020-01-05 17:03:09 +03:00
|
|
|
(read_line | rep);
|
2020-01-05 14:02:39 +03:00
|
|
|
|
|
|
|
def repl:
|
2020-01-05 17:03:09 +03:00
|
|
|
{continue: true} | while(
|
|
|
|
.continue;
|
|
|
|
try {value: repl_, continue: true}
|
|
|
|
catch
|
|
|
|
if is_jqmal_error then
|
|
|
|
{value: "Error: \(.)", continue: true}
|
|
|
|
else
|
|
|
|
{value: ., continue: false}
|
2020-01-10 17:13:51 +03:00
|
|
|
end) | if .value then .value|_display else empty end;
|
2020-01-05 14:02:39 +03:00
|
|
|
|
|
|
|
repl
|