This is the check-bnf Reference Manual, version 8.1.30, generated automatically by Declt version 4.0 beta 2 "William Riker" on Sun Dec 15 04:35:02 2024 GMT+0.
The main system appears first, followed by any subsystem dependency.
check-bnf
Macro arguments checker.
SATO Shinichi
(GIT git@github.com:hyotang666/check-bnf)
MIT
8.1.30
alexandria
(system).
millet
(system).
closer-mop
(system).
matrix-case
(system).
check-bnf.lisp
(file).
defbnf.lisp
(file).
Files are sorted by type and then listed depth-first from the systems components trees.
check-bnf/check-bnf.lisp
check-bnf
(system).
check-bnf
(macro).
defbnf
(macro).
doc
(macro).
expression
(type).
initialize-instance
(method).
syntax-error
(function).
syntax-error
(condition).
*-checker
(function).
*bnf*
(special variable).
*default-condition*
(special variable).
*whole*
(special variable).
+-checker
(function).
<*form-body>
(function).
<*form>
(function).
<+form>
(function).
<check-type-form>
(function).
<local-atom-check-form>
(function).
<local-check-form>
(function).
<local-cons-check-form>
(function).
<local-fun>
(function).
<local-or-check-form>
(function).
<local-type-check-form>
(function).
<require-form>
(function).
<spec-form>
(function).
at-least-n-cons
(function).
bnf-definitions
(reader method).
bnf-definitions
(reader method).
but-extended-marker
(function).
capture-syntax-error
(macro).
cboundp
(function).
check-cons
(function).
checker
(class).
checker-p
(function).
cons-equal
(function).
copy-spec
(function).
definitions
(function).
extended-marker
(function).
extended-marker
(type).
ignored
(function).
length-mismatch
(condition).
local-check
(function).
may-syntax-error
(condition).
pprint-bnf
(function).
pprint-check-bnf
(function).
pprint-def-clause
(function).
pprint-def-elt
(function).
pprint-defbnf
(function).
pprint-definitions
(function).
resignaler
(function).
spec
(function).
spec
(structure).
spec-checker
(reader).
spec-name
(reader).
spec-p
(function).
t-p
(function).
type-specifier
(type).
violate-list
(condition).
whole-form<=syntax-error
(reader method).
check-bnf/defbnf.lisp
check-bnf.lisp
(file).
check-bnf
(system).
<declaration>
(function).
<function-type>
(function).
<lambda-list>
(function).
Packages are listed by definition order.
check-bnf
common-lisp
.
<declaration>
(function).
<function-type>
(function).
<lambda-list>
(function).
check-bnf
(macro).
defbnf
(macro).
doc
(macro).
expression
(type).
syntax-error
(function).
syntax-error
(condition).
*-checker
(function).
*bnf*
(special variable).
*default-condition*
(special variable).
*whole*
(special variable).
+-checker
(function).
<*form-body>
(function).
<*form>
(function).
<+form>
(function).
<check-type-form>
(function).
<local-atom-check-form>
(function).
<local-check-form>
(function).
<local-cons-check-form>
(function).
<local-fun>
(function).
<local-or-check-form>
(function).
<local-type-check-form>
(function).
<require-form>
(function).
<spec-form>
(function).
at-least-n-cons
(function).
bnf-definitions
(generic reader).
but-extended-marker
(function).
capture-syntax-error
(macro).
cboundp
(function).
check-cons
(function).
checker
(class).
checker-p
(function).
cons-equal
(function).
copy-spec
(function).
definitions
(function).
extended-marker
(function).
extended-marker
(type).
ignored
(function).
length-mismatch
(condition).
local-check
(function).
may-syntax-error
(condition).
pprint-bnf
(function).
pprint-check-bnf
(function).
pprint-def-clause
(function).
pprint-def-elt
(function).
pprint-defbnf
(function).
pprint-definitions
(function).
resignaler
(function).
spec
(function).
spec
(structure).
spec-checker
(reader).
spec-name
(reader).
spec-p
(function).
t-p
(function).
type-specifier
(type).
violate-list
(condition).
whole-form<=syntax-error
(generic reader).
Definitions are sorted by export status, category, package, and then by lexicographic order.
# CHECK-BNF
## Description:
Macro argument checker like CL:CHECK-TYPE.
In most simple case, its like CL:CHECK-TYPE.
“‘lisp
#?(let ((var ’symbol))
(check-bnf ()
((var symbol))))
=> NIL
“‘
“‘lisp
#?(let ((var "string"))
(check-bnf ()
((var symbol))))
:invokes-debugger syntax-error
, :test
“‘
You can check some place at once.
“‘lisp
#?(let ((a ’symbol)
(b "string"))
(check-bnf ()
((a symbol))
((b string))))
=> NIL
“‘
When type-specifier is expanded to T,
Efficient code is generated.
“‘lisp
#?(check-bnf ()
((a t)))
:expanded-to NIL
“‘
“‘lisp
#?(check-bnf ()
((a* t)))
:expanded-to (let ((check-bnf::*whole* nil)
(check-bnf::*bnf* ’((a* t))))
(labels ((a* (a*)
(if (typep a* ’(and atom (not null)))
(let ((check-bnf::*default-condition* ’check-bnf::violate-list))
(syntax-error ’a* "~A require LIST but ~S." ’a* a*))
nil)))
(a* a*)))
“‘
Also it occur in OR form.
“‘lisp
#?(check-bnf ()
((a (or symbol t string))))
:expanded-to NIL
“‘
“‘lisp
#?(check-bnf ()
((a (or symbol b string))
(b t)))
:expanded-to NIL
“‘
“‘lisp
#?(check-bnf ()
((a (or b c))
(b integer)
(c t)))
:expanded-to NIL
“‘
When you know VAR is list, and it has 0 or more elt. (a.k.a. *)
You can write like below.
“‘lisp
#?(let ((var* nil))
(check-bnf ()
((var* symbol))))
=> NIL
“‘
“‘lisp
#?(let ((var* ’(symbol)))
(check-bnf ()
((var* symbol))))
=> NIL
“‘
“‘lisp
#?(let ((var* ’("string")))
(check-bnf ()
((var* symbol))))
:invokes-debugger syntax-error
, :test
“‘
“‘lisp
#?(let ((var* :not-list))
(check-bnf ()
((var* symbol))))
:invokes-debugger syntax-error
, :test
“‘
When expected T, efficient code is generated.
“‘lisp
#?(CHECK-BNF () ((OPTION* KEYWORD T)))
:expanded-to (LET ((check-bnf::*WHOLE* NIL) (check-bnf::*BNF* ’((OPTION* KEYWORD T))))
(LABELS ((OPTION* (OPTION*)
(IF (TYPEP OPTION* ’(AND ATOM (NOT NULL)))
(let ((check-bnf::*default-condition* ’check-bnf::violate-list))
(SYNTAX-ERROR ’OPTION* "~A require LIST but ~S."
’option*
OPTION*))
(LOOP :FOR args :ON OPTION* :BY #’CDDR
:for (G11516 G11517)
:= (if (typep args ’(cons * (cons * *)))
args
(let ((check-bnf::*default-condition*
’check-bnf::may-syntax-error))
(syntax-error ’option*
"~A : Length mismatch. Lack last ~{~S~^ ~} of ~S~:@_in ~S"
’option*
(subseq ’(keyword t)
(mod (length args) 2))
’(keyword t)
args)))
:DO (FUNCALL
(check-bnf::RESIGNALER ’OPTION* args)
(check-bnf::CAPTURE-SYNTAX-ERROR
(UNLESS (TYPEP G11516 ’KEYWORD)
(SYNTAX-ERROR ’OPTION*
"~A : ~S comes. It is type-of ~S."
’option*
G11516
(TYPE-OF
G11516))))
(check-bnf::IGNORED G11517))))))
(OPTION* OPTION*)))
“‘
If you do not like names var as XXX*, you can specify alias.
“‘lisp
#?(let ((vars ’(symbol)))
(check-bnf ()
(((var* vars) symbol))))
=> NIL
“‘
e.g. specify for plist.
“‘lisp
#?(let ((var* ’(:key "value" :key2 "value2")))
(check-bnf ()
((var* keyword string))))
=> NIL
“‘
“‘lisp
#?(let ((var* ’(:key 2 :key2 "not integer")))
(check-bnf ()
((var* keyword integer))))
:invokes-debugger syntax-error
, :test
“‘
“‘lisp
#?(let ((var* ’(:key 1 "not-key" 2)))
(check-bnf ()
((var* keyword integer))))
:invokes-debugger syntax-error
, :test
“‘
“‘lisp
#?(let ((var* ’(:not "ballanced" :plist)))
(check-bnf ()
((var* keyword string))))
:invokes-debugger syntax-error
, :test
“‘
“‘lisp
#?(let ((var* ’(0 1)))
(check-bnf ()
((var* keyword string))))
:invokes-debugger syntax-error
, :test
“‘
e.g. specify for alist.
“‘lisp
#?(let ((var* ’((:key "value") (:key2 "value2"))))
(check-bnf ()
((var* (keyword string)))))
=> nil
“‘
“‘lisp
#?(let ((var* ’((:key "value") (:key2 :not-string))))
(check-bnf ()
((var* (keyword string)))))
:invokes-debugger syntax-error
, :test
“‘
“‘lisp
#?(let ((var* ’((:key "value") (:not "ballanced" clause))))
(check-bnf ()
((var* (keyword string)))))
:invokes-debugger syntax-error
, :test
“‘
“‘lisp
#?(let ((var* ’((:key "value") (:not-ballanced))))
(check-bnf ()
((var* (keyword string)))))
:invokes-debugger syntax-error
, :test
“‘
of course dotted are valid.
“‘lisp
#?(let ((var* ’((:key . "value"))))
(check-bnf ()
((var* (keyword . string)))))
=> nil
“‘
when you know var is list, and it has 1 or more elt, (a.k.a. +)
you can write like below.
“‘lisp
#?(let ((var+ ’(1)))
(check-bnf ()
((var+ integer))))
=> nil
“‘
“‘lisp
#?(let ((var+ ’()))
(check-bnf ()
((var+ integer))))
:invokes-debugger syntax-error
, :test
“‘
“‘lisp
#?(let ((var+ ’("not-integer")))
(check-bnf ()
((var+ integer))))
:invokes-debugger syntax-error
, :test
“‘
“‘lisp
#?(let ((var+ :not-cons))
(check-bnf ()
((var+ integer))))
:invokes-debugger syntax-error
, :test
“‘
### syntax
(check-bnf (&key ((:whole whole?))) &rest def+)
=> result
## arguments and values:
whole := form, evaluated.
“‘lisp
#?(check-bnf (:whole no-such-var)
((dummy dummy)))
:signals (or error
warning ; for ccl
)
“‘
expects var for &whole.
when specified, header and footer is generated in error message.
“‘lisp
#?(let ((a "not-symbol"))
(check-bnf ()
((a symbol))))
:invokes-debugger syntax-error
, :test
“‘
“‘lisp
#?(let ((a "not-symbol"))
(check-bnf (:whole ’(whole ("not-symbol")))
((a symbol))))
:invokes-debugger syntax-error
, :test
“‘
def := (clause+)+
clause := (var-spec spec+)
var-spec := [ name | (name name) ]
name := symbol, otherwise error.
“‘lisp
#?(check-bnf ()
(("not-symbol" dummy)))
:signals syntax-error
, :lazy
“‘
not evaluated.
“‘lisp
#?(check-bnf ()
(((intern "not evaluated") dummy)))
:signals syntax-error
, :lazy
“‘
NAME must not be a type name.
“‘lisp
#?(deftype type-name () ’symbol)
=> TYPE-NAME
“‘
“‘lisp
#?(check-bnf ()
((type-name ’symbol)))
:signals syntax-error
, :lazy
“‘
clause require one or more, otherwise syntax error.
“‘lisp
#?(check-bnf ())
:signals syntax-error
, :lazy
“‘
spec := [ type-specifier | bnf ]
bnf := [ name | list-bnf | or-form ]
list-bnf := (spec+)
or-form := (or spec+)
spec require one or more, otherwise error.
“‘lisp
#?(check-bnf ()
((dummy)))
:signals syntax-error
, :lazy
“‘
“‘lisp
#?(check-bnf ()
((dummy+ nil)))
:signals syntax-error
, :lazy
“‘
result := null
## affected by:
none
## side-effects:
none
## notes:
to check optional argument (e.g. &optional or &key), you can write like below.
“‘lisp
#?(let ((option))
(check-bnf ()
((option (or null symbol)))))
=> nil
“‘
“‘lisp
#?(let ((option ’symbol))
(check-bnf ()
((option (or null symbol)))))
=> nil
“‘
“‘lisp
#?(let ((function-name "not function-name"))
(check-bnf ()
((function-name (or name setf-name))
(name symbol)
(setf-name ((eql setf) name)))))
:invokes-debugger syntax-error
, :test
“‘
to check optional value in list, you can write like below.
“‘lisp
#?(let ((args ’(option and others)))
(check-bnf ()
((args (option? other*))
(option? (eql option))
(other* symbol))))
=> nil
“‘
“‘lisp
#?(let ((args ’(and others)))
(check-bnf ()
((args (option? other*))
(option? (eql option))
(other* symbol))))
=> nil
“‘
“‘lisp
#?(let ((args ’("not option nor other*" and others)))
(check-bnf ()
((args (option? other*))
(option? (eql option))
(other* symbol))))
:invokes-debugger syntax-error
, :test
“‘
“‘lisp
#?(LET (VAR)
(CHECK-BNF ()
((VAR (A* B*))
(A SYMBOL)
(B INTEGER))))
=> NIL
“‘
“‘lisp
#?(LET ((VAR ’(SYM)))
(CHECK-BNF ()
((VAR (A* B*))
(A SYMBOL)
(B INTEGER))))
=> NIL
“‘
“‘lisp
#?(LET ((VAR ’(SYM SYM)))
(CHECK-BNF ()
((VAR (A* B*))
(A SYMBOL)
(B INTEGER))))
=> NIL
“‘
“‘lisp
#?(LET ((VAR ’(SYM SYM 1)))
(CHECK-BNF ()
((VAR (A* B*))
(A SYMBOL)
(B INTEGER))))
=> NIL
“‘
“‘lisp
#?(LET ((VAR ’(SYM SYM 1 2)))
(CHECK-BNF ()
((VAR (A* B*))
(A SYMBOL)
(B INTEGER))))
=> NIL
“‘
“‘lisp
#?(LET ((VAR ’(SYM SYM "string")))
(CHECK-BNF ()
((VAR (A* B*))
(A SYMBOL)
(B INTEGER))))
:invokes-debugger SYNTAX-ERROR
, :test
“‘
Key value pair in heads.
“‘lisp
#?(LET ((ARGS ’(:KEY 1 :KEY 2 "doc")))
(CHECK-BNF ()
((ARGS (OPTION* DOC?))
(OPTION* KEYWORD INTEGER)
(DOC? STRING))))
=> NIL
“‘
“‘lisp
#?(LET ((ARGS ’(:KEY 1 :KEY 2)))
(CHECK-BNF ()
((ARGS (OPTION* DOC?))
(OPTION* KEYWORD INTEGER)
(DOC? STRING))))
=> NIL
“‘
“‘lisp
#?(LET ((ARGS ’(:KEY 1 :KEY 2 not-string)))
(CHECK-BNF ()
((ARGS (OPTION* DOC?))
(OPTION* KEYWORD INTEGER)
(DOC? STRING))))
:invokes-debugger syntax-error
, :test
“‘
## exceptional-situations:
every name should not conflicts cl symbol.
“‘lisp
#?(let ((list nil))
(check-bnf ()
((list list))))
=> unspecified
“‘
## example.
“‘lisp
#?(let ((var ’(symbol symbol)))
(check-bnf ()
((var (symbol symbol option*))
(option* keyword string))))
=> nil
“‘
“‘lisp
#?(let ((var ’(symbol symbol)))
(check-bnf ()
((var (symbol symbol option?))
(option? keyword))))
=> nil
“‘
“‘lisp
#?(let ((var ’(symbol symbol)))
(check-bnf ()
((var (symbol symbol required))
(required keyword))))
:invokes-debugger syntax-error
, :test
“‘
#### right side xxx*
“‘lisp
#?(let ((var ’(symbol)))
(check-bnf ()
((var (or string name*))
(name symbol))))
=> nil
“‘
“‘lisp
#?(let ((var "string"))
(check-bnf ()
((var (or string name*))
(name symbol))))
=> nil
“‘
“‘lisp
#?(let ((var ()))
(check-bnf ()
((var (or string name*))
(name symbol))))
=> nil
“‘
“‘lisp
#?(let ((var :not-list))
(check-bnf ()
((var (or string name*))
(name symbol))))
:invokes-debugger syntax-error
, :test
“‘
#### right side xxx?
“‘lisp
#?(let ((ll nil))
(check-bnf ()
((ll (var?))
(var symbol))))
=> nil
“‘
“‘lisp
#?(let ((ll ’(var)))
(check-bnf ()
((ll (var?))
(var symbol))))
=> nil
“‘
“‘lisp
#?(let ((ll ’(var too much)))
(check-bnf ()
((ll (var?))
(var symbol))))
:invokes-debugger syntax-error
, :test
“‘
“‘lisp
#?(let ((ll "not list"))
(check-bnf ()
((ll (var?))
(var symbol))))
:invokes-debugger syntax-error
, :test
“‘
“‘lisp
#?(let ((ll ’("not symbol")))
(check-bnf ()
((ll (var?))
(var symbol))))
:invokes-debugger syntax-error
, :test
“‘
## Practical case examples.
#### deftype.
“‘lisp
#?(let ((name ’name)
(lambda-list ’())
(body ’("doc" t)))
(check-bnf ()
((name (and symbol (not (or keyword boolean)))))
((lambda-list list))
((body (doc? declaration* expression*))
(doc? string)
(declaration* ((eql declare) t*)))))
=> NIL
“‘
“‘lisp
#?(let ((body ’("doc" t)))
(check-bnf ()
((body (string? declaration* expression*))
(declaration* ((eql declare) t*)))))
=> NIL
“‘
## Tests
“‘lisp
#?(let ((ll "not-list"))
(check-bnf ()
((ll <lambda-list>))))
:invokes-debugger syntax-error
, :test
“‘
#### Support compound type specifier.
#### ISSUE: Right side expression may be type specifier accidentally?
#### e.g. (vector spec)
“‘lisp
#?(let ((index 3))
(check-bnf ()
((index (mod #.array-total-size-limit)))))
=> NIL
“‘
cell-error
.
program-error
.
simple-error
.
Initarg | Value |
---|---|
:format-control |
|
(quote nil)
:whole
This slot is read-only.
(quote nil)
:definitions
This slot is read-only.
# EXPRESSION
## description:
## compound type specifier kind:
## compound type specifier syntax:
## compound type specifier arguments:
## compound type specifier description:
Collect definitions that related to THING from BNF
Return extended-marker if NAME has, otherwirse nil.
# PPRINT-CHECK-BNF
## description:
### syntax
(pprint-check-bnf stream exp)
=> result
## arguments and values:
stream :=
exp :=
result :=
## affected by:
## side-effects:
## notes:
## exceptional-situations:
## tests:
“‘lisp
#?(pprint-check-bnf nil ’(check-bnf))
:outputs "(CHECK-BNF)"
“‘
“‘lisp
#?(pprint-check-bnf nil ’(check-bnf nil))
:outputs "(CHECK-BNF ())"
“‘
“‘lisp
#?(pprint-check-bnf nil ’(check-bnf nil nil))
:outputs "(CHECK-BNF () ())"
“‘
“‘lisp
#?(pprint-check-bnf nil ’(check-bnf nil not-list))
=> unspecified
“‘
depending on implementation.
CLISP specific guard #2.
“‘lisp
#?(pprint-check-bnf nil ’(check-bnf ()
((a symbol))
((b string))))
:outputs "(CHECK-BNF ()
((A SYMBOL))
((B STRING)))"
“‘
“‘lisp
#?(pprint-check-bnf nil ’(check-bnf ()
((a symbol))
((b string))))
:outputs "(CHECK-BNF ()
((A SYMBOL))
((B STRING)))"
“‘
CLISP specific guard #3.
“‘lisp
#?(format nil "~<~:@_~:>" nil)
=> ""
, :test
“‘
“‘lisp
#?(pprint-check-bnf nil ’(check-bnf ()
((function-name (or name setf-name))
(name symbol)
(setf-name ((eql setf) name)))))
:outputs "(CHECK-BNF ()
((FUNCTION-NAME (OR NAME SETF-NAME))
(NAME SYMBOL)
(SETF-NAME ((EQL SETF) NAME))))"
“‘
“‘lisp
#?(PPRINT-CHECK-BNF NIL
’(CHECK-BNF ()
(A
B)))
:outputs "(CHECK-BNF ()
(A
B))"
“‘
checker
)) ¶automatically generated reader method
syntax-error
)) ¶syntax-error
)) ¶funcallable-standard-object
.
:definitions
This slot is read-only.
Jump to: | *
+
<
A B C D E F G I L M P R S T W |
---|
Jump to: | *
+
<
A B C D E F G I L M P R S T W |
---|
Jump to: | *
C D N S W |
---|
Jump to: | *
C D N S W |
---|
Jump to: | C D E F L M P S T V |
---|
Jump to: | C D E F L M P S T V |
---|