From 4ecd7fff4237df32f2409f7ee16db16d32cd57f6 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Sat, 14 Apr 2007 04:27:15 -0500 Subject: [PATCH 01/10] split up some unix constants split up netbsd stat --- extra/unix/bsd/bsd.factor | 11 +++++++--- extra/unix/bsd/freebsd/freebsd.factor | 3 +++ extra/unix/bsd/macosx/macosx.factor | 3 +++ extra/unix/bsd/netbsd/netbsd.factor | 3 +++ extra/unix/bsd/openbsd/openbsd.factor | 3 +++ extra/unix/stat/netbsd/32/32.factor | 26 ++++++++++++++++++++++++ extra/unix/stat/netbsd/64/64.factor | 27 +++++++++++++++++++++++++ extra/unix/stat/netbsd/netbsd.factor | 29 +++++---------------------- extra/unix/types/netbsd/netbsd.factor | 5 ++--- extra/unix/unix.factor | 1 - 10 files changed, 80 insertions(+), 31 deletions(-) create mode 100644 extra/unix/bsd/freebsd/freebsd.factor create mode 100644 extra/unix/bsd/macosx/macosx.factor create mode 100644 extra/unix/bsd/netbsd/netbsd.factor create mode 100644 extra/unix/bsd/openbsd/openbsd.factor create mode 100644 extra/unix/stat/netbsd/32/32.factor create mode 100644 extra/unix/stat/netbsd/64/64.factor diff --git a/extra/unix/bsd/bsd.factor b/extra/unix/bsd/bsd.factor index e652f1b9f9..cb7b347c20 100755 --- a/extra/unix/bsd/bsd.factor +++ b/extra/unix/bsd/bsd.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2005, 2006 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. +USING: alien.syntax combinators system vocabs.loader ; IN: unix -USING: alien.syntax ; ! FreeBSD @@ -15,8 +15,6 @@ USING: alien.syntax ; : O_TRUNC HEX: 0400 ; inline : O_EXCL HEX: 0800 ; inline -: FD_SETSIZE 1024 ; inline - : SOL_SOCKET HEX: ffff ; inline : SO_REUSEADDR HEX: 4 ; inline : SO_OOBINLINE HEX: 100 ; inline @@ -83,3 +81,10 @@ C-STRUCT: sockaddr-un : SEEK_SET 0 ; inline : SEEK_CUR 1 ; inline : SEEK_END 2 ; inline + +os { + { "macosx" [ "unix.bsd.macosx" require ] } + { "freebsd" [ "unix.bsd.freebsd" require ] } + { "openbsd" [ "unix.bsd.openbsd" require ] } + { "netbsd" [ "unix.bsd.netbsd" require ] } +} case diff --git a/extra/unix/bsd/freebsd/freebsd.factor b/extra/unix/bsd/freebsd/freebsd.factor new file mode 100644 index 0000000000..94bb708527 --- /dev/null +++ b/extra/unix/bsd/freebsd/freebsd.factor @@ -0,0 +1,3 @@ +IN: unix + +: FD_SETSIZE 1024 ; diff --git a/extra/unix/bsd/macosx/macosx.factor b/extra/unix/bsd/macosx/macosx.factor new file mode 100644 index 0000000000..3c0617ad17 --- /dev/null +++ b/extra/unix/bsd/macosx/macosx.factor @@ -0,0 +1,3 @@ +IN: unix + +: FD_SETSIZE 1024 ; inline diff --git a/extra/unix/bsd/netbsd/netbsd.factor b/extra/unix/bsd/netbsd/netbsd.factor new file mode 100644 index 0000000000..ac18749830 --- /dev/null +++ b/extra/unix/bsd/netbsd/netbsd.factor @@ -0,0 +1,3 @@ +IN: unix + +: FD_SETSIZE 256 ; inline diff --git a/extra/unix/bsd/openbsd/openbsd.factor b/extra/unix/bsd/openbsd/openbsd.factor new file mode 100644 index 0000000000..3c0617ad17 --- /dev/null +++ b/extra/unix/bsd/openbsd/openbsd.factor @@ -0,0 +1,3 @@ +IN: unix + +: FD_SETSIZE 1024 ; inline diff --git a/extra/unix/stat/netbsd/32/32.factor b/extra/unix/stat/netbsd/32/32.factor new file mode 100644 index 0000000000..bb2df6d6d3 --- /dev/null +++ b/extra/unix/stat/netbsd/32/32.factor @@ -0,0 +1,26 @@ +USING: kernel alien.syntax math ; +IN: unix.stat + +! NetBSD 4.0 + +C-STRUCT: stat + { "dev_t" "st_dev" } + { "mode_t" "st_mode" } + { "ino_t" "st_ino" } + { "nlink_t" "st_nlink" } + { "uid_t" "st_uid" } + { "gid_t" "st_gid" } + { "dev_t" "st_rdev" } + { "timespec" "st_atim" } + { "timespec" "st_mtim" } + { "timespec" "st_ctim" } + { "timespec" "st_birthtim" } + { "off_t" "st_size" } + { "blkcnt_t" "st_blocks" } + { "blksize_t" "st_blksize" } + { "uint32_t" "st_flags" } + { "uint32_t" "st_gen" } + { { "uint32_t" 2 } "st_qspare" } ; + +FUNCTION: int stat ( char* pathname, stat* buf ) ; +FUNCTION: int lstat ( char* pathname, stat* buf ) ; diff --git a/extra/unix/stat/netbsd/64/64.factor b/extra/unix/stat/netbsd/64/64.factor new file mode 100644 index 0000000000..f1f6f93dbd --- /dev/null +++ b/extra/unix/stat/netbsd/64/64.factor @@ -0,0 +1,27 @@ +USING: kernel alien.syntax math ; +IN: unix.stat + +! NetBSD 4.0 + +C-STRUCT: stat + { "dev_t" "st_dev" } + { "ino_t" "st_ino" } + { "mode_t" "st_mode" } + { "nlink_t" "st_nlink" } + { "uid_t" "st_uid" } + { "gid_t" "st_gid" } + { "dev_t" "st_rdev" } + { "timespec" "st_atim" } + { "timespec" "st_mtim" } + { "timespec" "st_ctim" } + { "off_t" "st_size" } + { "blkcnt_t" "st_blocks" } + { "blksize_t" "st_blksize" } + { "uint32_t" "st_flags" } + { "uint32_t" "st_gen" } + { "uint32_t" "st_spare0" } + { "timespec" "st_birthtim" } + { "int" "__pad5" } ; + +FUNCTION: int stat ( char* pathname, stat* buf ) ; +FUNCTION: int lstat ( char* pathname, stat* buf ) ; diff --git a/extra/unix/stat/netbsd/netbsd.factor b/extra/unix/stat/netbsd/netbsd.factor index bb2df6d6d3..8057e5939b 100644 --- a/extra/unix/stat/netbsd/netbsd.factor +++ b/extra/unix/stat/netbsd/netbsd.factor @@ -1,26 +1,7 @@ -USING: kernel alien.syntax math ; +USING: layouts combinators vocabs.loader ; IN: unix.stat -! NetBSD 4.0 - -C-STRUCT: stat - { "dev_t" "st_dev" } - { "mode_t" "st_mode" } - { "ino_t" "st_ino" } - { "nlink_t" "st_nlink" } - { "uid_t" "st_uid" } - { "gid_t" "st_gid" } - { "dev_t" "st_rdev" } - { "timespec" "st_atim" } - { "timespec" "st_mtim" } - { "timespec" "st_ctim" } - { "timespec" "st_birthtim" } - { "off_t" "st_size" } - { "blkcnt_t" "st_blocks" } - { "blksize_t" "st_blksize" } - { "uint32_t" "st_flags" } - { "uint32_t" "st_gen" } - { { "uint32_t" 2 } "st_qspare" } ; - -FUNCTION: int stat ( char* pathname, stat* buf ) ; -FUNCTION: int lstat ( char* pathname, stat* buf ) ; +cell-bits { + { 32 [ "unix.stat.netbsd.32" require ] } + { 64 [ "unix.stat.netbsd.64" require ] } +} case diff --git a/extra/unix/types/netbsd/netbsd.factor b/extra/unix/types/netbsd/netbsd.factor index 77636a6d6d..6d33547627 100755 --- a/extra/unix/types/netbsd/netbsd.factor +++ b/extra/unix/types/netbsd/netbsd.factor @@ -18,7 +18,7 @@ TYPEDEF: ulonglong u_int64_t TYPEDEF: __uint32_t __dev_t TYPEDEF: __uint32_t dev_t -TYPEDEF: __uint64_t ino_t +TYPEDEF: __uint32_t ino_t TYPEDEF: __uint32_t mode_t TYPEDEF: __uint32_t nlink_t TYPEDEF: __uint32_t uid_t @@ -26,7 +26,6 @@ TYPEDEF: __uint32_t gid_t TYPEDEF: __int64_t off_t TYPEDEF: __int64_t blkcnt_t TYPEDEF: __uint32_t blksize_t -TYPEDEF: __uint32_t fflags_t -TYPEDEF: int ssize_t +TYPEDEF: longlong ssize_t TYPEDEF: int pid_t TYPEDEF: int time_t diff --git a/extra/unix/unix.factor b/extra/unix/unix.factor index 09d77fee11..d02e180cff 100755 --- a/extra/unix/unix.factor +++ b/extra/unix/unix.factor @@ -149,6 +149,5 @@ FUNCTION: ssize_t write ( int fd, void* buf, size_t nbytes ) ; { [ linux? ] [ "unix.linux" require ] } { [ bsd? ] [ "unix.bsd" require ] } { [ solaris? ] [ "unix.solaris" require ] } - { [ t ] [ ] } } cond From b993a1c588c5bf091e353d84bd3295081f3e05f2 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Sat, 14 Apr 2007 04:27:28 -0500 Subject: [PATCH 02/10] more constants --- build-support/grovel.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/build-support/grovel.c b/build-support/grovel.c index 8422ec197c..1260b29c80 100644 --- a/build-support/grovel.c +++ b/build-support/grovel.c @@ -141,10 +141,12 @@ void unix_constants() constant(EINTR); constant(EAGAIN); constant(EINPROGRESS); - constant(PROT_READ); + constant(PROT_READ); constant(PROT_WRITE); constant(MAP_FILE); constant(MAP_SHARED); + grovel(pid_t); + } int main() { @@ -158,6 +160,10 @@ int main() { openbsd_stat(); openbsd_types(); #endif + grovel(blkcnt_t); + grovel(blksize_t); + //grovel(fflags_t); + grovel(ssize_t); #ifdef UNIX unix_types(); From bc5f82255fbdeeb11f3b3cfef555856ec2dcb8cf Mon Sep 17 00:00:00 2001 From: Chris Double Date: Thu, 27 Mar 2008 17:24:05 +1300 Subject: [PATCH 03/10] peg refactorings --- extra/peg/peg.factor | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/extra/peg/peg.factor b/extra/peg/peg.factor index 10c9ce907d..0ae2aba2ee 100755 --- a/extra/peg/peg.factor +++ b/extra/peg/peg.factor @@ -24,8 +24,13 @@ SYMBOL: packrat GENERIC: (compile) ( parser -- quot ) +: input-from ( input -- n ) + #! Return the index from the original string that the + #! input slice is based on. + dup slice? [ slice-from ] [ drop 0 ] if ; + :: run-packrat-parser ( input quot c -- result ) - input slice? [ input slice-from ] [ 0 ] if + input input-from quot c [ drop H{ } clone ] cache [ drop input quot call From 4c50daed2213b9442954aec3a38abb51586fd05c Mon Sep 17 00:00:00 2001 From: Chris Double Date: Thu, 27 Mar 2008 17:45:59 +1300 Subject: [PATCH 04/10] Testcase for packrat behaviour --- extra/peg/peg-tests.factor | 20 ++++++++++++++++++++ extra/peg/peg.factor | 18 ++++++++++++++---- 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/extra/peg/peg-tests.factor b/extra/peg/peg-tests.factor index 89cc243863..bd4699f097 100644 --- a/extra/peg/peg-tests.factor +++ b/extra/peg/peg-tests.factor @@ -158,3 +158,23 @@ IN: peg.tests "a]" "[" token hide "a" token "]" token hide 3array seq parse ] unit-test + +{ V{ "1" "-" "1" } V{ "1" "+" "1" } } [ + [ + [ "1" token , "-" token , "1" token , ] seq* , + [ "1" token , "+" token , "1" token , ] seq* , + ] choice* + "1-1" over parse parse-result-ast swap + "1+1" swap parse parse-result-ast +] unit-test + +{ V{ "1" "-" "1" } V{ "1" "+" "1" } } [ + [ + [ + [ "1" token , "-" token , "1" token , ] seq* , + [ "1" token , "+" token , "1" token , ] seq* , + ] choice* + "1-1" over parse parse-result-ast swap + "1+1" swap parse parse-result-ast + ] with-packrat +] unit-test \ No newline at end of file diff --git a/extra/peg/peg.factor b/extra/peg/peg.factor index 0ae2aba2ee..bbd55ec6fa 100755 --- a/extra/peg/peg.factor +++ b/extra/peg/peg.factor @@ -29,12 +29,22 @@ GENERIC: (compile) ( parser -- quot ) #! input slice is based on. dup slice? [ slice-from ] [ drop 0 ] if ; +: input-cache ( quot cache -- cache ) + #! From the packrat cache, obtain the cache for the parser quotation + #! that maps the input string position to the parser result. + [ drop H{ } clone ] cache ; + +: cached-result ( n input-cache input quot -- result ) + #! Get the cached result for input position n + #! from the input cache. If the item is not in the cache, + #! call 'quot' with 'input' on the stack to get the result + #! and store that in the cache and return it. + [ nip ] swap compose curry cache ; inline + :: run-packrat-parser ( input quot c -- result ) input input-from - quot c [ drop H{ } clone ] cache - [ - drop input quot call - ] cache ; inline + quot c input-cache + input quot cached-result ; inline : run-parser ( input quot -- result ) #! If a packrat cache is available, use memoization for From 4e29081e93aadb902ebbcc27d9c2049d73434adb Mon Sep 17 00:00:00 2001 From: Chris Double Date: Thu, 27 Mar 2008 18:07:30 +1300 Subject: [PATCH 05/10] Make left recursion in pegs a failed parse Eventually left recursion will work fine, but this is prevents an infinite loop for now. --- extra/peg/peg-tests.factor | 4 +++- extra/peg/peg.factor | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/extra/peg/peg-tests.factor b/extra/peg/peg-tests.factor index bd4699f097..bd8abb63e6 100644 --- a/extra/peg/peg-tests.factor +++ b/extra/peg/peg-tests.factor @@ -175,6 +175,8 @@ IN: peg.tests [ "1" token , "+" token , "1" token , ] seq* , ] choice* "1-1" over parse parse-result-ast swap - "1+1" swap parse parse-result-ast ] with-packrat + [ + "1+1" swap parse parse-result-ast + ] with-packrat ] unit-test \ No newline at end of file diff --git a/extra/peg/peg.factor b/extra/peg/peg.factor index bbd55ec6fa..1361f9fdbd 100755 --- a/extra/peg/peg.factor +++ b/extra/peg/peg.factor @@ -34,12 +34,12 @@ GENERIC: (compile) ( parser -- quot ) #! that maps the input string position to the parser result. [ drop H{ } clone ] cache ; -: cached-result ( n input-cache input quot -- result ) +:: cached-result ( n input-cache input quot -- result ) #! Get the cached result for input position n #! from the input cache. If the item is not in the cache, #! call 'quot' with 'input' on the stack to get the result #! and store that in the cache and return it. - [ nip ] swap compose curry cache ; inline + n input-cache [ drop input quot call ] cache ; inline :: run-packrat-parser ( input quot c -- result ) input input-from From f6b7f8197e5e1bf033157bdcd389aa216383a29e Mon Sep 17 00:00:00 2001 From: Chris Double Date: Thu, 27 Mar 2008 23:54:34 +1300 Subject: [PATCH 06/10] Add tests for left recusion in pegs --- extra/peg/ebnf/ebnf-tests.factor | 30 +++++++++++++++++++++++++++++- extra/peg/ebnf/ebnf.factor | 4 ++-- extra/peg/peg-tests.factor | 18 +++++++++++++++++- extra/peg/peg.factor | 6 +++++- 4 files changed, 53 insertions(+), 5 deletions(-) diff --git a/extra/peg/ebnf/ebnf-tests.factor b/extra/peg/ebnf/ebnf-tests.factor index c9b9f5d977..dea549eb37 100644 --- a/extra/peg/ebnf/ebnf-tests.factor +++ b/extra/peg/ebnf/ebnf-tests.factor @@ -142,4 +142,32 @@ IN: peg.ebnf.tests { f } [ "Z" [EBNF foo=[^A-Z] EBNF] call -] unit-test \ No newline at end of file +] unit-test + +[ + #! Test direct left recursion. Currently left recursion should cause a + #! failure of that parser. + #! Not using packrat, so recursion causes data stack overflow + "1+1" [EBNF num=([0-9])+ expr=expr "+" num | num EBNF] call +] must-fail + +{ V{ 49 } } [ + #! Test direct left recursion. Currently left recursion should cause a + #! failure of that parser. + #! Using packrat, so first part of expr fails, causing 2nd choice to be used + "1+1" [ [EBNF num=([0-9])+ expr=expr "+" num | num EBNF] call ] with-packrat parse-result-ast +] unit-test + +[ + #! Test indirect left recursion. Currently left recursion should cause a + #! failure of that parser. + #! Not using packrat, so recursion causes data stack overflow + "1+1" [EBNF num=([0-9])+ x=expr expr=x "+" num | num EBNF] call +] must-fail + +{ V{ 49 } } [ + #! Test indirect left recursion. Currently left recursion should cause a + #! failure of that parser. + #! Using packrat, so first part of expr fails, causing 2nd choice to be used + "1+1" [ [EBNF num=([0-9])+ x=expr expr=x "+" num | num EBNF] call ] with-packrat parse-result-ast +] unit-test diff --git a/extra/peg/ebnf/ebnf.factor b/extra/peg/ebnf/ebnf.factor index 11e1e2ea64..be4beab3f1 100644 --- a/extra/peg/ebnf/ebnf.factor +++ b/extra/peg/ebnf/ebnf.factor @@ -266,7 +266,7 @@ M: ebnf-non-terminal (transform) ( ast -- parser ) ] [ ] make delay sp ; : transform-ebnf ( string -- object ) - 'ebnf' parse parse-result-ast transform ; + 'ebnf' [ parse ] packrat-parse parse-result-ast transform ; : check-parse-result ( result -- result ) dup [ @@ -281,7 +281,7 @@ M: ebnf-non-terminal (transform) ( ast -- parser ) ] if ; : ebnf>quot ( string -- hashtable quot ) - 'ebnf' parse check-parse-result + 'ebnf' [ parse ] with-packrat check-parse-result parse-result-ast transform dup main swap at compile 1quotation ; : [EBNF "EBNF]" parse-multiline-string ebnf>quot nip parsed ; parsing diff --git a/extra/peg/peg-tests.factor b/extra/peg/peg-tests.factor index bd8abb63e6..cd95bd3b93 100644 --- a/extra/peg/peg-tests.factor +++ b/extra/peg/peg-tests.factor @@ -179,4 +179,20 @@ IN: peg.tests [ "1+1" swap parse parse-result-ast ] with-packrat -] unit-test \ No newline at end of file +] unit-test + +: expr ( -- parser ) + #! Test direct left recursion. Currently left recursion should cause a + #! failure of that parser. + [ expr ] delay "+" token "1" token 3seq "1" token 2choice ; + +[ + #! Not using packrat, so recursion causes data stack overflow + "1+1" expr parse parse-result-ast +] must-fail + +{ "1" } [ + #! Using packrat, so expr fails, causing the 2nd choice to be used. + "1+1" expr [ parse ] with-packrat parse-result-ast +] unit-test + diff --git a/extra/peg/peg.factor b/extra/peg/peg.factor index 1361f9fdbd..e5632d645c 100755 --- a/extra/peg/peg.factor +++ b/extra/peg/peg.factor @@ -39,7 +39,11 @@ GENERIC: (compile) ( parser -- quot ) #! from the input cache. If the item is not in the cache, #! call 'quot' with 'input' on the stack to get the result #! and store that in the cache and return it. - n input-cache [ drop input quot call ] cache ; inline + n input-cache [ + drop + f n input-cache set-at + input quot call + ] cache ; inline :: run-packrat-parser ( input quot c -- result ) input input-from From fa8b311b277582adbcdf5fe9e6aca747b1cd5322 Mon Sep 17 00:00:00 2001 From: Chris Double Date: Fri, 28 Mar 2008 00:04:08 +1300 Subject: [PATCH 07/10] Add packrat-parse, etc --- extra/peg/ebnf/ebnf.factor | 4 ++-- extra/peg/peg-docs.factor | 30 ++++++++++++++++++++++++++---- extra/peg/peg.factor | 10 ++++++++-- 3 files changed, 36 insertions(+), 8 deletions(-) diff --git a/extra/peg/ebnf/ebnf.factor b/extra/peg/ebnf/ebnf.factor index be4beab3f1..ed0dea0410 100644 --- a/extra/peg/ebnf/ebnf.factor +++ b/extra/peg/ebnf/ebnf.factor @@ -266,7 +266,7 @@ M: ebnf-non-terminal (transform) ( ast -- parser ) ] [ ] make delay sp ; : transform-ebnf ( string -- object ) - 'ebnf' [ parse ] packrat-parse parse-result-ast transform ; + 'ebnf' packrat-parse parse-result-ast transform ; : check-parse-result ( result -- result ) dup [ @@ -281,7 +281,7 @@ M: ebnf-non-terminal (transform) ( ast -- parser ) ] if ; : ebnf>quot ( string -- hashtable quot ) - 'ebnf' [ parse ] with-packrat check-parse-result + 'ebnf' packrat-parse check-parse-result parse-result-ast transform dup main swap at compile 1quotation ; : [EBNF "EBNF]" parse-multiline-string ebnf>quot nip parsed ; parsing diff --git a/extra/peg/peg-docs.factor b/extra/peg/peg-docs.factor index 30e7f0e72f..c93d1af830 100644 --- a/extra/peg/peg-docs.factor +++ b/extra/peg/peg-docs.factor @@ -12,7 +12,7 @@ HELP: parse { $description "Given the input string, parse it using the given parser. The result is a object if " "the parse was successful, otherwise it is f." } -{ $see-also compile with-packrat } ; +{ $see-also compile with-packrat packrat-parse } ; HELP: with-packrat { $values @@ -23,8 +23,30 @@ HELP: with-packrat "Calls the quotation with a packrat cache in scope. Usually the quotation will " "call " { $link parse } " or call a word produced by " { $link compile } "." "The cache is used to avoid the possible exponential time performace that pegs " - "can have, instead giving linear time at the cost of increased memory usage." } -{ $see-also compile parse } ; + "can have, instead giving linear time at the cost of increased memory usage. " + "Use of this packrat option also allows direct and indirect recursion to " + "be handled in the parser without entering an infinite loop." } +{ $see-also compile parse packrat-parse packrat-call } ; + +HELP: packrat-parse +{ $values + { "input" "a string" } + { "parser" "a parser" } + { "result" "a parse-result or f" } +} +{ $description + "Compiles and calls the parser with a packrat cache in scope." } +{ $see-also compile parse packrat-call with-packrat } ; + +HELP: packrat-call +{ $values + { "input" "a string" } + { "quot" "a quotation with stack effect ( input -- result )" } + { "result" "a parse-result or f" } +} +{ $description + "Calls the compiled parser with a packrat cache in scope." } +{ $see-also compile packrat-call packrat-parse with-packrat } ; HELP: compile { $values @@ -36,7 +58,7 @@ HELP: compile "The mapping from parser to compiled word is kept in a cache. If you later change " "the definition of a parser you'll need to clear this cache with " { $link reset-compiled-parsers } " before using " { $link compile } " on that parser again." } -{ $see-also compile with-packrat reset-compiled-parsers } ; +{ $see-also compile with-packrat reset-compiled-parsers packrat-call packrat-parse } ; HELP: reset-compiled-parsers { $description diff --git a/extra/peg/peg.factor b/extra/peg/peg.factor index e5632d645c..246dbc7962 100755 --- a/extra/peg/peg.factor +++ b/extra/peg/peg.factor @@ -67,11 +67,17 @@ GENERIC: (compile) ( parser -- quot ) [ compiled-parser ] with-compilation-unit ; : parse ( state parser -- result ) - compile execute ; + compile execute ; inline : with-packrat ( quot -- result ) #! Run the quotation with a packrat cache active. - [ H{ } clone packrat ] dip with-variable ; + [ H{ } clone packrat ] dip with-variable ; inline + +: packrat-parse ( state parser -- result ) + [ parse ] with-packrat ; + +: packrat-call ( state quot -- result ) + with-packrat ; inline Date: Thu, 27 Mar 2008 11:18:32 -0500 Subject: [PATCH 08/10] Fix NetBSD FFI --- core/cpu/x86/architecture/architecture.factor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/cpu/x86/architecture/architecture.factor b/core/cpu/x86/architecture/architecture.factor index 49b05ea48f..f993639c05 100755 --- a/core/cpu/x86/architecture/architecture.factor +++ b/core/cpu/x86/architecture/architecture.factor @@ -156,7 +156,7 @@ M: x86-backend %unbox-small-struct ( size -- ) M: x86-backend struct-small-enough? ( size -- ? ) { 1 2 4 8 } member? - os { "linux" "solaris" } member? not and ; + os { "linux" "netbsd" "solaris" } member? not and ; M: x86-backend %return ( -- ) 0 %unwind ; From aad587d6647607042bbbed72e59cbbb67d801c46 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Thu, 27 Mar 2008 11:48:51 -0500 Subject: [PATCH 09/10] Fix deploy test --- extra/tools/deploy/deploy-tests.factor | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/extra/tools/deploy/deploy-tests.factor b/extra/tools/deploy/deploy-tests.factor index 8db34320de..5030763a3d 100755 --- a/extra/tools/deploy/deploy-tests.factor +++ b/extra/tools/deploy/deploy-tests.factor @@ -1,10 +1,11 @@ IN: tools.deploy.tests USING: tools.test system io.files kernel tools.deploy.config tools.deploy.backend math sequences io.launcher arrays -namespaces ; +namespaces continuations ; : shake-and-bake ( vocab -- ) - "." resource-path [ + [ "test.image" temp-file delete-file ] ignore-errors + "resource:" [ >r vm "test.image" temp-file r> dup deploy-config make-deploy-image From 89c76987388ad917247caed9f618c2253dfeb5da Mon Sep 17 00:00:00 2001 From: Chris Double Date: Fri, 28 Mar 2008 11:30:46 +1300 Subject: [PATCH 10/10] Fix MEMO problem with seq* and choice* --- extra/peg/peg.factor | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/extra/peg/peg.factor b/extra/peg/peg.factor index 246dbc7962..709052b7dd 100755 --- a/extra/peg/peg.factor +++ b/extra/peg/peg.factor @@ -338,7 +338,7 @@ MEMO: 3seq ( parser1 parser2 parser3 -- parser ) MEMO: 4seq ( parser1 parser2 parser3 parser4 -- parser ) 4array seq ; -MEMO: seq* ( quot -- paser ) +: seq* ( quot -- paser ) { } make seq ; inline MEMO: choice ( seq -- parser ) @@ -353,7 +353,7 @@ MEMO: 3choice ( parser1 parser2 parser3 -- parser ) MEMO: 4choice ( parser1 parser2 parser3 parser4 -- parser ) 4array choice ; -MEMO: choice* ( quot -- paser ) +: choice* ( quot -- paser ) { } make choice ; inline MEMO: repeat0 ( parser -- parser )