| OLD | NEW |
| 1 # Copyright 2013 the V8 project authors. All rights reserved. | 1 # Copyright 2013 the V8 project authors. All rights reserved. |
| 2 # Redistribution and use in source and binary forms, with or without | 2 # Redistribution and use in source and binary forms, with or without |
| 3 # modification, are permitted provided that the following conditions are | 3 # modification, are permitted provided that the following conditions are |
| 4 # met: | 4 # met: |
| 5 # | 5 # |
| 6 # * Redistributions of source code must retain the above copyright | 6 # * Redistributions of source code must retain the above copyright |
| 7 # notice, this list of conditions and the following disclaimer. | 7 # notice, this list of conditions and the following disclaimer. |
| 8 # * Redistributions in binary form must reproduce the above | 8 # * Redistributions in binary form must reproduce the above |
| 9 # copyright notice, this list of conditions and the following | 9 # copyright notice, this list of conditions and the following |
| 10 # disclaimer in the documentation and/or other materials provided | 10 # disclaimer in the documentation and/or other materials provided |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 args = parser.parse_args() | 102 args = parser.parse_args() |
| 103 | 103 |
| 104 re_file = args.re | 104 re_file = args.re |
| 105 print "parsing %s" % re_file | 105 print "parsing %s" % re_file |
| 106 with open(re_file, 'r') as f: | 106 with open(re_file, 'r') as f: |
| 107 rule_processor = RuleProcessor.parse(f.read()) | 107 rule_processor = RuleProcessor.parse(f.read()) |
| 108 | 108 |
| 109 if args.minimize_default: | 109 if args.minimize_default: |
| 110 if args.no_verify_default: | 110 if args.no_verify_default: |
| 111 DfaMinimizer.set_verify(False) | 111 DfaMinimizer.set_verify(False) |
| 112 rule_processor.default_automata().minimal_dfa() | 112 dfa = rule_processor.default_automata().dfa() |
| 113 mdfa = rule_processor.default_automata().minimal_dfa() |
| 114 print "nodes reduced from %s to %s" % (dfa.node_count(), mdfa.node_count()) |
| 113 DfaMinimizer.set_verify(True) | 115 DfaMinimizer.set_verify(True) |
| 114 | 116 |
| 115 html_file = args.html | 117 html_file = args.html |
| 116 if html_file: | 118 if html_file: |
| 117 html = generate_html(rule_processor, args.minimize_default) | 119 html = generate_html(rule_processor, args.minimize_default) |
| 118 with open(args.html, 'w') as f: | 120 with open(args.html, 'w') as f: |
| 119 f.write(html) | 121 f.write(html) |
| 120 print "wrote html to %s" % html_file | 122 print "wrote html to %s" % html_file |
| 121 | 123 |
| 122 code_file = args.code | 124 code_file = args.code |
| 123 if code_file: | 125 if code_file: |
| 124 code = generate_code(rule_processor, args.minimize_default) | 126 code = generate_code(rule_processor, args.minimize_default) |
| 125 with open(code_file, 'w') as f: | 127 with open(code_file, 'w') as f: |
| 126 f.write(code) | 128 f.write(code) |
| 127 print "wrote code to %s" % code_file | 129 print "wrote code to %s" % code_file |
| 128 | 130 |
| 129 input_file = args.input | 131 input_file = args.input |
| 130 if input_file: | 132 if input_file: |
| 131 with open(input_file, 'r') as f: | 133 with open(input_file, 'r') as f: |
| 132 lex(rule_processor, f.read()) | 134 lex(rule_processor, f.read()) |
| OLD | NEW |