Rename io.launcher.unix.parser to simple-tokenizer since ftp.server uses it
parent
f78e5c7430
commit
eab105590b
|
@ -1,15 +1,14 @@
|
|||
! Copyright (C) 2008 Doug Coleman.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: accessors assocs byte-arrays calendar classes
|
||||
combinators combinators.short-circuit concurrency.promises
|
||||
continuations destructors ftp io io.backend io.directories
|
||||
io.encodings io.encodings.binary
|
||||
tools.files io.encodings.utf8 io.files io.files.info
|
||||
io.pathnames io.launcher.unix.parser io.servers.connection
|
||||
io.sockets io.streams.duplex io.streams.string io.timeouts
|
||||
kernel make math math.bitwise math.parser namespaces sequences
|
||||
splitting threads unicode.case logging calendar.format
|
||||
strings io.files.links io.files.types io.encodings.8-bit.latin1 ;
|
||||
USING: accessors assocs byte-arrays calendar classes combinators
|
||||
combinators.short-circuit concurrency.promises continuations
|
||||
destructors ftp io io.backend io.directories io.encodings
|
||||
io.encodings.binary tools.files io.encodings.utf8 io.files
|
||||
io.files.info io.pathnames io.servers.connection io.sockets
|
||||
io.streams.duplex io.streams.string io.timeouts kernel make math
|
||||
math.bitwise math.parser namespaces sequences splitting threads
|
||||
unicode.case logging calendar.format strings io.files.links
|
||||
io.files.types io.encodings.8-bit.latin1 simple-tokenizer ;
|
||||
IN: ftp.server
|
||||
|
||||
SYMBOL: server
|
||||
|
@ -24,7 +23,7 @@ TUPLE: ftp-command raw tokenized ;
|
|||
dup \ <ftp-command> DEBUG log-message
|
||||
ftp-command new
|
||||
over >>raw
|
||||
swap tokenize-command >>tokenized ;
|
||||
swap tokenize >>tokenized ;
|
||||
|
||||
TUPLE: ftp-get path ;
|
||||
: <ftp-get> ( path -- obj )
|
||||
|
|
|
@ -1,33 +0,0 @@
|
|||
IN: io.launcher.unix.parser.tests
|
||||
USING: io.launcher.unix.parser tools.test ;
|
||||
|
||||
[ "" tokenize-command ] must-fail
|
||||
[ " " tokenize-command ] must-fail
|
||||
[ V{ "a" } ] [ "a" tokenize-command ] unit-test
|
||||
[ V{ "abc" } ] [ "abc" tokenize-command ] unit-test
|
||||
[ V{ "abc" } ] [ "abc " tokenize-command ] unit-test
|
||||
[ V{ "abc" } ] [ " abc" tokenize-command ] unit-test
|
||||
[ V{ "abc" "def" } ] [ "abc def" tokenize-command ] unit-test
|
||||
[ V{ "abc def" } ] [ "abc\\ def" tokenize-command ] unit-test
|
||||
[ V{ "abc\\" "def" } ] [ "abc\\\\ def" tokenize-command ] unit-test
|
||||
[ V{ "abc\\ def" } ] [ "\"abc\\\\ def\"" tokenize-command ] unit-test
|
||||
[ V{ "abc\\ def" } ] [ " \"abc\\\\ def\"" tokenize-command ] unit-test
|
||||
[ V{ "abc\\ def" "hey" } ] [ "\"abc\\\\ def\" hey" tokenize-command ] unit-test
|
||||
[ V{ "abc def" "hey" } ] [ "\"abc def\" \"hey\"" tokenize-command ] unit-test
|
||||
[ "\"abc def\" \"hey" tokenize-command ] must-fail
|
||||
[ "\"abc def" tokenize-command ] must-fail
|
||||
[ V{ "abc def" "h\"ey" } ] [ "\"abc def\" \"h\\\"ey\" " tokenize-command ] unit-test
|
||||
|
||||
[
|
||||
V{
|
||||
"Hello world.app/Contents/MacOS/hello-ui"
|
||||
"-i=boot.macosx-ppc.image"
|
||||
"-include= math compiler ui"
|
||||
"-deploy-vocab=hello-ui"
|
||||
"-output-image=Hello world.app/Contents/Resources/hello-ui.image"
|
||||
"-no-stack-traces"
|
||||
"-no-user-init"
|
||||
}
|
||||
] [
|
||||
"\"Hello world.app/Contents/MacOS/hello-ui\" -i=boot.macosx-ppc.image \"-include= math compiler ui\" -deploy-vocab=hello-ui \"-output-image=Hello world.app/Contents/Resources/hello-ui.image\" -no-stack-traces -no-user-init" tokenize-command
|
||||
] unit-test
|
|
@ -1 +0,0 @@
|
|||
unix
|
|
@ -1,15 +1,14 @@
|
|||
! Copyright (C) 2007, 2008 Slava Pestov.
|
||||
! Copyright (C) 2007, 2010 Slava Pestov.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: accessors alien.c-types arrays assocs combinators
|
||||
continuations environment io io.backend io.backend.unix
|
||||
io.files io.files.private io.files.unix io.launcher
|
||||
io.launcher.unix.parser io.pathnames io.ports kernel math
|
||||
namespaces sequences strings system threads unix
|
||||
unix.process unix.ffi ;
|
||||
io.files io.files.private io.files.unix io.launcher io.pathnames
|
||||
io.ports kernel math namespaces sequences strings system threads
|
||||
unix unix.process unix.ffi simple-tokenizer ;
|
||||
IN: io.launcher.unix
|
||||
|
||||
: get-arguments ( process -- seq )
|
||||
command>> dup string? [ tokenize-command ] when ;
|
||||
command>> dup string? [ tokenize ] when ;
|
||||
|
||||
: assoc>env ( assoc -- env )
|
||||
[ "=" glue ] { } assoc>map ;
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
Slava Pestov
|
|
@ -0,0 +1,13 @@
|
|||
USING: help.markup help.syntax strings ;
|
||||
IN: simple-tokenizer
|
||||
|
||||
HELP: tokenize
|
||||
{ $values { "input" string } { "ast" "a sequence of strings" } }
|
||||
{ $description
|
||||
"Tokenize a string. Supported syntax:"
|
||||
{ $list
|
||||
{ { $snippet "foo bar baz" } " - simple tokens" }
|
||||
{ { $snippet "foo\\ bar" } " - token with an escaped space"}
|
||||
{ { $snippet "\"foo bar\"" } " - quoted token" }
|
||||
}
|
||||
} ;
|
|
@ -0,0 +1,33 @@
|
|||
IN: simple-tokenizer.tests
|
||||
USING: simple-tokenizer tools.test ;
|
||||
|
||||
[ "" tokenize ] must-fail
|
||||
[ " " tokenize ] must-fail
|
||||
[ V{ "a" } ] [ "a" tokenize ] unit-test
|
||||
[ V{ "abc" } ] [ "abc" tokenize ] unit-test
|
||||
[ V{ "abc" } ] [ "abc " tokenize ] unit-test
|
||||
[ V{ "abc" } ] [ " abc" tokenize ] unit-test
|
||||
[ V{ "abc" "def" } ] [ "abc def" tokenize ] unit-test
|
||||
[ V{ "abc def" } ] [ "abc\\ def" tokenize ] unit-test
|
||||
[ V{ "abc\\" "def" } ] [ "abc\\\\ def" tokenize ] unit-test
|
||||
[ V{ "abc\\ def" } ] [ "\"abc\\\\ def\"" tokenize ] unit-test
|
||||
[ V{ "abc\\ def" } ] [ " \"abc\\\\ def\"" tokenize ] unit-test
|
||||
[ V{ "abc\\ def" "hey" } ] [ "\"abc\\\\ def\" hey" tokenize ] unit-test
|
||||
[ V{ "abc def" "hey" } ] [ "\"abc def\" \"hey\"" tokenize ] unit-test
|
||||
[ "\"abc def\" \"hey" tokenize ] must-fail
|
||||
[ "\"abc def" tokenize ] must-fail
|
||||
[ V{ "abc def" "h\"ey" } ] [ "\"abc def\" \"h\\\"ey\" " tokenize ] unit-test
|
||||
|
||||
[
|
||||
V{
|
||||
"Hello world.app/Contents/MacOS/hello-ui"
|
||||
"-i=boot.macosx-ppc.image"
|
||||
"-include= math compiler ui"
|
||||
"-deploy-vocab=hello-ui"
|
||||
"-output-image=Hello world.app/Contents/Resources/hello-ui.image"
|
||||
"-no-stack-traces"
|
||||
"-no-user-init"
|
||||
}
|
||||
] [
|
||||
"\"Hello world.app/Contents/MacOS/hello-ui\" -i=boot.macosx-ppc.image \"-include= math compiler ui\" -deploy-vocab=hello-ui \"-output-image=Hello world.app/Contents/Resources/hello-ui.image\" -no-stack-traces -no-user-init" tokenize
|
||||
] unit-test
|
|
@ -1,13 +1,9 @@
|
|||
! Copyright (C) 2008 Slava Pestov
|
||||
! Copyright (C) 2008, 2010 Slava Pestov
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: peg peg.ebnf arrays sequences strings kernel ;
|
||||
IN: io.launcher.unix.parser
|
||||
IN: simple-tokenizer
|
||||
|
||||
! Our command line parser. Supported syntax:
|
||||
! foo bar baz -- simple tokens
|
||||
! foo\ bar -- escaping the space
|
||||
! "foo bar" -- quotation
|
||||
EBNF: tokenize-command
|
||||
EBNF: tokenize
|
||||
space = " "
|
||||
escaped-char = "\" .:ch => [[ ch ]]
|
||||
quoted = '"' (escaped-char | [^"])*:a '"' => [[ a ]]
|
|
@ -0,0 +1 @@
|
|||
text
|
Loading…
Reference in New Issue