-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGrammarBase.gf
293 lines (259 loc) · 7.21 KB
/
GrammarBase.gf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
abstract GrammarBase = {
flags startcat = S;
cat
S ; Cl ; Fragment ;
NP ; VP ; A ; PrepP ;
W ; PreV ; Prep ; Interj ; Num ; Pred ; PredInfix ; VCList ;
fun
--
-- A comments with prefix `PU` is a cite
-- from the official Toki Pona book.
--
--
-- A clause. Not exaclty:
--
--PU-- To build a simple sentence in TokiPona, follow the model:
--PU-- NOUN + `li` + NOUN
--
-- Instead: in the grammar, a clause is:
--
-- NP (noun phrase) + `li` + Predicate
--
-- For example,
-- "ni li jan"
-- is
-- (Clause (UseN Ni_W) (PredNP (UseN Jan_W)))
--
Clause : NP -> Pred -> Cl ;
UseN : W -> NP ;
PredNP : NP -> Pred ;
--
-- An adjective.
--
--PU-- An adjective is a word that describes a noun.
--PU-- An adjective can also be added after a noun to describe it.
UseA : W -> A ;
AdjNP : NP -> A -> NP ;
--
-- Not:
--
--PU-- This can be a complete sentence:
--PU-- NOUN + li + ADJECTIVE
--
-- Instead: in the grammar, there are no adjective predicates.
--
-- The reason is that a Tokipona word can be anything:
-- an adjective, a noun or a verb. Consider the phrase:
--
-- mi sona.
--
-- A translation can be:
--
-- I am knowledge
-- I am wise
-- I know
--
-- To avoid a combinatoric explosure of parses, the rule is that
-- the predicate is always a noun phrase (unless definitely not).
--
--
-- Not:
--
--PU-- A second noun can also fill the role of the adjective.
--PU-- This is similar to using the word 'of' in English.
--
-- Skip it to avoid combinatoric explosure.
--
--
--PU-- The particle 'pi' is used to divide a second noun group
--PU-- that describes a first noun group.
--
PiNP : NP -> NP -> NP ;
--
--PU-- An adjective can also be used directly after a verb
--PU-- to modify it.
--
UseV : W -> VP ;
AdjVP : VP -> A -> VP ;
--
-- Not exactly:
--
--PU-- An adjective can also modify another adjective.
--
-- In the grammar:
--
-- An adjective can be added to a noun phrase or to a verb phrase
-- and then another adjective can be added as well.
--
--
--PU-- The words 'mi' ('me, we') and 'sina' ('you') are special.
--PU-- When 'mi' or 'sina' is used alone as the subject,
--PU-- no 'li' is used after it.
--
Mi_Pron : NP ;
Sina_Pron : NP ;
Ona_Pron : NP ;
--
--PU-- To form a sentence with a verb, follow this model:
--PU-- NOUN + li + VERB + e + NOUN
--
-- Not:
--
--PU-- You can omit the object of a verb.
--
-- Skip it to avoid combinatoric explosure.
--
ComplV : VP -> NP -> Pred ;
--
--PU-- A pre-verb can be added before a main verb
--
WithPreV : W -> PreV -> VP ;
--
-- A clause can have several predicated
--
-- To simplify the grammar, it is convenient to represent
-- prepositions and `ala`/`anu` constructions as predicates.
--
PredL : Pred -> PredInfix -> Pred -> Pred ;
PredPrepL : Pred -> PrepP -> Pred ;
PredInfixNot : PredInfix ; -- ala
PredInfixOr : PredInfix ; -- anu
PredInfixAnd : PredInfix ; -- li
PredInfixCAnd : PredInfix ; -- , li
PredPrep : PrepP -> Pred ;
--
--PU-- There are two ways to ask a yes-or-no question.
--PU-- The first is to add the phrase 'anu seme' at the end.
--
--PU-- The other way is to repeat the word being
--PU-- used as a verb, adding 'ala' in between
--
-- In the grammar:
-- something anu/ala seme
-- represented as a predicate list:
-- (Predicate for something) PredInfixAnu (Predicate for seme)
-- (Predicate for something) PredInfixAla (Predicate for the verb)
--
--
--PU-- To reply 'yes', repeat the verb.
--PU-- To reply 'no', repeat the verb with 'ala'
--PU-- or use 'ala' alone
--
ClausePred : Pred -> Cl ;
--
--PU-- `anu` can be used as `or` for noun phrases.
--PU-- It is not described in the book, but seen in examples
--
OrNP : NP -> NP -> NP ;
--
--PU-- Prepositions often introduce a new noun.
--
ComplPrep : Prep -> NP -> PrepP ;
UsePrep: Prep -> PrepP ;
--
--PU-- A preposition can be used at the end of a sentence.
--
--PU-- A sentence can also use a preposition
--PU-- without a regular verb.
--
-- Grammer: Use `ClausePred`
--
--PU-- Proper names behave as adjectives.
--PU-- Use them after a noun that describes what they are.
--
-- To mark a word as name, prefix it with 'Nimi':
-- 'ma tomo Nimi Isanpu' is 'Istanbul'.
--
Name : String -> A ;
NameNP : String -> NP ;
--
--PU-- To greet someone.
--PU-- Greetings are often not complete sentences.
--
-- Grammar: Use `ClausePred`
--
--
--PU-- The particle 'a' adds emothion or emphasis.
--PU-- It can be used:
--PU--
--PU-- 1. alone,
--
IjAlone : Interj -> Cl ;
--
--PU-- 2. at the end of a sentence
--
PostfixIjCl : Cl -> Interj -> Cl ;
--
--PU-- 3. at the end of a noun phrase
--
IjNP : NP -> Interj -> NP ;
--
-- Not mentioned in the grammar, but used in examples:
-- . several interjections in a raw
-- . interjection at the beginning of a sentence
--
IjExt : Interj -> Interj -> Interj ;
PrefixIjCl : Cl -> Interj -> Cl ;
--
--PU-- The particle 'o' has three uses:
--PU-- 1. after a noun phrase to show who is being called
--PU-- addressed,
--
Vocative : NP -> Fragment ;
--
--PU-- 2. before a verb to express a command or request,
--
Command : Pred -> Cl ;
--
--PU-- 3. after the subject (and replacing 'li') to express
--PU-- a wish or desire.
--
Wish : NP -> Pred -> Cl ;
--
--PU-- The simplest number system uses five basic adjectives.
--PU-- Add them one after another.
--
GrowNum : Num -> Num -> Num ;
Number : Num -> A ;
--
--PU-- For ordinal numbers, add the particle 'nanpa' before
--PU-- the number.
--
OrdinalNP : Num -> NP ;
OrdinalA : Num -> A ;
--
--PU-- The particle 'la' allows to link two sentences,
--PU-- or link a fragment to a sentence.
--
FragmentNP : NP -> Fragment ;
FragmentVP : VP -> Fragment ;
FragmentCl : Cl -> Fragment ;
WithContext : Cl -> Fragment -> Cl ;
--
-- Versions with different context separators
--
WithContextC : Cl -> Fragment -> Cl ; -- ','
WithContextCLa : Cl -> Fragment -> Cl ; -- ', la'
WithContextSc : Cl -> Fragment -> Cl ; -- ':'
--
--PU-- There are many ways to translate 'and'
--PU-- 1. Join multiple subjects with 'en'
--
AndNP : NP -> NP -> NP;
--
--PU-- 2. Join multiple verbs by repeating 'li'
--
-- Use `PredInfixAnd`
--
--PU-- 3. Join multiple direct objects by repeating 'e'
--
ComplVL : VP -> VCList -> Pred ;
VCListPair : NP -> NP -> VCList ;
VCListGrow : VCList -> NP -> VCList ;
--
-- To build a sentence, add '.', '?' or '!' to a clause.
--
UseCl : Cl -> S ;
QuestUseCl : Cl -> S ;
ExclUseCl : Cl -> S ;
}