Re: YACC, going the other way

zvr@ntua.gr (Alexios Zavras)
25 Apr 91 08:54:58 GMT

          From comp.compilers

Related articles
YACC, going the other way elk@cblpn.att.com (1991-04-15)
Re: YACC, going the other way zeil@cs.odu.edu (1991-04-23)
Re: YACC, going the other way carlton@aldebaran.Berkeley.EDU (1991-04-23)
Re: YACC, going the other way wunder@hpsdel.sde.hp.com (Walter Underwood) (1991-04-24)
Re: YACC, going the other way zvr@ntua.gr (1991-04-25)
Re: YACC, going the other way jimad@microsoft.UUCP (1991-04-26)
Re: YACC, going the other way ressler@cs.cornell.edu (1991-05-01)
| List of all articles for this month |

Newsgroups: comp.compilers
From: zvr@ntua.gr (Alexios Zavras)
Keywords: yacc, parse, testing
Organization: National Technical University of Athens, Greece
References: <1991Apr23.140427.5416@iecc.cambridge.ma.us>
Date: 25 Apr 91 08:54:58 GMT

In article <1991Apr23.140427.5416@iecc.cambridge.ma.us>, elk@cblpn.att.com (Edwin Lewis King +1 614 860 3394) writes:
> I'm interesting in generating strings that are described by a BNF (OK,
> YACC) grammar.
> Has anyone actually done this before? Is there a YACC-ish tool
> available for such a thing?


        I've seen this question in the past and I replied by mail, but
since people always ask, our moderator should keep an answer as well.


        Check out kafka, a tool that does exactly what you want !
The source was posted on the net (altough many years ago),
so it must be archived somewhere.


        It is the base on which the games insult, babble and flame are
based: each of them is just a grammar specification.
>From the original README:
> Copyright (c) 1985 Wayne A. Christopher
> Contained herein is the source for kafka, which is a program that
> translates BNF grammars into C programs to generate strings in the
> grammar, and files for three useful kafka programs, insult, flame,
> and babble. I don't have a manual page for kafka because I have
> been too lazy to write one, but if you read the .k files you will
> probably be able to figure out how things work.


        The program is *very* yacc-like (even has kkoutput() functions :-).
Here are some sample lines from flame.k:


<start> = <flame>;
<flame> = "I can't believe how " <adjective> " you are." { CH(1,100); } ;
<flame> = "I firmly believe that" <statement> "." { CH(1,80); } ;
<adjective> = ignorant { CH(1, 100); } ;
<adjective> = as <adjective> "as a" <thing> { CH(1, 60); } ;
<thing> = <adjective> <thing> { CH(1,30); } ;
<thing> = dog { CH(1,60); } ;
<statement> = most <group-adj> "people have" <thing> "#s" { CH(1, 60); } ;


etc. etc.


Oh, here's a sample output: :-)
> zvr@phgasos> flame
> I'll bet you think that dogs are nasty. I can't believe how hungry
> like a wolf you are. Furthermore, you jerk, you make me sick.


A very useful program !!!


-- zvr --
Alexios Zavras (-zvr-)
zvr@ntua.gr
zvr@theseas.ntua.gr
--


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.