Clean up io.unix.launcher command parser
parent
82e98dac8b
commit
026c4186f1
|
@ -16,4 +16,18 @@ USING: io.unix.launcher tools.test ;
|
|||
[ { "abc def" "hey" } ] [ "'abc def' \"hey\"" tokenize-command ] unit-test
|
||||
[ "'abc def' \"hey" tokenize-command ] unit-test-fails
|
||||
[ "'abc def" tokenize-command ] unit-test-fails
|
||||
[ { "abc def" "h\"ey" } ] [ "'abc def' \"h\"ey\" " tokenize-command ] unit-test
|
||||
[ { "abc def" "h\"ey" } ] [ "'abc def' \"h\\\"ey\" " tokenize-command ] unit-test
|
||||
|
||||
[
|
||||
{
|
||||
"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
|
||||
|
|
|
@ -16,19 +16,18 @@ USE: unix
|
|||
! "foo bar" -- quotation
|
||||
LAZY: 'escaped-char' "\\" token any-char-parser &> ;
|
||||
|
||||
LAZY: 'chars' 'escaped-char' any-char-parser <|> <*> ;
|
||||
LAZY: 'quoted-char' ( delimiter -- parser' )
|
||||
'escaped-char'
|
||||
swap [ member? not ] curry satisfy
|
||||
<|> ; inline
|
||||
|
||||
LAZY: 'quoted-1' 'chars' "\"" "\"" surrounded-by ;
|
||||
LAZY: 'quoted' ( delimiter -- parser )
|
||||
dup 'quoted-char' <*> swap dup surrounded-by ;
|
||||
|
||||
LAZY: 'quoted-2' 'chars' "'" "'" surrounded-by ;
|
||||
LAZY: 'unquoted' ( -- parser ) " " 'quoted-char' <+> ;
|
||||
|
||||
LAZY: 'non-space-char'
|
||||
'escaped-char' [ CHAR: \s = not ] satisfy <|> ;
|
||||
|
||||
LAZY: 'unquoted' 'non-space-char' <+> ;
|
||||
|
||||
LAZY: 'argument'
|
||||
'quoted-1' 'quoted-2' 'unquoted' <|> <|>
|
||||
LAZY: 'argument' ( -- parser )
|
||||
"\"" 'quoted' "'" 'quoted' 'unquoted' <|> <|>
|
||||
[ >string ] <@ ;
|
||||
|
||||
MEMO: 'arguments' ( -- parser )
|
||||
|
|
Loading…
Reference in New Issue