diff --git a/library/errors.factor b/library/errors.factor index be7da35dc1..6d91006879 100644 --- a/library/errors.factor +++ b/library/errors.factor @@ -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 ; diff --git a/library/generic/tuple.factor b/library/generic/tuple.factor index 4e390397e6..07a152f5a9 100644 --- a/library/generic/tuple.factor +++ b/library/generic/tuple.factor @@ -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 ; diff --git a/library/syntax/parser.factor b/library/syntax/parser.factor index fa21f21695..cab04055e0 100644 --- a/library/syntax/parser.factor +++ b/library/syntax/parser.factor @@ -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 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 diff --git a/library/syntax/parser.facts b/library/syntax/parser.facts index 498c1cc192..7141e236fa 100644 --- a/library/syntax/parser.facts +++ b/library/syntax/parser.facts @@ -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." } diff --git a/library/tools/debugger.factor b/library/tools/debugger.factor index 07194f634e..35f44186ec 100644 --- a/library/tools/debugger.factor +++ b/library/tools/debugger.factor @@ -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 -- ) write-object terpri ; diff --git a/library/tools/errors.factor b/library/tools/errors.factor index 3217a321fb..c9d9b7f471 100644 --- a/library/tools/errors.factor +++ b/library/tools/errors.factor @@ -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 [ "" ] unless* write diff --git a/library/ui/gestures.factor b/library/ui/gestures.factor index 6059881990..4279d57222 100644 --- a/library/ui/gestures.factor +++ b/library/ui/gestures.factor @@ -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 ;