1 /*
2 * PROPRIETARY INFORMATION. This software is proprietary to POWDER
3 * Development, and is not to be reproduced, transmitted, or disclosed
4 * in any way without written permission.
5 *
6 * Produced by: Jeff Lait
7 *
8 * POWDER Development
9 *
10 * NAME: grammar.h ( POWDER Library, C++ )
11 *
12 * COMMENTS:
13 * These handle all the bizarre exceptions which English can
14 * throw at us. Well, theoritically they are all handled, but
15 * as exceptions are found, this is where to add them.
16 */
17
18 #ifndef __grammar_h__
19 #define __grammar_h__
20
21 #include "buf.h"
22
23 class MOB;
24 class ITEM;
25
26 enum VERB_PERSON
27 {
28 VERB_I,
29 VERB_YOU,
30 VERB_HE,
31 VERB_SHE,
32 VERB_IT,
33 VERB_WE,
34 VERB_YALL,
35 VERB_HES,
36 VERB_SHES,
37 VERB_THEY,
38 NUM_VERBS
39 };
40
41 // Utility functions to expand ctype.
42 bool
43 gram_ispronoun(const char *word);
44 inline bool
gram_ispronoun(BUF buf)45 gram_ispronoun(BUF buf)
46 { return gram_ispronoun(buf.buffer()); }
47
48
49 // Utility function to capitalize a sentence...
50 // This will also capitalize any sub sentences.
51 BUF
52 gram_capitalize(const char *str);
53 BUF
54 gram_capitalize(BUF buf);
55
56 // This will convert the given name into the possessive tense.
57 // Ie, you -> your, orc -> orc's, moss -> moss'
58 BUF
59 gram_makepossessive(const char *str);
60 BUF
61 gram_makepossessive(BUF str);
62
63 // This will convert the given name into a plural
64 BUF
65 gram_makeplural(const char *phrase);
66 BUF
67 gram_makeplural(BUF phrase);
68
69 // XXX hits the Foo.
70 // he/she/it/you/I
71 const char *
72 gram_getpronoun(VERB_PERSON person);
73
74 // XXX rock dissolved in acid.
75 // his/her/its/your/my
76 const char *
77 gram_getpossessive(VERB_PERSON person);
78
79 // That rock is XXX.
80 // his/hers/its/yours/mine
81 const char *
82 gram_getownership(VERB_PERSON person);
83
84 // Suicidially, Foo hits XXX.
85 // himself/herself/itself/yourself/myself
86 const char *
87 gram_getreflexive(VERB_PERSON person);
88
89 // Foo hits XXX.
90 // him/her/it/you/me
91 const char *
92 gram_getaccusative(VERB_PERSON person);
93
94 bool
95 gram_isvowel(char c);
96
97 // True if c is the end of a sentence.
98 bool
99 gram_isendsentence(char c);
100
101 bool
102 gram_isplural(const char *noun);
103 inline bool
gram_isplural(BUF buf)104 gram_isplural(BUF buf)
105 { return gram_isplural(buf.buffer()); }
106
107 // This takes a complicated name, like:
108 // holy +3 wand of fireballs (5)
109 // and determines if "wand" is plural.
110 bool
111 gram_isnameplural(const char *name);
112 inline bool
gram_isnameplural(BUF buf)113 gram_isnameplural(BUF buf)
114 { return gram_isnameplural(buf.buffer()); }
115
116 // This will fetch the appropriate article, ie: a, an, the.
117 // As the article may be empty (for proper nouns or plural nouns)
118 // the trailing space is included, so it would be "a ".
119 const char *
120 gram_getarticle(const char *noun);
121 inline const char *
gram_getarticle(BUF buf)122 gram_getarticle(BUF buf)
123 { return gram_getarticle(buf.buffer()); }
124
125 // This builds the appropriate phrase, such as "5 arrows of dragon slaying"
126 // or "no tea" according to the singular basename and the count variable.
127 // If article is false, it will not use "a" or "the" in the singular
128 // cases.
129 BUF
130 gram_createcount(const char *basename, int count, bool article);
131 BUF
132 gram_createcount(BUF basename, int count, bool article);
133
134 // This builds the appropriate place number. Ie, 1st, 2nd, 23rd.
135 BUF
136 gram_createplace(int place);
137
138 // Conjugates the given infinitive verb according the given person.
139 BUF
140 gram_conjugate(const char *verb, VERB_PERSON person, bool past = false);
141 inline BUF
142 gram_conjugate(BUF verb, VERB_PERSON person, bool past = false)
143 { return gram_conjugate(verb.buffer(), person, past); }
144
145 #endif
146