Don't need MEMO: there anymore according to doublec

db4
Slava Pestov 2008-06-04 19:33:43 -05:00
parent 7cc553c4b6
commit ab5843d831
1 changed files with 7 additions and 8 deletions

View File

@ -1,7 +1,6 @@
! Copyright (C) 2008 Slava Pestov
! See http://factorcode.org/license.txt for BSD license.
USING: peg peg.parsers kernel sequences strings words
memoize ;
USING: peg peg.parsers kernel sequences strings words ;
IN: io.unix.launcher.parser
! Our command line parser. Supported syntax:
@ -9,20 +8,20 @@ IN: io.unix.launcher.parser
! foo\ bar -- escaping the space
! 'foo bar' -- quotation
! "foo bar" -- quotation
MEMO: 'escaped-char' ( -- parser )
"\\" token [ drop t ] satisfy 2seq [ second ] action ;
: 'escaped-char' ( -- parser )
"\\" token any-char 2seq [ second ] action ;
MEMO: 'quoted-char' ( delimiter -- parser' )
: 'quoted-char' ( delimiter -- parser' )
'escaped-char'
swap [ member? not ] curry satisfy
2choice ; inline
MEMO: 'quoted' ( delimiter -- parser )
: 'quoted' ( delimiter -- parser )
dup 'quoted-char' repeat0 swap dup surrounded-by ;
MEMO: 'unquoted' ( -- parser ) " '\"" 'quoted-char' repeat1 ;
: 'unquoted' ( -- parser ) " '\"" 'quoted-char' repeat1 ;
MEMO: 'argument' ( -- parser )
: 'argument' ( -- parser )
"\"" 'quoted'
"'" 'quoted'
'unquoted' 3choice