Mercurial > projects > dil
comparison trunk/src/dil/translator/German.d @ 678:cedfc67faabf
Improved GermantTranslator.
author | Aziz K?ksal <aziz.koeksal@gmail.com> |
---|---|
date | Fri, 18 Jan 2008 23:11:44 +0100 |
parents | e7811328e6c7 |
children | 1ae72234db26 |
comparison
equal
deleted
inserted
replaced
677:118971211c4c | 678:cedfc67faabf |
---|---|
25 char[] indentStep; /// Appended to indent at each indendation level. | 25 char[] indentStep; /// Appended to indent at each indendation level. |
26 | 26 |
27 Declaration inAggregate; /// Current aggregate. | 27 Declaration inAggregate; /// Current aggregate. |
28 Declaration inFunc; /// Current function. | 28 Declaration inFunc; /// Current function. |
29 | 29 |
30 bool pluralize; /// Whether to use the plural in the next type. | 30 bool pluralize; /// Whether to use the plural when printing the next types. |
31 bool pointer; /// Whether next types should consider the previous pointer. | |
31 | 32 |
32 /++ | 33 /++ |
33 Construct a GermanTranslator. | 34 Construct a GermanTranslator. |
34 Params: | 35 Params: |
35 put = buffer to print to. | 36 put = buffer to print to. |
281 | 282 |
282 TypeNode visit(ArrayType n) | 283 TypeNode visit(ArrayType n) |
283 { | 284 { |
284 char[] c1 = "s", c2 = ""; | 285 char[] c1 = "s", c2 = ""; |
285 if (pluralize) | 286 if (pluralize) |
286 (pluralize = false), (c1 = "n"), (c2 = "s"); | 287 (c1 = pointer ? ""[] : "n"), (c2 = "s"); |
287 // Types after arrays should be in plural. | 288 pointer = false; |
288 pluralize = true; | |
289 if (n.assocType) | 289 if (n.assocType) |
290 put.format("assoziative{} Array{} von ", c1, c2); | 290 put.format("assoziative{} Array{} von ", c1, c2); |
291 // visitT(n.assocType); | 291 // visitT(n.assocType); |
292 else if (n.e) | 292 else if (n.e) |
293 { | 293 { |
297 put.format("statische{} Array{} von ", c1, c2); | 297 put.format("statische{} Array{} von ", c1, c2); |
298 // visitE(n.e), n.e2 && visitE(n.e2); | 298 // visitE(n.e), n.e2 && visitE(n.e2); |
299 } | 299 } |
300 else | 300 else |
301 put.format("dynamische{} Array{} von ", c1, c2); | 301 put.format("dynamische{} Array{} von ", c1, c2); |
302 // Types following arrays should be in plural. | |
303 pluralize = true; | |
302 visitT(n.next); | 304 visitT(n.next); |
305 pluralize = false; | |
303 return n; | 306 return n; |
304 } | 307 } |
305 | 308 |
306 TypeNode visit(PointerType n) | 309 TypeNode visit(PointerType n) |
307 { | 310 { |
308 char[] c = ""; | 311 char[] c = pluralize ? (pointer ? ""[] : "n") : ""; |
309 if (pluralize) | 312 pointer = true; |
310 (pluralize = false), c = "n"; | |
311 put.format("Zeiger{} auf ", c), visitT(n.next); | 313 put.format("Zeiger{} auf ", c), visitT(n.next); |
312 return n; | 314 return n; |
313 } | 315 } |
314 | 316 |
315 TypeNode visit(QualifiedType n) | 317 TypeNode visit(QualifiedType n) |
326 return n; | 328 return n; |
327 } | 329 } |
328 | 330 |
329 TypeNode visit(IntegralType n) | 331 TypeNode visit(IntegralType n) |
330 { | 332 { |
331 char[] c = ""; | 333 char[] c = pluralize ? "s"[] : ""; |
332 if (pluralize) | 334 if (n.tok == TOK.Void) // Avoid pluralizing "void" |
333 { | 335 c = ""; |
334 (pluralize = false), c = "s"; | 336 put.format("{}{}", n.begin.srcText, c); |
335 if (n.tok == TOK.Void) // Avoid pluralizing "void" | |
336 c = ""; | |
337 } | |
338 put.format(n.begin.srcText, c); | |
339 return n; | 337 return n; |
340 } | 338 } |
341 } | 339 } |