Skip to content

Commit

Permalink
interp: Some better naming and typos
Browse files Browse the repository at this point in the history
  • Loading branch information
wader committed Sep 18, 2021
1 parent 3db11d3 commit 1fe5d95
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion pkg/interp/funcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import (
// TODO: make it nicer somehow? generate generators? remove from struct?
func (i *Interp) makeFunctions() []Function {
fs := []Function{
{[]string{"readline"}, 0, 2, i.readline, nil},
{[]string{"_readline"}, 0, 2, i.readline, nil},
{[]string{"eval"}, 1, 2, nil, i.eval},
{[]string{"stdin"}, 0, 0, nil, i.makeStdioFn(i.os.Stdin())},
{[]string{"stdout"}, 0, 0, nil, i.makeStdioFn(i.os.Stdout())},
Expand Down
14 changes: 7 additions & 7 deletions pkg/interp/interp.jq
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ def _repl($opts): #:: a|(Opts) => @
def _read_expr:
# both _prompt and _complete want arrays
( . as $c
| readline(_prompt; "_complete")
| _readline(_prompt; "_complete")
| if trim == "" then
$c | _read_expr
end
Expand All @@ -345,7 +345,7 @@ def _repl($opts): #:: a|(Opts) => @
# TODO: nicer way to set filename for error message
catch (. | .filename = "repl")
| if _query_pipe_last | _query_is_func("repl") then
( _query_slurp_wrap(_query_func_rename("_repl_iter"))
( _query_slurp_wrap(_query_func_rename("_repl_slurp"))
| _query_tostring as $wrap_expr
| $c
| _repl_eval($wrap_expr)
Expand All @@ -361,7 +361,7 @@ def _repl($opts): #:: a|(Opts) => @
if . == "interrupt" then empty
elif . == "eof" then error("break")
elif _eval_is_compile_error then _repl_on_error
else error(.)
else error
end
);
( _options_stack(. + [$opts]) as $_
Expand All @@ -371,13 +371,13 @@ def _repl($opts): #:: a|(Opts) => @
)
);

def _repl_iter($opts): _repl($opts);
def _repl_iter: _repl({});
def _repl_slurp($opts): _repl($opts);
def _repl_slurp: _repl({});

# just gives error, call appearing last will be renamed to _repl_iter
# just gives error, call appearing last will be renamed to _repl_slurp
def repl($_):
if options.repl then error("repl must be last")
else error("repl can only be be used from repl")
else error("repl can only be used from interactive repl")
end;
def repl: repl(null);

Expand Down
2 changes: 1 addition & 1 deletion pkg/interp/testdata/repl.fqtest
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,4 @@ $ fq -i '[1,2,3]'
$ fq -n repl
exitcode: 5
stderr:
error: repl can only be be used from repl
error: repl can only be used from interactive repl

0 comments on commit 1fe5d95

Please sign in to comment.