]> gitweb.factorcode.org Git - factor.git/blob - unmaintained/modules/using/using.factor
updated modules.util to use manifests
[factor.git] / unmaintained / modules / using / using.factor
1 USING: accessors assocs kernel modules.remote-loading modules.rpc
2 namespaces peg peg.ebnf peg-lexer sequences vocabs vocabs.parser
3 strings ;
4 IN: modules.using
5
6 : >qualified ( vocab prefix -- assoc )
7     [ vocab-words ] [ 58 suffix ] bi* [ swap [ prepend ] dip ] curry assoc-map ;
8
9 : >partial-vocab ( words assoc -- assoc )
10     [ dupd at [ no-word-error ] unless* ] curry { } map>assoc ;
11
12 : remote-load ( addr vocabspec -- voab ) [ "modules.remote-loading" remote-vocab use-vocab ] dip get-vocab ;
13
14 : load'em ( vocab words/? -- ) [ swap >partial-vocab ] when* manifest get qualified-vocabs>> push ;
15
16 EBNF: modulize
17 tokenpart = (!(':').)+ => [[ >string ]]
18 s = ':' => [[ drop ignore ]]
19 rpc = tokenpart s s tokenpart => [[ first2 remote-vocab ]]
20 remote = tokenpart s tokenpart => [[ first2 remote-load ]]
21 plain = tokenpart => [[ load-vocab ]]
22 module = rpc | remote | plain
23 ;EBNF
24
25 ON-BNF: USING:
26 tokenizer = <foreign factor>
27 sym = !(";"|"}"|"=>").
28 modspec = sym => [[ modulize ]]
29 qualified = modspec sym => [[ first2 >qualified ]]
30 unqualified = modspec => [[ vocab-words ]]
31 words = ("=>" sym+ )? => [[ [ f ] [ second ] if-empty ]]
32 long = "{" ( qualified | unqualified ) words "}" => [[ rest first2 load'em ignore ]]
33 short = modspec => [[ use-vocab ignore ]]
34 wordSpec = long | short
35 using = wordSpec+ ";" => [[ drop ignore ]]
36 ;ON-BNF