Friendlier :help
parent
28035296f4
commit
d727edea89
|
@ -1,7 +1,7 @@
|
||||||
! Copyright (C) 2004, 2006 Slava Pestov.
|
! Copyright (C) 2004, 2006 Slava Pestov.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
IN: kernel-internals
|
IN: kernel-internals
|
||||||
USING: generic sequences ;
|
USING: generic namespaces sequences ;
|
||||||
|
|
||||||
: >c ( continuation -- ) catchstack* push ;
|
: >c ( continuation -- ) catchstack* push ;
|
||||||
: c> ( -- continuation ) catchstack* pop ;
|
: c> ( -- continuation ) catchstack* pop ;
|
||||||
|
@ -16,6 +16,7 @@ USING: kernel ;
|
||||||
catchstack* empty? [
|
catchstack* empty? [
|
||||||
die
|
die
|
||||||
] [
|
] [
|
||||||
|
dup error set-global
|
||||||
c> dup quotation? [ call ] [ continue-with ] if
|
c> dup quotation? [ call ] [ continue-with ] if
|
||||||
] if ;
|
] if ;
|
||||||
|
|
||||||
|
|
|
@ -87,7 +87,7 @@ M: tuple = ( obj tuple -- ? )
|
||||||
[ 2drop t ] [ over tuple? [ tuple= ] [ 2drop f ] if ] if ;
|
[ 2drop t ] [ over tuple? [ tuple= ] [ 2drop f ] if ] if ;
|
||||||
|
|
||||||
: (delegates) ( obj -- )
|
: (delegates) ( obj -- )
|
||||||
[ dup , delegate (delegates) ] when* ;
|
[ dup delegate (delegates) , ] when* ;
|
||||||
|
|
||||||
: delegates ( obj -- seq )
|
: delegates ( obj -- seq )
|
||||||
[ (delegates) ] { } make ;
|
[ (delegates) ] { } make ;
|
||||||
|
|
|
@ -31,18 +31,17 @@ SYMBOL: string-mode
|
||||||
[ "Use the word " swap synopsis append ] keep 2array
|
[ "Use the word " swap synopsis append ] keep 2array
|
||||||
] map ;
|
] map ;
|
||||||
|
|
||||||
: word-not-found ( str -- word )
|
TUPLE: no-word name ;
|
||||||
"No word named "
|
|
||||||
over
|
: no-word ( str -- word )
|
||||||
" found in current vocabulary search path" append3
|
dup <no-word> swap do-what-i-mean condition ;
|
||||||
swap do-what-i-mean condition ;
|
|
||||||
|
|
||||||
: scan-word ( -- obj )
|
: scan-word ( -- obj )
|
||||||
scan dup [
|
scan dup [
|
||||||
dup ";" = not string-mode get and [
|
dup ";" = not string-mode get and [
|
||||||
dup use get hash-stack [ ] [
|
dup use get hash-stack [ ] [
|
||||||
dup string>number [ ] [
|
dup string>number [ ] [
|
||||||
word-not-found dup word-vocabulary use+
|
no-word dup word-vocabulary use+
|
||||||
] ?if
|
] ?if
|
||||||
] ?if
|
] ?if
|
||||||
] unless
|
] 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."
|
"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 )"
|
HELP: scan-word "( -- obj )"
|
||||||
{ $values { "obj" "a word or a number" } }
|
{ $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." }
|
{ $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 ;
|
: :get error-continuation get continuation-name hash-stack ;
|
||||||
: :res restarts get nth first3 continue-with ;
|
: :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 ( -- )
|
: :help ( -- )
|
||||||
error get delegates [ error-help ] map [ ] subset
|
error get delegates [ error-help ] map [ ] subset
|
||||||
dup empty? [
|
{
|
||||||
"No help for this error. " print
|
{ [ dup empty? ] [ (:help-none) ] }
|
||||||
] [
|
{ [ dup length 1 = ] [ first help ] }
|
||||||
[ help ] each
|
{ [ t ] [ (:help-multi) ] }
|
||||||
] if ;
|
} cond ;
|
||||||
|
|
||||||
: (debug-help) ( string quot -- )
|
: (debug-help) ( string quot -- )
|
||||||
<input> write-object terpri ;
|
<input> write-object terpri ;
|
||||||
|
|
|
@ -136,6 +136,9 @@ M: slice-error error.
|
||||||
"Cannot create slice because " write
|
"Cannot create slice because " write
|
||||||
slice-error-reason append print ;
|
slice-error-reason append print ;
|
||||||
|
|
||||||
|
M: no-word summary
|
||||||
|
drop "Word not found in current vocabulary search path" ;
|
||||||
|
|
||||||
: parse-dump ( error -- )
|
: parse-dump ( error -- )
|
||||||
"Parsing " write
|
"Parsing " write
|
||||||
dup parse-error-file [ "<interactive>" ] unless* write
|
dup parse-error-file [ "<interactive>" ] unless* write
|
||||||
|
|
|
@ -5,7 +5,7 @@ USING: generic hashtables kernel math models namespaces queues
|
||||||
sequences words ;
|
sequences words ;
|
||||||
|
|
||||||
: gestures ( gadget -- seq )
|
: gestures ( gadget -- seq )
|
||||||
delegates [ "gestures" word-prop ] map [ ] subset ;
|
delegates [ class "gestures" word-prop ] map [ ] subset ;
|
||||||
|
|
||||||
: set-gestures ( class hash -- ) "gestures" set-word-prop ;
|
: set-gestures ( class hash -- ) "gestures" set-word-prop ;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue