syntax: experimenting with pathnames.
parent
7075e5fede
commit
86684fcb95
|
@ -18,6 +18,8 @@ IN: bootstrap.syntax
|
|||
"[[" "[=[" "[==["
|
||||
"factor[[" "factor[=[" "factor[==["
|
||||
"factor\""
|
||||
"resource\"" "vocab\"" "home\""
|
||||
"resource`" "vocab`" "home`"
|
||||
"PRIVATE<"
|
||||
"B{"
|
||||
"BV{"
|
||||
|
|
|
@ -1,9 +1,32 @@
|
|||
! Copyright (C) 2004, 2009 Slava Pestov, Doug Coleman.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: accessors combinators io.backend kernel math math.order
|
||||
namespaces sequences splitting strings system ;
|
||||
USING: accessors arrays combinators io.backend kernel math
|
||||
math.order namespaces sequences sequences.private splitting
|
||||
strings system ;
|
||||
IN: io.pathnames
|
||||
|
||||
TUPLE: pathname string ;
|
||||
C: <pathname> pathname ;
|
||||
|
||||
M: pathname nth string>> nth ;
|
||||
M: pathname nth-unsafe string>> nth-unsafe ;
|
||||
M: pathname length string>> length ;
|
||||
M: pathname like drop dup pathname? [ <pathname> ] unless ;
|
||||
M: pathname string-lines normalize-path 1array ;
|
||||
|
||||
TUPLE: resource-path < pathname ;
|
||||
C: <resource-path> resource-path ;
|
||||
|
||||
TUPLE: vocab-path < pathname ;
|
||||
C: <vocab-path> vocab-path ;
|
||||
|
||||
TUPLE: home-path < pathname ;
|
||||
C: <home-path> home-path ;
|
||||
|
||||
M: resource-path like drop dup pathname? [ <resource-path> ] unless ;
|
||||
M: vocab-path like drop dup pathname? [ <vocab-path> ] unless ;
|
||||
M: home-path like drop dup pathname? [ <home-path> ] unless ;
|
||||
|
||||
SYMBOL: current-directory
|
||||
|
||||
: path-separator? ( ch -- ? ) os windows? "/\\" "/" ? member? ;
|
||||
|
@ -163,10 +186,6 @@ M: string absolute-path
|
|||
M: object normalize-path ( path -- path' )
|
||||
absolute-path ;
|
||||
|
||||
TUPLE: pathname string ;
|
||||
|
||||
C: <pathname> pathname ;
|
||||
|
||||
M: pathname absolute-path string>> absolute-path ;
|
||||
|
||||
M: pathname <=> [ string>> ] compare ;
|
||||
|
|
|
@ -124,6 +124,30 @@ IN: bootstrap.syntax
|
|||
"]==]" parse-multiline-string suffix!
|
||||
] define-core-syntax
|
||||
|
||||
"resource\"" [
|
||||
"\"" parse-multiline-string-new <resource-path> suffix!
|
||||
] define-core-syntax
|
||||
|
||||
"resource`" [
|
||||
lexer get parse-spaceless-payload <resource-path> suffix!
|
||||
] define-core-syntax
|
||||
|
||||
"vocab\"" [
|
||||
"\"" parse-multiline-string-new <vocab-path> suffix!
|
||||
] define-core-syntax
|
||||
|
||||
"vocab`" [
|
||||
lexer get parse-spaceless-payload <vocab-path> suffix!
|
||||
] define-core-syntax
|
||||
|
||||
"home\"" [
|
||||
"\"" parse-multiline-string-new <home-path> suffix!
|
||||
] define-core-syntax
|
||||
|
||||
"home`" [
|
||||
lexer get parse-spaceless-payload <home-path> suffix!
|
||||
] define-core-syntax
|
||||
|
||||
"PRIMITIVE:" [
|
||||
current-vocab name>>
|
||||
scan-word scan-effect ";" expect ensure-primitive
|
||||
|
|
Loading…
Reference in New Issue