]> gitweb.factorcode.org Git - factor.git/commitdiff
Get continuation responder and parser combinators working with recent
authorChris Double <chris.double@double.co.nz>
Tue, 2 Nov 2004 00:02:33 +0000 (00:02 +0000)
committerChris Double <chris.double@double.co.nz>
Tue, 2 Nov 2004 00:02:33 +0000 (00:02 +0000)
factor changes. Todo example is currently broken.

contrib/cont-responder/cont-html.factor
contrib/cont-responder/cont-responder.factor
contrib/cont-responder/load.factor
contrib/cont-responder/todo.factor
contrib/parser-combinators/lazy.factor
contrib/parser-combinators/parser-combinators.factor

index 7fc39c98e1b534cc3dd3ee97b377c270d1b3ac5c..802a4f8c56a806aa46c8d2ca45cdd2a0e405284c 100644 (file)
@@ -77,7 +77,7 @@ USE: logic
 : attrs>string ( alist -- string )
   #! Convert the attrs alist to a string
   #! suitable for embedding in an html tag.
-  nreverse <% [ dup car % "='" % cdr % "'" % ] each %> ;
+  reverse <% [ dup car % "='" % cdr % "'" % ] each %> ;
 
 : write-attributes ( n: namespace -- )  
   #! With the attribute namespace on the stack, get the attributes
index 8531d5a84743f9ef657aa627023ce4de6c50b354..a95de9fe3e9555d0cc4c8dc2869623928591b1eb 100644 (file)
@@ -43,6 +43,7 @@ USE: cont-html
 USE: logging
 USE: url-encoding
 USE: unparser
+USE: hashtables
 
 : expiry-timeout ( -- timeout-seconds )
   #! Number of seconds to timeout continuations in
@@ -104,7 +105,7 @@ USE: unparser
   #! if they are 'timeout-seconds' old (ie. were added
   #! more than 'timeout-seconds' ago.
   continuation-items [ cdr dupd expired? not ] subset nip
-  alist>namespace "continuation-table" set ;
+  alist>hash "continuation-table" set ;
 
 : register-continuation ( expire? quot -- id ) 
   #! Store a continuation in the table and associate it with
@@ -257,7 +258,7 @@ USE: inspector
 : post-request>namespace ( post-request -- namespace )
   #! Return a namespace containing the name/value's from the 
   #! post data.
-  alist>namespace ;
+  alist>hash ;
 
 : cont-post-responder ( id -- )    
   #! httpd responder that retrieves a continuation for the given
index 7dd08e803b90a1186044f49ab9b3e541ec95a137..280e5973abd085727cb973b871c04913604cfc90 100644 (file)
@@ -42,12 +42,12 @@ USE: parser
   "cont-utils.factor" run-file ;
 : l2 
   "cont-examples.factor" run-file ;
-: l3 "todo.factor" run-file ;
-: l4 "todo-example.factor" run-file ;
+: l3 "todo.factor" run-file ;
+: l4 "todo-example.factor" run-file ;
 : l5 "live-updater.factor" run-file ;
-: l6 "eval-responder.factor" run-file ;
+: l6 "eval-responder.factor" run-file ;
 : l7 "live-updater-responder.factor" run-file ;
 : l8 "browser.factor" run-file ;
 : la ;
 : la [ 8888 httpd ] [ dup . flush [ la ] when* ] catch ;
-: lb [ la "httpd thread exited.\n" write flush ] in-thread  ;
+: lb [ la "httpd thread exited.\n" write flush ] in-thread  ;
index 9ed62048eb9e91029447e752d36e0a24d1f30907..cec7f9f54d70b103c76eff685a2c73058e170c7b 100644 (file)
@@ -60,7 +60,7 @@ USE: files
 : add-todo-item ( <todo> <item> -- )
   #! Add the item to the todo list
   swap [
-    "items" add@
+    "items" get swap unit append "items" set
   ] bind ;
 
 : namespace>alist ( namespace -- alist )
index 21199a8952a8a7b6149021e0e7115c7f02c08827..0717f5b895bad6defb90dd24c637e00e4d7c3824 100644 (file)
@@ -75,7 +75,7 @@ USE: logic
 
 : (ltake) ( n llist accum -- list )
   >r >r pred dup 0 < [ 
-    drop r> drop r> nreverse  
+    drop r> drop r> reverse  
   ] [ 
     r> luncons swap r> cons (ltake) 
   ] ifte ;
@@ -91,10 +91,10 @@ USE: logic
   over [ ] = [
     2drop [ ]
   ] [
-    [ luncons ] dip     
+    >r luncons r>     
     dup swapd           
     [ lmap ] curry2  
-    [ call ] dip
+    >r call r>
     lcons 
   ] ifte ;
 
@@ -104,7 +104,7 @@ USE: logic
   over [ ] = [
     2drop [ ] 
   ] [
-    [ luncons ] dip
+    >r luncons r>
     dup swapd
     [ lsubset ] curry2
     -rot dupd call [ 
index b21fea00e79fcd138dd01244a5f49262fc2a3622..edb9c8b015fc0c431a1ee9ac51900708dceb460a 100644 (file)
@@ -82,7 +82,7 @@ USE: parser
 
 : (list-take) ( n list accum -- list )
   >r >r pred dup 0 < [ 
-    drop r> drop r> nreverse 
+    drop r> drop r> reverse 
   ] [ 
     r> uncons swap r> cons (list-take) 
   ] ifte ;
@@ -131,7 +131,7 @@ USE: parser
 : ifte-head= ( string-or-list ch [ quot1 ] [ quot2 ] -- )
   #! When the character 'ch' is equal to the head
   #! of the string or list, run the quot1 otherwise run quot2.
-  [ swap phead = ] 2dip ifte ;
+  r> r> swap phead = r> r> ifte ;
 
 : symbol ( ch -- parser )
   #! Return a parser that parses the given symbol.
@@ -246,7 +246,7 @@ USE: unparser
   #! Return a parser that first skips all whitespace before
   #! parsing.
   [ ( inp parser -- result )
-    [ parse-skipwhite ] dip call
+    >r parse-skipwhite r> call
   ] curry1 ;
 
 : just ( parser -- parser )
@@ -264,7 +264,7 @@ USE: unparser
   #! to the resulting parse tree.
   [ ( inp p f -- result )
     >r call r> [ ( [ x | xs ] f -- [ fx | xs ] )
-      swap uncons [ swap over [ call ] [ drop ] ifte ] dip cons
+      swap uncons r> swap over [ call ] [ drop ] ifte r> cons
     ] curry1 lmap
   ] curry2 ;
 
@@ -359,7 +359,7 @@ USE: unparser
   #! Call quot with start and the first value in the list.
   #! quot is then called with the result of quot and the 
   #! next item in the list until the list is exhausted.
-  uncons >r swap dup dip r> dup [
+  uncons >r swap dup swap r> call r> r> dup [
     (reduce)
   ] [
     2drop