Skip to content

Commit

Permalink
vocabs: use valid-vocab-name? to filter disk vocabs
Browse files Browse the repository at this point in the history
  • Loading branch information
mrjbq7 committed Jan 9, 2024
1 parent af8e25b commit 21cdff9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
8 changes: 6 additions & 2 deletions basis/vocabs/hierarchy/hierarchy.factor
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
USING: accessors arrays assocs combinators.short-circuit fry
io.directories io.files io.files.info io.pathnames kernel make
memoize namespaces sequences sets sorting splitting vocabs
vocabs.loader vocabs.metadata ;
vocabs.private vocabs.loader vocabs.metadata ;
IN: vocabs.hierarchy

TUPLE: vocab-prefix name ;
Expand All @@ -15,7 +15,11 @@ M: vocab-prefix vocab-name name>> ;
<PRIVATE

: visible-dir? ( entry -- ? )
{ [ directory? ] [ name>> "." head? not ] } 1&& ;
{
[ directory? ]
[ name>> "." head? not ]
[ name>> valid-vocab-name? ]
} 1&& ;

: visible-dirs ( seq -- seq' )
[ visible-dir? ] filter [ name>> ] sort-by ;
Expand Down
10 changes: 8 additions & 2 deletions core/vocabs/vocabs.factor
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,17 @@ SYMBOLS: +parsing+ +done+ ;
swap >>name
H{ } clone >>words ;

<PRIVATE

: valid-vocab-name? ( name -- ? )
dup string? [ [ ":/\\ \"" member? ] none? ] [ f ] if ;

PRIVATE>

ERROR: bad-vocab-name name ;

: check-vocab-name ( name -- name )
dup string? [ bad-vocab-name ] unless
dup [ ":/\\ \"" member? ] any? [ bad-vocab-name ] when ;
dup valid-vocab-name? [ bad-vocab-name ] unless ;

TUPLE: vocab-link name ;

Expand Down

0 comments on commit 21cdff9

Please sign in to comment.