]> gitweb.factorcode.org Git - factor.git/blob - extra/lisp/parser/mod/mod.factor
Initial import
[factor.git] / extra / lisp / parser / mod / mod.factor
1 ! Broken by recent changes
2
3 USING: kernel vocabs words combinators math
4        namespaces arrays sequences assocs sorting
5        inspector vars ;
6
7 IN: parser
8
9 ! ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
10
11 ! : word-restarts ( string -- restarts )
12 ! words-named natural-sort
13 ! [ [ "Use the word " swap summary append ] keep 2array ] map
14 ! { "Define this word as a symbol" 0 } add
15 ! { "Defer this word in the 'scratchpad' vocabulary" f } add ;
16
17 ! : no-word-option ( obj -- word )
18 ! { { [ dup f = ] [ drop in get create ] }
19 !   { [ dup 0 = ] [ drop in get create dup define-symbol ] }
20 !   { [ t ]       [ nip dup word-vocabulary use+ ] }
21 ! } cond ;
22
23 VAR: new-symbol-action ! ( str -- word )
24
25 ! [ dup no-word no-word-option ] new-symbol-action set-global 
26
27 ! ! For lisp:
28 ! ! 
29 ! ! [ in get create dup define-symbol ] >new-symbol-action
30
31 ! : search ( str -- word )
32 ! { { [ dup use get assoc-stack ]
33 !     [ use get assoc-stack ] }
34 !   { [ dup words-named empty? ]
35 !     [ new-symbol-action> call ] }
36 !   { [ dup words-named length 0 > ]
37 !     [ dup no-word no-word-option ] }
38 ! } cond ;