Friendlier :help
parent
28035296f4
commit
d727edea89
|
@ -1,7 +1,7 @@
|
|||
! Copyright (C) 2004, 2006 Slava Pestov.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
IN: kernel-internals
|
||||
USING: generic sequences ;
|
||||
USING: generic namespaces sequences ;
|
||||
|
||||
: >c ( continuation -- ) catchstack* push ;
|
||||
: c> ( -- continuation ) catchstack* pop ;
|
||||
|
@ -16,6 +16,7 @@ USING: kernel ;
|
|||
catchstack* empty? [
|
||||
die
|
||||
] [
|
||||
dup error set-global
|
||||
c> dup quotation? [ call ] [ continue-with ] if
|
||||
] if ;
|
||||
|
||||
|
|
|
@ -87,7 +87,7 @@ M: tuple = ( obj tuple -- ? )
|
|||
[ 2drop t ] [ over tuple? [ tuple= ] [ 2drop f ] if ] if ;
|
||||
|
||||
: (delegates) ( obj -- )
|
||||
[ dup , delegate (delegates) ] when* ;
|
||||
[ dup delegate (delegates) , ] when* ;
|
||||
|
||||
: delegates ( obj -- seq )
|
||||
[ (delegates) ] { } make ;
|
||||
|
|
|
@ -31,18 +31,17 @@ SYMBOL: string-mode
|
|||
[ "Use the word " swap synopsis append ] keep 2array
|
||||
] map ;
|
||||
|
||||
: word-not-found ( str -- word )
|
||||
"No word named "
|
||||
over
|
||||
" found in current vocabulary search path" append3
|
||||
swap do-what-i-mean condition ;
|
||||
TUPLE: no-word name ;
|
||||
|
||||
: no-word ( str -- word )
|
||||
dup <no-word> swap do-what-i-mean condition ;
|
||||
|
||||
: scan-word ( -- obj )
|
||||
scan dup [
|
||||
dup ";" = not string-mode get and [
|
||||
dup use get hash-stack [ ] [
|
||||
dup string>number [ ] [
|
||||
word-not-found dup word-vocabulary use+
|
||||
no-word dup word-vocabulary use+
|
||||
] ?if
|
||||
] ?if
|
||||
] unless
|
||||
|
|
|
@ -35,6 +35,12 @@ HELP: string-mode f
|
|||
"Since no parsing words are invoked in string mode, there is a special case that ends it; if the token " { $snippet ";" } " is read, string mode is switched off and the " { $link POSTPONE: ; } " parsing word is called."
|
||||
} ;
|
||||
|
||||
HELP: no-word "( name -- )"
|
||||
{ $values { "name" "a string" } }
|
||||
{ $description "Throws a " { $link no-word } " error." }
|
||||
{ $error-description "Thrown if the parser encounters a token which does not name a word in the current vocabulary search path. If any words with this name exist in vocabularies not part of the search path, a number of restarts will offer to add those vocabularies to the search path and use the chosen word." }
|
||||
{ $notes "Apart from a missing " { $link POSTPONE: USE: } ", this error can also indicate an ordering issue. In Factor, words must be defined before they can be called." } ;
|
||||
|
||||
HELP: scan-word "( -- obj )"
|
||||
{ $values { "obj" "a word or a number" } }
|
||||
{ $description "Reads the next token from the line currently being parsed. First tries to look up the word in the dictionary, and if the lookup fails, attempts to convert the token to a number." }
|
||||
|
|
|
@ -29,13 +29,19 @@ SYMBOL: restarts
|
|||
: :get error-continuation get continuation-name hash-stack ;
|
||||
: :res restarts get nth first3 continue-with ;
|
||||
|
||||
: (:help-multi)
|
||||
"This error has multiple delegates:" print help-outliner ;
|
||||
|
||||
: (:help-none)
|
||||
drop "No help for this error. " print ;
|
||||
|
||||
: :help ( -- )
|
||||
error get delegates [ error-help ] map [ ] subset
|
||||
dup empty? [
|
||||
"No help for this error. " print
|
||||
] [
|
||||
[ help ] each
|
||||
] if ;
|
||||
{
|
||||
{ [ dup empty? ] [ (:help-none) ] }
|
||||
{ [ dup length 1 = ] [ first help ] }
|
||||
{ [ t ] [ (:help-multi) ] }
|
||||
} cond ;
|
||||
|
||||
: (debug-help) ( string quot -- )
|
||||
<input> write-object terpri ;
|
||||
|
|
|
@ -136,6 +136,9 @@ M: slice-error error.
|
|||
"Cannot create slice because " write
|
||||
slice-error-reason append print ;
|
||||
|
||||
M: no-word summary
|
||||
drop "Word not found in current vocabulary search path" ;
|
||||
|
||||
: parse-dump ( error -- )
|
||||
"Parsing " write
|
||||
dup parse-error-file [ "<interactive>" ] unless* write
|
||||
|
|
|
@ -5,7 +5,7 @@ USING: generic hashtables kernel math models namespaces queues
|
|||
sequences words ;
|
||||
|
||||
: gestures ( gadget -- seq )
|
||||
delegates [ "gestures" word-prop ] map [ ] subset ;
|
||||
delegates [ class "gestures" word-prop ] map [ ] subset ;
|
||||
|
||||
: set-gestures ( class hash -- ) "gestures" set-word-prop ;
|
||||
|
||||
|
|
Loading…
Reference in New Issue