The query-repl Reference Manual

This is the query-repl Reference Manual, version 4.1.4, generated automatically by Declt version 4.0 beta 2 "William Riker" on Sat Dec 03 23:01:13 2022 GMT+0.

Table of Contents


1 Introduction


2 Systems

The main system appears first, followed by any subsystem dependency.


2.1 query-repl

REPL for user query.

Author

SATO Shinichi

Source Control

(GIT git@github.com:hyotang666/query-repl)

Bug Tracker

https://github.com/hyotang666/query-repl/issues

License

MIT

Version

4.1.4

Dependencies
  • check-bnf (system).
  • uiop (system).
Source

query-repl.asd.

Child Component

query-repl.lisp (file).


3 Files

Files are sorted by type and then listed depth-first from the systems components trees.


3.1 Lisp


3.1.1 query-repl/query-repl.asd

Source

query-repl.asd.

Parent Component

query-repl (system).

ASDF Systems

query-repl.


3.1.2 query-repl/query-repl.lisp

Source

query-repl.asd.

Parent Component

query-repl (system).

Packages

query-repl.

Public Interface
Internals

4 Packages

Packages are listed by definition order.


4.1 query-repl

Source

query-repl.lisp.

Use List

common-lisp.

Public Interface
Internals

5 Definitions

Definitions are sorted by export status, category, package, and then by lexicographic order.


5.1 Public Interface


5.1.1 Special variables

Special Variable: *prompt*

# \*PROMPT\*

## Description:

## Value type is T.

“‘lisp
#?
*PROMPT* :be-the “‘
Initial value is ‘">"‘

## Affected By: QUERY-PROMPT

## Notes:

Package

query-repl.

Source

query-repl.lisp.

Special Variable: *query-eval*

# \*QUERY-EVAL\*

## Description:

## Value type is BOOLEAN

“‘lisp
#?
*QUERY-EVAL* :be-the “‘
Initial value is ‘T‘

## Affected By: QUERY-READ, QUERY-EVAL

## Notes:

Package

query-repl.

Source

query-repl.lisp.


5.1.2 Macros

Macro: query-bind (binds &body body)

# QUERY-BIND

## Description:

### syntax (QUERY-BIND (&rest bind\*) &body body)
=> result

## Arguments and Values:
bind := (query-name function &key report-function interactive-function)
query-name := symbol, otherwise an implementation dependent condition.

“‘lisp
#?(query-bind (("not symbol" (lambda () :dummy))))
:signals condition
“‘
Not evaluated.

“‘lisp
#?(query-bind (((intern "Not evaluated") (lambda () :dummy))))
:signals condition
“‘
function := function, otherwise an implementation dependent condition.

“‘lisp
#?(query-bind ((name "not function")))
:signals condition
“‘

“‘lisp
#?(query-bind ((name ’no-such-function)))
:signals condition
“‘
Evaluated.

“‘lisp
#?(query-bind ((name (coerce ’list ’function))))
:invokes-debugger not
“‘
If the argument FUNCTION does not transfer control flow, EXP is returned.

“‘lisp
#?(query-bind ((name #’list))
(query-eval 0))
=> 0
“‘
report-function := function, otherwise an implementation dependent conditioin.

“‘lisp
#?(query-bind ((name #’list :report-function "not function")))
:signals condition
“‘
Evaluated.

“‘lisp
#?(query-bind ((name #’list :report-function (coerce #’print ’function)))) :invokes-debugger not
“‘
If specified such function should have API as (function (stream)).
Specified function is called to print selection report.

“‘lisp
#?(query-bind ((name (lambda () :dummy)
:report-function (lambda (s) (format s "Report"))))
(query-prompt))
:outputs "
0: [NAME] Report
> "
, :stream
“‘
When NIL (the default), selection name is printed as report.

“‘lisp
#?(query-bind ((name (lambda () :dummy)))
(query-prompt))
:outputs "
0: [NAME] NAME
> "
, :stream
“‘
interactive-function := function, otherwise an implementation dependent condition.

“‘lisp
#?(with-input-from-string (in "name")
(let ((*query-io* (make-two-way-stream in (make-broadcast-stream))))
(query-bind ((name (lambda () :dummy) :interactive-function "not function")) (query-repl))))
:signals condition
“‘
If specifed, such function should have API as (function () list).
Specifed function is called when selection is selected.

“‘lisp
#?(query-bind ((name (lambda (a) a)
:interactive-function (lambda () (list (princ :hoge)))))
(query-eval 0))
:outputs "HOGE"
“‘
If specified, such functions return value is APPLYed the first argument FUNCTION.

“‘lisp
#?(query-bind ((name #’princ :interactive-function (lambda () (list :a *standard-output*)))) (query-eval 0))
:outputs "A"
“‘
body := implicit PROGN
result := T.

## Affected By:
QUERY-REPL::*SELECTIONS*

## Side-Effects:
Modify environment i.e. QUERY-REPL::*SELECTIONS*.

## Notes:

## Exceptional-Situations:

Package

query-repl.

Source

query-repl.lisp.

Macro: query-case (query &body clauses)

# QUERY-CASE

## Description:

### syntax (QUERY-CASE query &body clauses)
=> result

## Arguments and Values:
query := Form which print query message.
clause := (name lambda-list query-param* &body body)
name := symbol, otherwise error.

“‘lisp
#?(query-case () ("not symbol" ()))
:signals error
“‘
Not evaluated.

“‘lisp
#?(query-case () ((intern "Not evaluated")))
:signals error
“‘
lambda-list := ordinary lambda list.

“‘lisp
#?(query-case () (name "not list"))
:signals error
“‘
query-param := [ :report report-form | :interactive function-name ]
report-form := [ function-name | string ]
When report-form function-name is specified, such function should have API as (function (stream)).

“‘lisp
#?(query-case () (name () :report (formatter "not function name")))
:signals error
“‘
When string is specified, treated as (lambda (s) (format s string)).

“‘lisp
#?(with-input-from-string (in "0")
(let ((*query-io* (make-two-way-stream in *query-io*)))
(query-case () (name () :report "Printed."))))
:outputs "
0: [NAME] Printed.
> "
, :stream
“‘
function-name := [ symbol | (cons (eql lambda)) ]
When interactive function is specified, such function should have API as (function () list). Returned values are applied to LAMBDA-LIST and BODY is evaluated.

“‘lisp
#?(with-input-from-string (in "0")
(let ((*query-io* (make-two-way-stream in *query-io*)))
(query-case ()
(name (a) :interactive (lambda () (list :returned))
a))))
=> :RETURNED
, :stream
“‘
body := implicit progn.
result := T

## Affected By:
QUERY-REPL::*SELECTIONS* internally.

“‘lisp
#?(with-input-from-string (in "test")
(let ((*query-io* (make-two-way-stream in *query-io*)))
(block :block
(query-bind ((test (lambda () (return-from :block :return))))
(query-case ()
(a () :a))))))
:outputs "
0: [A ] A
1: [TEST] TEST
> "
, :stream
“‘

“‘lisp
#?(with-input-from-string (in "test")
(let ((*query-io* (make-two-way-stream in *query-io*)))
(block :block
(query-bind ((test (lambda () (return-from :block :return))))
(query-case ()
(a () :a))))))
=> :RETURN
, :stream
“‘

## Side-Effects:

## Notes:

## Exceptional-Situations:

Package

query-repl.

Source

query-repl.lisp.


5.1.3 Ordinary functions

Function: paged-select (list &key max key print-page)

# PAGED-SELECT

## Description:

### syntax (PAGED-SELECT list &key (max 10) (key #’identity))
=> result

## Arguments and Values:
list := list, otherwise an implementation dependent condition.

