| 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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 graphs = [] | 93 graphs = [] |
| 94 for (graph, (precedence, code, transition)) in v['regex']: | 94 for (graph, (precedence, code, transition)) in v['regex']: |
| 95 default_code = v['default_action'] | 95 default_code = v['default_action'] |
| 96 action = code if code else default_code | 96 action = code if code else default_code |
| 97 if action: | 97 if action: |
| 98 graph = NfaBuilder.add_action(graph, (precedence, action)) | 98 graph = NfaBuilder.add_action(graph, (precedence, action)) |
| 99 if transition == 'continue': | 99 if not transition: |
| 100 pass |
| 101 elif transition == 'continue': |
| 100 assert not k == 'default' | 102 assert not k == 'default' |
| 101 graph = NfaBuilder.add_continue(graph) | 103 graph = NfaBuilder.add_continue(graph) |
| 102 elif transition == 'break': | 104 elif transition == 'break': |
| 103 pass | 105 assert code |
| 106 graph = NfaBuilder.add_break(graph) |
| 104 elif (transition == 'terminate' or | 107 elif (transition == 'terminate' or |
| 105 transition == 'terminate_illegal'): | 108 transition == 'terminate_illegal'): |
| 106 assert not code | 109 assert not code |
| 107 graph = NfaBuilder.add_action(graph, (-1, transition)) | 110 graph = NfaBuilder.add_action(graph, (-1, transition)) |
| 108 else: | 111 else: |
| 109 assert k == 'default' | 112 assert k == 'default' |
| 110 subgraph_modifier = '*' if code else None | 113 subgraph_modifier = '*' if code else None |
| 111 graph = NfaBuilder.join_subgraph( | 114 graph = NfaBuilder.join_subgraph( |
| 112 graph, transition, rule_map[transition], subgraph_modifier) | 115 graph, transition, rule_map[transition], subgraph_modifier) |
| 113 graphs.append(graph) | 116 graphs.append(graph) |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 with open(args.html, 'w') as f: | 154 with open(args.html, 'w') as f: |
| 152 f.write(html) | 155 f.write(html) |
| 153 print "wrote html to %s" % html_file | 156 print "wrote html to %s" % html_file |
| 154 | 157 |
| 155 input_file = args.input | 158 input_file = args.input |
| 156 if input_file: | 159 if input_file: |
| 157 with open(input_file, 'r') as f: | 160 with open(input_file, 'r') as f: |
| 158 input_text = f.read() + '\0' | 161 input_text = f.read() + '\0' |
| 159 for t in generator.lex(input_text): | 162 for t in generator.lex(input_text): |
| 160 print t | 163 print t |
| OLD | NEW |