diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2019-01-01 15:05:58 -0800 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2019-01-01 15:07:10 -0800 |
| commit | b6d3cbd61cd08e39d20a569b7c5ece6bb25897dd (patch) | |
| tree | ccf3930b7a2834ffad1a10a9d91f0042542dec34 /tools | |
| parent | 0760d4fb6495c4aa4f74038457acede5063f514a (diff) | |
Misc changes, including text indented interpolations are now indented
relative to the text, not the opening '("', code objects can now remove
all free vars, the REPL uses global vars. Error API is changing a bit.
Diffstat (limited to 'tools')
| -rwxr-xr-x | tools/repl.nom | 57 |
1 files changed, 38 insertions, 19 deletions
diff --git a/tools/repl.nom b/tools/repl.nom index 983de5f..4240ddc 100755 --- a/tools/repl.nom +++ b/tools/repl.nom @@ -42,25 +42,44 @@ repeat: if ((size of $buff) == 0): stop $buff = ($buff, joined) - - # TODO: support local variables spoof file $buff try: - $ret = (run $buff) - ..and if it barfs $err: say $err - ..or 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: + $tree = ($buff parsed) + ..and if it barfs $err: + say $err + do next + + unless $tree: + do next + + for $chunk in $tree: + try: + $lua = ($chunk as lua) + ..and if it barfs $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) + ..and if it barfs $err: say $err + ..or 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" - - else: - say "= \$ret" |