“‘lisp
#?(paged-select "not list")
:signals condition
“‘
max := (integer 3 *), otherwise an implementation dependent condition.

“‘lisp
#?(paged-select ’(1 2 3) :max 1)
:signals condition
“‘

“‘lisp
#?(paged-select ’(1 2 3) :max -1)
:signals condition
“‘

“‘lisp
#?(paged-select ’(1 2 3) :max 10.0)
:signals condition
“‘

“‘lisp
#?(paged-select ’(1 2 3) :max "not integer")
:signals condition
“‘
When specified, output selection has specified size.

“‘lisp
#?(with-input-from-string (in "1")
(let ((*query-io* (make-two-way-stream in *query-io*))) (paged-select (loop :for i :below 10 :collect i) :max 3))) :outputs "
0: [SELECT] #:NEXT
1: [SELECT] 0
2: [SELECT] 1
> "
, :stream
“‘
key := function designator, otherwise an implementation dependent condition.

“‘lisp
#?(paged-select ’(1 2 3) :key "not function")
:signals condition
“‘
If specified, each element is applied.

“‘lisp
#?(with-input-from-string (in "1")
(let ((*query-io* (make-two-way-stream in *query-io*))) (paged-select ’(1 2 3) :key #’princ-to-string)))
=> "2"
, :test
“‘
result := T

## Affected By:
Dynamic environment of QUERY-REPL::*SELECTIONS*

“‘lisp
#?(with-input-from-string (in "3")
(let ((*query-io* (make-two-way-stream in *query-io*)))
(block :block
(query-bind ((test (lambda () (return-from :block :returned)))) (paged-select ’(1 2 3))))))
=> :RETURNED
, :stream
“‘
*QUERY-EVAL*

“‘lisp
#?(with-input-from-string (in "(print :hoge) 0")
(let ((*query-io* (make-two-way-stream in (make-broadcast-stream)))) (paged-select ’(1 2 3))))
:outputs "
:HOGE "
“‘

## Side-Effects:

## Notes:
Key function is applied only printed page elements.

“‘lisp
#?(with-input-from-string (in "1")
(let ((*query-io* (make-two-way-stream in (make-broadcast-stream)))) (paged-select (loop :for i :below 20 :collect i)
:key (lambda (x) (princ x) (force-output) x)))) :outputs "012345678"
“‘
Additionaly such function is applied only once.

“‘lisp
#?(with-input-from-string (in (concatenate ’string
"0" ; <— Choose #:NEXT.
" 1" ; <— Choose #:PREV.
" 2")) ; <— Select.
(let ((*query-io* (make-two-way-stream in (make-broadcast-stream)))) (paged-select (loop :for i :below 20 :collect i)
:key (lambda (x) (princ x) (force-output) x)))) :outputs "012345678910111213141516"
“‘

## Exceptional-Situations:

Package

query-repl.

Source

query-repl.lisp.

Function: query-eval (exp)

# QUERY-EVAL

## Description:

### syntax (QUERY-EVAL exp)
=> result

## Arguments and Values:
exp := T
result := T

## Affected By:
*QUERY-EVAL*
When *QUERY-EVAL* is NIL, EXP itself is returned.

“‘lisp
#?(query-eval ’(+))
=> 0
“‘

“‘lisp
#?(let ((*query-eval*))
(query-eval ’(+)))
=> (+)
, :test
“‘
QUERY-REPL::*SELECTIONS* internal use.
When EXP is integer and can get (nth EXP QUERY-REPL::*SELECTIONS*)
such selections interactive-function is called.

“‘lisp
#?(query-bind ((test (lambda () (princ :will-printed))))
(query-eval 0))
:outputs "WILL-PRINTED"
“‘
When EXP is symbol and can get only one slection from QUERY-REPL::*SELECTION* by its name such selections interactive-function is called.

