Language GNUCHILL
| Date: | 03/16/06 |
| Author: | Wilfried Moser |
| URL: | n/a |
| Comments: | 2 |
| Info: | n/a |
| Score: |
--
-- GNUCHILL implemtation of `99 beers on the wall' including correct
-- handling of the lyrics.
--
ninetyninebeersonthewall: MODULE
SYN maxbeersonthewall = 99;
SYNMODE beersrange = INT (0:maxbeersonthewall);
DCL beers BUFFER (1) beersrange;
countbeers: PROCESS ()
DCL nextbottle beersrange;
RECEIVE CASE
(beers in howmuch):
nextbottle := howmuch - 1
ON
(rangefail):
WRITETEXT (stdout, "No more bottles of beer on the wall, no more bottles of beer.%/");
WRITETEXT (stdout, "Go to the store and buy some more, 99 bottles of beer on the
wall.%/");
STOP;
END;
WRITETEXT (stdout, "%C bottles of beer on the wall, %C bottles of beer.%/", howmuch,
howmuch);
WRITETEXT (stdout, "Take one down and pass it around, no more bottles of beer on the
wall.%/");
SEND beers (nextbottle);
ESAC;
END countbeers;
DO FOR i IN beersrange;
START countbeers (-1);
OD;
SEND beers (maxbeersonthewall);
--
-- runtime takes care for remaining processes
-- before exiting.
--
END ninetyninebeersonthewall;
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