Language Froth
Date: | 04/20/05 |
Author: | Leo Wong |
URL: | n/a |
Comments: | 4 |
Info: | n/a |
Score: | (3.00 in 27 votes) |
\ 99 bottles of beer in Froth, by Leo Wong, a teetotaler 6FEB96 + \ Pass it around. : LYRICS [CHAR] ! PARSE TUCK HERE CHAR+ SWAP CHARS MOVE DUP C, CHARS ALLOT ; : VOCALIZE ( a) COUNT TYPE ; : SING CREATE LYRICS DOES> VOCALIZE ; SING NO_MORE No more ! SING BOTTLE bottle! SING BOTTLES bottles! SING OF_BEER of beer! SING ON_THE_WALL on the wall! SING TAKE Take ! SING IT it! SING ONE one! SING DOWN_AND_PASS_IT_AROUND down and pass it around! SING GO_TO_THE_STORE_&_BUY_SOME_MORE Go to the store and buy some more! SING COMMA ,! SING PERIOD .! : ?: CREATE ( n) , ' , ' , DOES> ( n) TUCK @ <> 1- CELLS - @ EXECUTE ; : NONE ( n) DROP NO_MORE ; : SOME ( n) . ; 0 ?: HOW_MANY NONE SOME 1 ?: BOTTLE(S) BOTTLE BOTTLES 1 ?: IT|ONE IT ONE : COMMERCIAL ( 0 - 99) GO_TO_THE_STORE_&_BUY_SOME_MORE 99 + ; : SHAREWARE ( n - n-1) DUP TAKE IT|ONE DOWN_AND_PASS_IT_AROUND 1- ; 0 ?: main(){0?99:--} COMMERCIAL SHAREWARE : BURP ( n - n n) DUP ; : HOW_MANY_BOTTLES_OF_BEER ( n n n) HOW_MANY BOTTLE(S) OF_BEER ; : Froth ( n - n') CR BURP BURP BURP HOW_MANY_BOTTLES_OF_BEER ON_THE_WALL COMMA CR BURP BURP BURP HOW_MANY_BOTTLES_OF_BEER COMMA CR BURP main(){0?99:--} COMMA CR BURP BURP BURP HOW_MANY_BOTTLES_OF_BEER ON_THE_WALL PERIOD CR ; : LeoWong ( n) DROP ; : SONG 99
Download Source | Write Comment
Download Source | Write Comment
Add Comment
Please provide a value for the fields Name,
Comment and Security Code.
This is a gravatar-friendly website.
E-mail addresses will never be shown.
Enter your e-mail address to use your gravatar.
Please don't post large portions of code here! Use the form to submit new examples or updates instead!
Comments
Ian Osgood said on 07/12/05 19:41:22
This is more like poetry than code!
Albert van der Horst said on 07/08/06 20:20:10
The author does a disservice to this forum by not properly identifying the language.
This is standard Forth, as far I can tell.
Doug said on 10/14/06 05:29:15
Well,if it's Forth...Can we remove this entry ?
petchema said on 10/14/06 10:51:51
I think it's really Froth, a slightly non standard implementation of Forth language for i386 in protected mode (found it in ftp://ftp.forth.org/pub/Forth/Reviewed/froth.zip).
According to included docs,
"Here are the main differences between Froth and FORTH (ANS) languages:
A defined word cannot be a valid number (according to numeric I/O base).
Froth interpret is not case sensitive.
IMMEDIATE word must fit inside a definition in Froth.
ALLOT works in a different manner than in FORTH and the FORTH word , (comma), used in BUILD>...DOES> construction is replaced by the word ! (store). Also, CREATE (and ALLOT) can't be used ouside a definition.
FORTH screens are replaced by text files, so LOADing works differently.
Froth is not a threated language, but there is a real 386 compiler behind.
The return stack is in Froth a real secondary stack.
Strings are, like in C language, ended with zero. String elements are given on stack only by their address (not addres + length as in ANS Forth).
Froth is not an open language like FORTH, for example you cannot build by yourself your own control structures.
Forth users could use next alias words in place of Froth words (you can use either one of the two words):
Forth word Froth word
variable int
constant const
build> create
then endif
loop enddo
+loop +enddo"
From this I think it's really Froth rather than standard Forth. However the differences are small.