OLD | NEW |
1 #! /usr/bin/env python | 1 #! /usr/bin/env python |
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 import itertools | 6 import itertools |
7 import json | 7 import json |
8 import os.path | 8 import os.path |
9 import re | 9 import re |
10 import sys | 10 import sys |
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
462 idl = idl_parser.IDLParser().ParseData(contents, filename) | 462 idl = idl_parser.IDLParser().ParseData(contents, filename) |
463 idl_schema = IDLSchema(idl) | 463 idl_schema = IDLSchema(idl) |
464 return idl_schema.process() | 464 return idl_schema.process() |
465 | 465 |
466 | 466 |
467 def Main(): | 467 def Main(): |
468 ''' | 468 ''' |
469 Dump a json serialization of parse result for the IDL files whose names | 469 Dump a json serialization of parse result for the IDL files whose names |
470 were passed in on the command line. | 470 were passed in on the command line. |
471 ''' | 471 ''' |
472 for filename in sys.argv[1:]: | 472 if len(sys.argv) > 1: |
473 schema = Load(filename) | 473 for filename in sys.argv[1:]: |
| 474 schema = Load(filename) |
| 475 print json.dumps(schema, indent=2) |
| 476 else: |
| 477 contents = sys.stdin.read() |
| 478 idl = idl_parser.IDLParser().ParseData(contents, '<stdin>') |
| 479 schema = IDLSchema(idl).process() |
474 print json.dumps(schema, indent=2) | 480 print json.dumps(schema, indent=2) |
475 | 481 |
476 | 482 |
477 if __name__ == '__main__': | 483 if __name__ == '__main__': |
478 Main() | 484 Main() |
OLD | NEW |