Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.forth > #4505
| From | Julian Fondren <ayrnieu@gmail.com> |
|---|---|
| Newsgroups | comp.lang.forth |
| Subject | Re: Yay! CGI forth interpreter success |
| Date | 2011-07-30 16:03 -0500 |
| Organization | A noiseless patient Spider |
| Message-ID | <86mxfv4h1e.fsf@gmail.com> (permalink) |
| References | <f95d654e-f937-4f00-a96f-7fe52c3aa674@j15g2000yqf.googlegroups.com> <89389716-8d7a-4de0-a954-ea63584c5522@a12g2000vbf.googlegroups.com> <fdd95e41-c342-4653-a551-454f54828409@a4g2000yqg.googlegroups.com> |
Tarkin <tarkin000@gmail.com> writes:
> On Jul 25, 8:17 am, Mark Wills <forthfr...@forthfiles.net> wrote:
>> On Jul 25, 3:08 am, Tarkin <tarkin...@gmail.com> wrote:
>> > here is index.4th, a simple, bare-minimum cgi test:
>> > --------------------8<----------------------------------------------
>> > \ vim: set ft=forth: set ts=2:
>> > : NEWL 13 EMIT 10 EMIT ;
>> > ." HTTP/1.1 200 OK" NEWL
>> > ." Content-Type: text/html; charset=UTF-8" NEWL
>> > ." Connection: close" NEWL
>> > ." X-Powered-By: flow-0.9" NEWL
>> > NEWL
>> > NEWL
>> > ." <html>" CR
>> > ." <head>" CR
>> > ." <title>FORTH CGI</title>" CR
>> > ." </head>" CR
>> > ." <body>" CR
>> > ." <h3>It works!</h3>" CR
>> > ." <p><strong>Hello, Browser!!!</strong><br />" CR
>> > ." Forth CGI interpreter based on jonesforth, written by
>> > Tarkin!!!.</p>" CR
>> > ." </body>" CR
>> > ." <html>" CR
>>
>> Very very nice!
>>
>> Given most browsers 'forgiveness' with white space, you could define
>> some HTML (at least the earlier ones, from 1.0/1.1) tags as Forth
>> words:
>>
>> : <p> ." <p>" ;
>> : </p> ." </p>" ;
>>
>
> Yes, that came next in testing! I also wrapped the headers like so:
> --------------------------8<------------------------------------------
> : .H1 ." HTTP/1.1 200 OK" NEWL;
> : .H2 ." Content-Type: text/html; charset=utf-8" NEWL ;
> : .H3 ." Connection: close" NEWL ;
> : .H4 ." X-Powered-By: flow-0.9" NEWL ;
> : .HTTP .H1 .H2 .H3 .H4 NEWL NEWL ;
> \ tags already defined....
> <html>
> <head>
> <title>flow CGI</title>
> </head>
> <body>
> <p><h3>It works!</h3>This is <strong>'Hello, browser!'</strong>
> for forth CGI!</p>
> </body>
> </html>
Are you really using Forth's text interpreter, here? There's no space
after <title> for it to be recognized as a word. If you're not using
Forth at this point, how will you embed any Forth logic? If you've
extended the interpreter so that <title> is pulled off and then allowed
to do its own parsing of the bare ` flow CGI ' that follows, how does
its parser know to interpret some text as Forth? I think of
: title ." flow CGI" ;
<html>
<head> <title> title ( <-- executed.) </title> </head>
<body>
<p> .( It works!) </p>
</body> </html>
You get a mileage from hitting space a few extra times. It's suddenly
clear what's Forth and what isn't; you don't have to do anything special
to switch between HTML and Forth; porting becomes a matter of a prelude
with some definitions, rather than having to (temporarily?) extend or
duplicate or hack the system's text interpreter. And rather than having
to edit the code to insert the spaces, which is an irritation for
version control.
> \ it might be my impl. but this seems backward for ! (STORE)...
> 3 ARRAY NUMS
> R1 0 NUMS !
> R2 1 NUMS !
> R3 2 NUMS !
! ( x a-addr -- )
NUMS ( u -- a-addr )
What seems backwards?
> : ROWS
> 0
> BEGIN
> 2DUP = IF 2DROP EXIT THEN
> <TR> DUP 1+ SWAP <TD> DUP 48 + EMIT </TD> <TD> NUMS @ DUP STRLEN
> TELL </TD> </TR>
> AGAIN
> ;
[char] 0 + \ clearer
(.) \ works for two-digit numbers.
: rows ( n -- ) \ is this so awful?
0 ?do <tr>
<td> i (.) type </td> \ may want a 1+ here
<td> i nums @ dup strlen tell </td>
</tr> loop ;
Back to comp.lang.forth | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Yay! CGI forth interpreter success Tarkin <tarkin000@gmail.com> - 2011-07-24 19:08 -0700
Re: Yay! CGI forth interpreter success Mark Wills <forthfreak@forthfiles.net> - 2011-07-25 05:17 -0700
Re: Yay! CGI forth interpreter success John Passaniti <john.passaniti@gmail.com> - 2011-07-25 18:31 -0700
Re: Yay! CGI forth interpreter success BruceMcF <agila61@netscape.net> - 2011-07-25 22:53 -0700
Re: Yay! CGI forth interpreter success Albert van der Horst <albert@spenarnc.xs4all.nl> - 2011-07-26 19:34 +0000
Re: Yay! CGI forth interpreter success Paul Rubin <no.email@nospam.invalid> - 2011-07-26 01:21 -0700
Re: Yay! CGI forth interpreter success Mark Wills <forthfreak@forthfiles.net> - 2011-07-26 01:57 -0700
Re: Yay! CGI forth interpreter success Albert van der Horst <albert@spenarnc.xs4all.nl> - 2011-07-26 19:48 +0000
Re: Yay! CGI forth interpreter success mhx@iae.nl (Marcel Hendrix) - 2011-07-27 21:33 +0200
Re: Yay! CGI forth interpreter success crc <charles.childers@gmail.com> - 2011-07-29 13:10 -0700
Re: Yay! CGI forth interpreter success Gerry Jackson <gerry@jackson9000.fsnet.co.uk> - 2011-07-26 17:48 +0100
Re: Yay! CGI forth interpreter success Gerry Jackson <gerry@jackson9000.fsnet.co.uk> - 2011-07-26 17:54 +0100
Re: Yay! CGI forth interpreter success crc <charles.childers@gmail.com> - 2011-07-26 12:02 -0700
Re: Yay! CGI forth interpreter success Gerry Jackson <gerry@jackson9000.fsnet.co.uk> - 2011-07-29 17:36 +0100
Re: Yay! CGI forth interpreter success anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2011-07-26 17:06 +0000
Re: Yay! CGI forth interpreter success Tarkin <tarkin000@gmail.com> - 2011-07-30 12:35 -0700
Re: Yay! CGI forth interpreter success Julian Fondren <ayrnieu@gmail.com> - 2011-07-30 16:03 -0500
Re: Yay! CGI forth interpreter success Albert van der Horst <albert@spenarnc.xs4all.nl> - 2011-07-31 10:47 +0000
Re: Yay! CGI forth interpreter success Tarkin <tarkin000@gmail.com> - 2011-07-31 11:11 -0700
Re: Yay! CGI forth interpreter success John Passaniti <john.passaniti@gmail.com> - 2011-08-03 09:41 -0700
Re: Yay! CGI forth interpreter success Spam@ControlQ.com - 2011-08-03 13:54 -0400
Re: Yay! CGI forth interpreter success Tarkin <Tarkin000@invalid.com> - 2011-08-04 23:06 +0000
Re: Yay! CGI forth interpreter success John Passaniti <john.passaniti@gmail.com> - 2011-08-11 16:48 -0700
Re: Yay! CGI forth interpreter success Tarkin <Tarkin000@gmail.com> - 2011-08-14 02:12 +0000
Re: Yay! CGI forth interpreter success John Passaniti <john.passaniti@gmail.com> - 2011-08-13 22:03 -0700
Re: Yay! CGI forth interpreter success Tarkin <Tarkin000@gmail.com> - 2011-08-20 23:07 +0000
Re: Yay! CGI forth interpreter success Tarkin <tarkin000@gmail.com> - 2011-07-31 11:12 -0700
Re: Yay! CGI forth interpreter success Tarkin <tarkin000@gmail.com> - 2011-07-31 11:24 -0700
csiph-web