“‘lisp
#?(query-bind ((test (lambda () (princ :will-printed))))
(query-eval :test))
:outputs "WILL-PRINTED"
“‘
When EXP is symbol and some selections are selected from QUERY-REPL::*SELECTION* by name a warning is signaled.

“‘lisp
#?(query-bind ((test (lambda () (princ :never)))
(test2 (lambda () (princ :never))))
(query-eval :test))
:signals warning
“‘
In such case, (values) are returned.

“‘lisp
#?(query-bind ((test (lambda () (princ :never)))
(test2 (lambda () (princ :never))))
(query-eval :test))
:values ()
, :ignore-signals
“‘

## Side-Effects:
Refer *QUERY-EVAL*
Modify +++ ++ + /// // / *** ** *.

## Notes:

## Exceptional-Situations:

Package

query-repl.

Source

query-repl.lisp.

Function: query-prompt (&optional *standard-output*)

# QUERY-PROMPT

## Description:

### syntax (QUERY-PROMPT &optional (\*standard-output\* \*query-io\*)) => result

## Arguments and Values:
*standard-output* := Output stream, otherwise error.

“‘lisp
#?(query-prompt "not-stream")
:signals error
“‘
result := NULL

“‘lisp
#?(query-prompt)
=> NIL
, :stream
“‘

## Affected By:
*PROMPT*

“‘lisp
#?(let ((*prompt* "input>"))
(query-prompt))
:outputs "
input> "
, :stream
“‘

## Side-Effects:
Outputs to ‘STREAM‘.

## Notes:

## Exceptional-Situations:

Package

query-repl.

Source

query-repl.lisp.

Function: query-read (&optional *standard-input*)

# QUERY-READ

## Description:
Thin wrapper for CL:READ.

### syntax (QUERY-READ &optional (\*standard-input\* \*query-io\*))
=> result

## Arguments and Values:
*standard-input* := input stream, otherwise error.

“‘lisp
#?(query-read "not stream")
:signals type-error
“‘
result := Lisp form.

## Affected By:
*QUERY-EVAL* *READ-EVAL* *READ-BASE* *READ-DEFAULT-FLOAT-FORMAT* *READ-SUPPRESS* When *QUERY-EVAL* is NIL, *READ-EVAL* is set NIL automatically.

“‘lisp
#?(let ((*query-eval*))
(with-input-from-string (*query-io* "#.(+)")
(query-read)))
:signals reader-error
“‘

## Side-Effects:
Consume stream contents.

## Notes:

## Exceptional-Situations:

Package

query-repl.

Source

query-repl.lisp.

Function: query-repl ()

# QUERY-REPL

## Description:

### syntax (QUERY-REPL)
=> result

## Arguments and Values:
result := T

## Affected By:
QUERY-REPL::*SELECTIONS*

“‘lisp
#?(block :block
(query-bind ((nil (lambda () (return-from :block 0)))) (with-input-from-string (s "0")
(let ((*query-io* (make-two-way-stream s *query-io*))) (query-repl)))))
=> 0
, :stream
“‘
*QUERY-EVAL*
When *QUERY-EVAL* is NIL, and meed #. dispatch macro
warning is signaled.

“‘lisp
#?(let (*query-eval*)
(block :block
(query-bind ((nil (lambda () (return-from :block 0)))) (with-input-from-string (s "#.1")
(let ((*query-io* (make-two-way-stream s *query-io*))) (query-repl))))))
:signals warning
“‘
In such case, do next loop.

“‘lisp
#?(let (*query-eval*)
(block :block
(query-bind ((nil (lambda () (return-from :block 0)))) (with-input-from-string (s "#.1 0")
(let ((*query-io* (make-two-way-stream s *query-io*))) (query-repl))))))
=> 0
, :stream
“‘
*READ-EVAL* *READ-BASE* *READ-DEFAULT-FLOAT-FORMAT* *READ-SUPPRESS*

## Side-Effects:
io *QUERY-IO*.

