comparison trunk/src/dil/translator/German.d @ 798:c24be8d4f6ab

Added documentation comments.
author Aziz K?ksal <aziz.koeksal@gmail.com>
date Sat, 01 Mar 2008 02:53:06 +0100
parents 19a34b69cc7d
children
comparison
equal deleted inserted replaced
797:cf2ad5df025c 798:c24be8d4f6ab
12 dil.ast.Parameters; 12 dil.ast.Parameters;
13 import tango.io.Print; 13 import tango.io.Print;
14 14
15 private alias Declaration D; 15 private alias Declaration D;
16 16
17 /++ 17 /// Translates a syntax tree into German.
18 Traverses a D syntax tree and explains in German.
19 +/
20 class GermanTranslator : DefaultVisitor 18 class GermanTranslator : DefaultVisitor
21 { 19 {
22 Print!(char) put; /// Output buffer. 20 Print!(char) put; /// Output buffer.
23 21
24 char[] indent; /// Current indendation string. 22 char[] indent; /// Current indendation string.
28 Declaration inFunc; /// Current function. 26 Declaration inFunc; /// Current function.
29 27
30 bool pluralize; /// Whether to use the plural when printing the next types. 28 bool pluralize; /// Whether to use the plural when printing the next types.
31 bool pointer; /// Whether next types should consider the previous pointer. 29 bool pointer; /// Whether next types should consider the previous pointer.
32 30
33 /++ 31 /// Construct a GermanTranslator.
34 Construct a GermanTranslator. 32 /// Params:
35 Params: 33 /// put = buffer to print to.
36 put = buffer to print to. 34 /// indentStep = added at every indendation step.
37 indentStep = added at every indendation step.
38 +/
39 this(Print!(char) put, char[] indentStep) 35 this(Print!(char) put, char[] indentStep)
40 { 36 {
41 this.put = put; 37 this.put = put;
42 this.indentStep = indentStep; 38 this.indentStep = indentStep;
43 } 39 }
46 void translate(Node root) 42 void translate(Node root)
47 { 43 {
48 visitN(root); 44 visitN(root);
49 } 45 }
50 46
47 /// Increases the indentation when instantiated.
48 /// The indentation is restored when the instance goes out of scope.
51 scope class Indent 49 scope class Indent
52 { 50 {
53 char[] old_indent; 51 char[] old_indent;
54 this() 52 this()
55 { 53 {
62 60
63 char[] toString() 61 char[] toString()
64 { return this.outer.indent; } 62 { return this.outer.indent; }
65 } 63 }
66 64
65 /// Saves an outer member when instantiated.
66 /// It is restored when the instance goes out of scope.
67 scope class Enter(T) 67 scope class Enter(T)
68 { 68 {
69 T t_save; 69 T t_save;
70 this(T t) 70 this(T t)
71 { 71 {
98 alias Enter!(StructDeclaration) EnteredStruct; 98 alias Enter!(StructDeclaration) EnteredStruct;
99 alias Enter!(UnionDeclaration) EnteredUnion; 99 alias Enter!(UnionDeclaration) EnteredUnion;
100 alias Enter!(FunctionDeclaration) EnteredFunction; 100 alias Enter!(FunctionDeclaration) EnteredFunction;
101 alias Enter!(ConstructorDeclaration) EnteredConstructor; 101 alias Enter!(ConstructorDeclaration) EnteredConstructor;
102 102
103 /// Prints the location of a node: @(lin,col)
103 void printLoc(Node node) 104 void printLoc(Node node)
104 { 105 {
105 auto loc = node.begin.getRealLocation(); 106 auto loc = node.begin.getRealLocation();
106 put(indent).formatln("@({},{})",/+ loc.filePath,+/ loc.lineNum, loc.colNum); 107 put(indent).formatln("@({},{})",/+ loc.filePath,+/ loc.lineNum, loc.colNum);
107 } 108 }