| OLD | NEW |
| (Empty) |
| 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 | |
| 3 # BSD-style license that can be found in the LICENSE file. | |
| 4 from token_info import tokens, keywords | |
| 5 from codegen import CodeWriter | |
| 6 | |
| 7 EXCLUDES = ['$add'] | |
| 8 | |
| 9 def main(): | |
| 10 '''Generates the TokenKind class into token_kind.g.dart.''' | |
| 11 cw = CodeWriter(__file__) | |
| 12 for tok in tokens: | |
| 13 if tok.methodName is not None and tok.methodName not in EXCLUDES: | |
| 14 dname = repr(tok.methodName).replace('$', '\\$') | |
| 15 cw.enterBlock('function %s(x, y) {' % tok.methodName) | |
| 16 cw.writeln("return (typeof(x) == 'number' && typeof(y) == 'number')") | |
| 17 cw.writeln(' ? x %s y : x.%s(y);' % (tok.text, tok.methodName)) | |
| 18 cw.exitBlock('}') | |
| 19 | |
| 20 cw.writeToFile('tests/core.g.js') | |
| 21 | |
| 22 if __name__ == '__main__': main() | |
| OLD | NEW |