6
my $parser = Parse::RecDescent->new(<<'END_OF_GRAMMAR');
8
grammar: rule(s) /\Z/ { [ map { $_->[0], $_->[1] } @{$item[1]} ] }
10
rule: identifier ":" defn ";" { [ $item[1], $item[3] ] }
13
defn: choice (barchoice)(s?) { [ $item[1], @{$item[2]} ] }
19
item: quoted_string | identifier | <error>
21
quoted_string: /"(.*?)"/s { " ".substr($item[1],1,-1) }
23
identifier: /[A-Za-z_]\w*/
27
(my $parsed = $parser->grammar(join '', <DATA>)) or die "bad parse";
29
my $top = $parsed->[0];
39
die "missing defn for $defn" unless exists $defns{$defn};
41
my @choices = @{$defns{$defn}};
42
for (@{$choices[rand @choices]}) {
43
## should be a list of ids or defns
44
die "huh $_ in $defn" if ref $defn;
50
die "Can't show $_ in $defn\n";
56
stanza: stanza exclaim stanza2 | stanza2;
57
stanza2: sentence comparison question | sentence comparison | comparison
58
comparison exclaim | address question question sentence;
60
sentence: sentence sentence2 | sentence2;
61
sentence2: "The " adjectiveNotHep personNotHep verbRelating "the "
62
adjectiveHep personHep ". " | "The " personHep verbRelating "the "
63
adjectiveNotHep ", " adjectiveNotHep personNotHep ". ";
65
question: question question2 | question2;
66
question2: ques_start adjectiveHep personNotHep "? " | ques_start
67
adjectiveNotHep personHep "? ";
69
comparison: comparison comparison2 | comparison2;
70
comparison2: "One says '" compNotHep "' while the other says '" compHep
72
"One thinks '" compNotHep "' while the other thinks '" compHep "'. "|
73
"They shout '" compNotHep "!' And we shout'" compHep "'. "|
74
"It's " compNotHep " versus " compHep "! ";
76
personNotHep: "capitalist" | "silk purse man" | "square" | "banker" |
77
"Merchant King" | "pinstripe suit" ;
79
personHep: "cat" | "beat soul" | "wordsmith" | "hep cat" | "free man" |
80
"street poet" | "skin beater" | "reed man" ;
82
adjectiveNotHep: "soul-sucking" | "commercial" | "cash-counting" |
83
"bloody-handed" | "four-cornered" | "uncool" | "love-snuffing";
85
adjectiveHep: "love-drunk" | "cool, cool" | "happening" | "tuned-in" |
86
"street wise" | "wise and learned";
88
verbRelating: "begrudges" | "fears" | "distresses" | "dodges" |
89
"dislikes" | "evades" | "curses" | "belittles" | "avoids" | "battles";
91
compNotHep: "recreation" | "isolation" | "tranportation" | "sacred nation"
92
| "complication" | "subordination";
93
compHep: "fornication" | "instigation" | "interpretation" | "elevation"
94
| "animation" | "inebriation" | "true relation";
96
ques_start: "Could there ever be a "|"How could there be a "|
98
address: "Catch this: " | "Listen, cats, " | "Dig it: " |
99
"I lay this on you: ";
100
exclaim: "Heavy, man. "|"Heavy. " | "Yow! " | "Snap 'em for me. " |