## Notes:

## Exceptional-Situations:

Package

query-repl.

Source

query-repl.lisp.

Function: select (list)

# SELECT

## Description:

### syntax (SELECT list)
=> result

## Arguments and Values:
list := list, otherwise error.

“‘lisp
#?(select :atom)
:signals type-error
“‘
result := selected elt of the list.

“‘lisp
#?(with-input-from-string (in "0") ; <— select 0 th.
(let ((*query-io* (make-two-way-stream in *query-io*)))
(select ’(1 2 3))))
=> 1
, :stream
“‘

“‘lisp
#?(with-input-from-string (in "1") ; <— select 1 th.
(let ((*query-io* (make-two-way-stream in *query-io*)))
(select ’(1 2 3))))
=> 2
, :stream
“‘

## Affected By:
Dynamic environment of QUERY-REPL::*SELECTIONS*

“‘lisp
#?(with-input-from-string (in "1")
(let ((*query-io* (make-two-way-stream in *query-io*)))
(block :block
(query-bind ((test (lambda () (return-from :block :selected)))) (select ’(:never))))))
=> :SELECTED
, :stream
“‘

## Side-Effects:
Input / Output *query-io*

“‘lisp
#?(with-input-from-string (in "1")
(let ((*query-io* (make-two-way-stream in *query-io*)))
(block :block
(query-bind ((test (lambda () (return-from :block :selected)))) (select ’(:never))))))
:outputs "
0: [SELECT] :NEVER
1: [TEST ] TEST
> "
, :stream
“‘

## Notes:

## Exceptional-Situations:

Package

query-repl.

Source

query-repl.lisp.


5.2 Internals


5.2.1 Special variables

Special Variable: *selections*
Package

query-repl.

Source

query-repl.lisp.


5.2.2 Ordinary functions

Function: <make-selection-form> (clause block)

# <MAKE-SELECTION-FORM>

## Description:

### syntax (<MAKE-SELECTION-FORM> clause block)
=> result

## Arguments and Values:
clause :=
block :=
result :=

## Affected By:

## Side-Effects:

## Notes:

## Exceptional-Situations:

## Tests.

“‘lisp
#?(<make-selection-form> ’(name ()) :block)
=> (NAME (LAMBDA () (RETURN-FROM :BLOCK (PROGN)))
:REPORT-FUNCTION (LAMBDA (query-repl::S) (FORMAT query-repl::S "~A" ’NAME)) :INTERACTIVE-FUNCTION NIL)
“‘

“‘lisp
#?(<make-selection-form> ’(name () :report fun-name-as-symbol) :block)
=> (NAME (LAMBDA () (RETURN-FROM :BLOCK (PROGN)))
:REPORT-FUNCTION #’FUN-NAME-AS-SYMBOL
:INTERACTIVE-FUNCTION NIL)
“‘

“‘lisp
#?(<make-selection-form> ’(name () :report (lambda (s) (format s "hoge"))) :block) => (NAME (LAMBDA () (RETURN-FROM :BLOCK (PROGN)))
:REPORT-FUNCTION #’(LAMBDA (S) (FORMAT S "hoge"))
:INTERACTIVE-FUNCTION NIL)
“‘

“‘lisp
#?(<make-selection-form> ’(name () :report "hoge") :block)
=> (NAME (LAMBDA () (RETURN-FROM :BLOCK (PROGN)))
:REPORT-FUNCTION (LAMBDA (query-repl::S) (FORMAT query-repl::S "hoge")) :INTERACTIVE-FUNCTION NIL)
“‘

