I'm attemtping to rewrite a C# application in Rebol to see first hand the levels of productity achievable.
I was curious to know before I jump in head first whether:
The parse function can do everything that Regex can
It's possible to mimic an HTTP (actually, HTTPS) session using port!
(Any examples here would be nice as I can't seem to find any)
There are any dialects available for parsing flat files
(including CSV, TSV, fixed length files)
There are functions to generate a PDF from an HTML file
(or just populate an existing PDF form)
Thanks!
EDIT:
On question #2, allow me to rephrase, I actually want to be able to maintain cookies between HTTP requests (actually, a POST [posting credentials to a login page], followed by numerous GETs that resend the cookie received after POSTing).
I guess the equivalent using curl would be:
curl [url] -d [data] -c [file]
curl [url] -b [file]
I guess my problem is I just don't know yet how to fully use the HTTP scheme (reading http://www.rebol.net/docs/prot-http.html) I see a cookie after a successfull post when I do this:
p: open http://localhost/test.php
write p "name=foo"
probe p/state/info/headers
But then what next? How do I resend this cookie along with the next request.
Can the parse function do everything that RegEx can?
Rebol's PARSE is in the family of "Top-down parsing languages (TDPL)". It should be strictly more powerful than RegEx or LL parsers. For a breakdown of what's possible/impossible see my answer to the question "Can you create PARSE rules for CSS2/CSS3 in Rebol" (A: Yes)
Is it possible to mimic an HTTP (actually, HTTPS) session using port!
You can write full web servers in Rebol--as demonstrated by Cheyenne...and you can browse its source code online. If you want a far simpler example check out the Tiny Web Server Sample.
With respect to the specific issue of "session management" via cookies, it's not terribly well documented how to do this...and for better or worse I do not use Rebol 2. My perception is that this is one of the areas where you'll have to feel out changes between versions.
FWIW, this code was working for me in a little script I wrote in Rebol 3 that used cookies:
system/schemes/http/spec/headers: compose [ cookie: (session_cookie) referer: (to-string urlForEdit) content-type: {application/x-www-form-urlencoded} user-agent: {Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.1.3) Gecko/20090824 Firefox/3.5.3} cache-control: {no-cache} ] either true [ system/schemes/http/spec/method: 'post system/schemes/http/spec/content: payloadString htmlResponse: to-string read postUrl ] [ # this seems to be equivalent to the other branch... # if the target of your WRITE is of type URL! then it # automatically sets spec/method and http/spec/content htmlResponse: to-string write postUrl payloadString ]
Are there dialects available for parsing flat files?
I'm not aware of any published dialects other than PARSE, which is typically used to get things like CSV into Rebol formats. Then the program operates on the data as Rebol. One unfortunate thing is that PARSE doesn't run on PORT! so if your file is large you may have to implement your own buffering solution.
Are there functions to generate a PDF from an HTML file?
Generating a PDF from HTML or filling out forms sounds like kind of a turnkey thing that you might want to call to an externally maintained tool for. But there is a project out there by Gabriele Santilli which generates legal PDF files from a Rebol PDF dialect:
http://web.tiscalinet.it/rebol/pdf-maker.r
What's fun is the documentation for the library is a PDF file which was made using the library itself. If you want to see the dialected code used to create it, you can look at it side-by-side with the generated result!