| 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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 loads = [] | 75 loads = [] |
| 76 for i, name in enumerate(self.__automata): | 76 for i, name in enumerate(self.__automata): |
| 77 (nfa, dfa) = self.__automata[name] | 77 (nfa, dfa) = self.__automata[name] |
| 78 if name == 'Normal': continue | 78 if name == 'Normal': continue |
| 79 (nfa_i, dfa_i) = ("nfa_%d" % i, "dfa_%d" % i) | 79 (nfa_i, dfa_i) = ("nfa_%d" % i, "dfa_%d" % i) |
| 80 scripts.append(script_template % (nfa_i, nfa.to_dot())) | 80 scripts.append(script_template % (nfa_i, nfa.to_dot())) |
| 81 scripts.append(script_template % (dfa_i, dfa.to_dot())) | 81 scripts.append(script_template % (dfa_i, dfa.to_dot())) |
| 82 loads.append(load_template % ("nfa [%s]" % name, nfa_i)) | 82 loads.append(load_template % ("nfa [%s]" % name, nfa_i)) |
| 83 loads.append(load_template % ("dfa [%s]" % name, dfa_i)) | 83 loads.append(load_template % ("dfa [%s]" % name, dfa_i)) |
| 84 body = "\n".join(scripts) + (load_outer_template % "\n".join(loads)) | 84 body = "\n".join(scripts) + (load_outer_template % "\n".join(loads)) |
| 85 return file_template % body | 85 return file_template % body |
| 86 | 86 |
| 87 def process_rules(self, parser_state): | 87 def process_rules(self, parser_state): |
| 88 rule_map = {} | 88 rule_map = {} |
| 89 builder = NfaBuilder() | 89 builder = NfaBuilder() |
| 90 builder.set_character_classes(parser_state.character_classes) | 90 builder.set_character_classes(parser_state.character_classes) |
| 91 assert 'default' in parser_state.rules | 91 assert 'default' in parser_state.rules |
| 92 def process(k, v): | 92 def process(k, v): |
| 93 assert 'default' in v | 93 assert 'default' in v |
| 94 graphs = [] | 94 graphs = [] |
| 95 for (graph, action) in v['regex']: | 95 for (graph, action) in v['regex']: |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 with open(args.html, 'w') as f: | 169 with open(args.html, 'w') as f: |
| 170 f.write(html) | 170 f.write(html) |
| 171 print "wrote html to %s" % html_file | 171 print "wrote html to %s" % html_file |
| 172 | 172 |
| 173 input_file = args.input | 173 input_file = args.input |
| 174 if input_file: | 174 if input_file: |
| 175 with open(input_file, 'r') as f: | 175 with open(input_file, 'r') as f: |
| 176 input_text = f.read() + '\0' | 176 input_text = f.read() + '\0' |
| 177 for t in generator.lex(input_text): | 177 for t in generator.lex(input_text): |
| 178 print t | 178 print t |
| OLD | NEW |