“‘lisp
#?(<make-selection-form> ’(name () :interactive (lambda () (list 0))) :block)
=> (NAME (LAMBDA () (RETURN-FROM :BLOCK (PROGN)))
:REPORT-FUNCTION (LAMBDA (QUERY-REPL::S) (FORMAT QUERY-REPL::S "~A" ’NAME)) :INTERACTIVE-FUNCTION #’(LAMBDA () (LIST 0)))
“‘

“‘lisp
#?(<make-selection-form> ’(name () :interactive) :block)
=> (NAME (LAMBDA () (RETURN-FROM :BLOCK (PROGN :INTERACTIVE)))
:REPORT-FUNCTION (LAMBDA (QUERY-REPL::S) (FORMAT QUERY-REPL::S "~A" ’NAME)) :INTERACTIVE-FUNCTION NIL)
“‘

Package

query-repl.

Source

query-repl.lisp.

Function: copy-selection (instance)
Package

query-repl.

Source

query-repl.lisp.

Function: make-selection (&key name report-function interactive-function)
Package

query-repl.

Source

query-repl.lisp.

Function: paged-prompt (print-pagep max-page index length prompt)
Package

query-repl.

Source

query-repl.lisp.

Function: parse-query-clause (clause)
Package

query-repl.

Source

query-repl.lisp.

Function: pprint-query-case (stream exp)
Package

query-repl.

Source

query-repl.lisp.

Function: pprint-query-case-clause (stream exp &rest noise)
Package

query-repl.

Source

query-repl.lisp.

Reader: selection-interactive-function (instance)
Package

query-repl.

Source

query-repl.lisp.

Target Slot

interactive-function.

Reader: selection-name (instance)
Package

query-repl.

Source

query-repl.lisp.

Target Slot

name.

Function: selection-p (object)
Package

query-repl.

Source

query-repl.lisp.

Reader: selection-report-function (instance)
Package

query-repl.

Source

query-repl.lisp.

Target Slot

report-function.


5.2.3 Structures

Structure: selection
Package

query-repl.

Source

query-repl.lisp.

Direct superclasses

structure-object.

Direct slots
Slot: name
Type

symbol

Readers

selection-name.

Writers

This slot is read-only.

Slot: report-function
Type

function

Initform

(error "required")

Readers

selection-report-function.

Writers

This slot is read-only.

Slot: interactive-function
Type

function

Initform

(error "required")

Readers

selection-interactive-function.

Writers

This slot is read-only.


Appendix A Indexes


A.1 Concepts


A.2 Functions

Jump to:   <  
C   F   M   P   Q   S  
Index Entry  Section

<
<make-selection-form>: Private ordinary functions

C
copy-selection: Private ordinary functions

F
Function, <make-selection-form>: Private ordinary functions
Function, copy-selection: Private ordinary functions
Function, make-selection: Private ordinary functions
Function, paged-prompt: Private ordinary functions
Function, paged-select: Public ordinary functions
Function, parse-query-clause: Private ordinary functions
Function, pprint-query-case: Private ordinary functions
Function, pprint-query-case-clause: Private ordinary functions
Function, query-eval: Public ordinary functions
Function, query-prompt: Public ordinary functions
Function, query-read: Public ordinary functions
Function, query-repl: Public ordinary functions
Function, select: Public ordinary functions
Function, selection-interactive-function: Private ordinary functions
Function, selection-name: Private ordinary functions
Function, selection-p: Private ordinary functions
Function, selection-report-function: Private ordinary functions

M
Macro, query-bind: Public macros
Macro, query-case: Public macros
make-selection: Private ordinary functions

P
paged-prompt: Private ordinary functions
paged-select: Public ordinary functions
parse-query-clause: Private ordinary functions
pprint-query-case: Private ordinary functions
pprint-query-case-clause: Private ordinary functions

Q
query-bind: Public macros
query-case: Public macros
query-eval: Public ordinary functions
query-prompt: Public ordinary functions
query-read: Public ordinary functions
query-repl: Public ordinary functions

S
select: Public ordinary functions
selection-interactive-function: Private ordinary functions
selection-name: Private ordinary functions
selection-p: Private ordinary functions
selection-report-function: Private ordinary functions