OLD | NEW |
1 # Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 # Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
2 # for details. All rights reserved. Use of this source code is governed by a | 2 # for details. All rights reserved. Use of this source code is governed by a |
3 # BSD-style license that can be found in the LICENSE file. | 3 # BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 '''Generates the many subtypes of Node as well as a NodeVisitor into | 5 '''Generates the many subtypes of Node as well as a NodeVisitor into |
6 tree.g.dart.''' | 6 tree.g.dart.''' |
7 | 7 |
8 from codegen import CodeWriter | 8 from codegen import CodeWriter |
9 | 9 |
10 class Node: | 10 class Node: |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 class Statement(Node): pass | 90 class Statement(Node): pass |
91 | 91 |
92 class Definition(Node): pass | 92 class Definition(Node): pass |
93 | 93 |
94 class TypeReference(Node): pass | 94 class TypeReference(Node): pass |
95 | 95 |
96 nodes = [ | 96 nodes = [ |
97 Definition('Directive', 'Identifier name, List<ArgumentNode> arguments'), | 97 Definition('Directive', 'Identifier name, List<ArgumentNode> arguments'), |
98 | 98 |
99 Definition('Type', | 99 Definition('Type', |
100 'bool isClass, Identifier name, List<TypeParameter> typeParameters, '+ | 100 'bool isClass, Identifier name, List<ParameterType> typeParameters, '+ |
101 'List<TypeReference> extendsTypes, List<TypeReference> implementsTypes,'+ | 101 'List<TypeReference> extendsTypes, List<TypeReference> implementsTypes,'+ |
102 'NativeType nativeType, TypeReference factoryType, List<Statement> body'), | 102 'NativeType nativeType, TypeReference factoryType, List<Statement> body'), |
103 | 103 |
104 Definition('FunctionType', | 104 Definition('FunctionType', |
105 'FunctionDefinition func, List<TypeParameter> typeParameters'), | 105 'FunctionDefinition func, List<ParameterType> typeParameters'), |
106 | 106 |
107 Definition('Variable', | 107 Definition('Variable', |
108 'List<Token> modifiers, TypeReference type, List<Identifier> names,' + | 108 'List<Token> modifiers, TypeReference type, List<Identifier> names,' + |
109 'List<Expression> values'), | 109 'List<Expression> values'), |
110 | 110 |
111 Definition('Function', | 111 Definition('Function', |
112 'List<Token> modifiers, TypeReference returnType, Identifier name,' + | 112 'List<Token> modifiers, TypeReference returnType, Identifier name,' + |
113 'List<FormalNode> formals, List<Expression> initializers,' + | 113 'List<FormalNode> formals, List<ParameterType> typeParameters,' + |
114 'Statement body'), | 114 'List<Expression> initializers, Statement body'), |
115 | 115 |
116 Statement('Return', 'Expression value'), | 116 Statement('Return', 'Expression value'), |
117 Statement('Throw', 'Expression value'), | 117 Statement('Throw', 'Expression value'), |
118 Statement('Assert', 'Expression test'), | 118 Statement('Assert', 'Expression test'), |
119 | 119 |
120 Statement('Break', 'Identifier label'), | 120 Statement('Break', 'Identifier label'), |
121 Statement('Continue', 'Identifier label'), | 121 Statement('Continue', 'Identifier label'), |
122 | 122 |
123 Statement('If', | 123 Statement('If', |
124 'Expression test, Statement trueBranch, Statement falseBranch'), | 124 'Expression test, Statement trueBranch, Statement falseBranch'), |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 cw.writeln('var output;') | 232 cw.writeln('var output;') |
233 cw.writeln('TreePrinter(this.output) { output.printer = this; }') | 233 cw.writeln('TreePrinter(this.output) { output.printer = this; }') |
234 for node in nodes: | 234 for node in nodes: |
235 node.writePrettyPrintMethod(cw) | 235 node.writePrettyPrintMethod(cw) |
236 cw.writeln() | 236 cw.writeln() |
237 cw.exitBlock('}') | 237 cw.exitBlock('}') |
238 | 238 |
239 cw.writeToFile('tree') | 239 cw.writeToFile('tree') |
240 | 240 |
241 if __name__ == '__main__': main() | 241 if __name__ == '__main__': main() |
OLD | NEW |