| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 # | 2 # |
| 3 # Copyright 2012 The Native Client Authors. All rights reserved. | 3 # Copyright 2012 The Native Client Authors. All rights reserved. |
| 4 # Use of this source code is governed by a BSD-style license that can | 4 # Use of this source code is governed by a BSD-style license that can |
| 5 # be found in the LICENSE file. | 5 # be found in the LICENSE file. |
| 6 # | 6 # |
| 7 | 7 |
| 8 """Decoder Generator script. | 8 """Decoder Generator script. |
| 9 | 9 |
| 10 Usage: generate-decoder.py <table-file> <output-cc-file> <decoder-name> | 10 Usage: generate-decoder.py <table-file> <output-cc-file> <decoder-name> |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 print "Decoder Generator reading ", table_filename | 40 print "Decoder Generator reading ", table_filename |
| 41 f = open(table_filename, 'r') | 41 f = open(table_filename, 'r') |
| 42 tables = dgen_input.parse_tables(f) | 42 tables = dgen_input.parse_tables(f) |
| 43 f.close() | 43 f.close() |
| 44 | 44 |
| 45 print "Successful - got %d tables." % len(tables) | 45 print "Successful - got %d tables." % len(tables) |
| 46 | 46 |
| 47 print "Generating %s..." % output_filename | 47 print "Generating %s..." % output_filename |
| 48 f = open(output_filename, 'w') | 48 f = open(output_filename, 'w') |
| 49 | 49 |
| 50 if output_filename.endswith('named.h'): | 50 if output_filename.endswith('tests.cc'): |
| 51 dgen_output.generate_tests_cc(tables, |
| 52 dgen_output.COutput(f)) |
| 53 elif output_filename.endswith('named.h'): |
| 51 dgen_output.generate_decoder_h(tables, | 54 dgen_output.generate_decoder_h(tables, |
| 52 decoder_name, | 55 decoder_name, |
| 53 _localize_filename(output_filename), | 56 _localize_filename(output_filename), |
| 54 True, | 57 True, |
| 55 dgen_output.COutput(f)) | 58 dgen_output.COutput(f)) |
| 56 elif output_filename.endswith('.h'): | 59 elif output_filename.endswith('.h'): |
| 57 dgen_output.generate_decoder_h(tables, | 60 dgen_output.generate_decoder_h(tables, |
| 58 decoder_name, | 61 decoder_name, |
| 59 _localize_filename(output_filename), | 62 _localize_filename(output_filename), |
| 60 False, | 63 False, |
| (...skipping 12 matching lines...) Expand all Loading... |
| 73 dgen_output.COutput(f)) | 76 dgen_output.COutput(f)) |
| 74 else: | 77 else: |
| 75 print 'Error: output filename not of form "*.{h,cc}"' | 78 print 'Error: output filename not of form "*.{h,cc}"' |
| 76 f.close() | 79 f.close() |
| 77 print "Completed." | 80 print "Completed." |
| 78 | 81 |
| 79 return 0 | 82 return 0 |
| 80 | 83 |
| 81 if __name__ == '__main__': | 84 if __name__ == '__main__': |
| 82 sys.exit(main(sys.argv)) | 85 sys.exit(main(sys.argv)) |
| OLD | NEW |