| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 2 # Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 3 # for details. All rights reserved. Use of this source code is governed by a | 3 # for details. All rights reserved. Use of this source code is governed by a |
| 4 # BSD-style license that can be found in the LICENSE file. | 4 # BSD-style license that can be found in the LICENSE file. |
| 5 | 5 |
| 6 '''Generates the many subtypes of Node as well as a NodeVisitor into | 6 '''Generates the many subtypes of Node as well as a NodeVisitor into |
| 7 tree.g.dart.''' | 7 tree.g.dart.''' |
| 8 | 8 |
| 9 from codegen import CodeWriter | 9 from codegen import CodeWriter |
| 10 | 10 |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 Node('Case', | 202 Node('Case', |
| 203 'Identifier label, List<Expression> cases, List<Statement> statements'), | 203 'Identifier label, List<Expression> cases, List<Statement> statements'), |
| 204 | 204 |
| 205 # Don't want to add Node to these names, use ! as convention to say so. | 205 # Don't want to add Node to these names, use ! as convention to say so. |
| 206 Node('TypeParameter!', 'Identifier name, TypeReference extendsType'), | 206 Node('TypeParameter!', 'Identifier name, TypeReference extendsType'), |
| 207 | 207 |
| 208 # TODO(jimhug): Consider removing this node and just using String. | 208 # TODO(jimhug): Consider removing this node and just using String. |
| 209 Node('Identifier!', 'String name'), | 209 Node('Identifier!', 'String name'), |
| 210 | 210 |
| 211 # Pseudo Expression for cover grammar approach | 211 # Pseudo Expression for cover grammar approach |
| 212 Expression('DeclaredIdentifier!', 'TypeReference type, Identifier name'), | 212 Expression('DeclaredIdentifier!', |
| 213 'TypeReference type, Identifier name, bool isFinal'), |
| 213 ] | 214 ] |
| 214 | 215 |
| 215 def main(): | 216 def main(): |
| 216 cw = CodeWriter(__file__) | 217 cw = CodeWriter(__file__) |
| 217 | 218 |
| 218 for node in nodes: | 219 for node in nodes: |
| 219 node.write(cw) | 220 node.write(cw) |
| 220 cw.writeln() | 221 cw.writeln() |
| 221 | 222 |
| 222 cw.writeln() | 223 cw.writeln() |
| (...skipping 10 matching lines...) Expand all Loading... |
| 233 cw.writeln('var output;') | 234 cw.writeln('var output;') |
| 234 cw.writeln('TreePrinter(this.output) { output.printer = this; }') | 235 cw.writeln('TreePrinter(this.output) { output.printer = this; }') |
| 235 for node in nodes: | 236 for node in nodes: |
| 236 node.writePrettyPrintMethod(cw) | 237 node.writePrettyPrintMethod(cw) |
| 237 cw.writeln() | 238 cw.writeln() |
| 238 cw.exitBlock('}') | 239 cw.exitBlock('}') |
| 239 | 240 |
| 240 cw.writeToFile('tree') | 241 cw.writeToFile('tree') |
| 241 | 242 |
| 242 if __name__ == '__main__': main() | 243 if __name__ == '__main__': main() |
| OLD | NEW |