| 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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 //fprintf(stderr, "char at hand is %c (%d)\\n", yych, yych);\n''' | 81 //fprintf(stderr, "char at hand is %c (%d)\\n", yych, yych);\n''' |
| 82 | 82 |
| 83 for key, s in state.transitions().items(): | 83 for key, s in state.transitions().items(): |
| 84 code += CodeGenerator.key_to_code(key) | 84 code += CodeGenerator.key_to_code(key) |
| 85 code += ''' { | 85 code += ''' { |
| 86 goto code_%s; | 86 goto code_%s; |
| 87 } | 87 } |
| 88 ''' % s.node_number() | 88 ''' % s.node_number() |
| 89 | 89 |
| 90 if action: | 90 if action: |
| 91 code += '%s\nBACK();\ngoto code_%s;\n' % (action.data(), | 91 if action.type() == 'code': |
| 92 start_node_number) | 92 code += '%s\nBACK();\ngoto code_%s;\n' % (action.data(), |
| 93 start_node_number) |
| 94 elif action.type() == 'push_token': |
| 95 #TODO |
| 96 pass |
| 97 else: |
| 98 raise Exception("unknown type %s" % action.type()) |
| 93 else: | 99 else: |
| 94 code += 'goto default_action;' | 100 code += 'goto default_action;' |
| 95 return code | 101 return code |
| 96 | 102 |
| 97 @staticmethod | 103 @staticmethod |
| 98 def rule_processor_to_code(rule_processor, use_mdfa): | 104 def rule_processor_to_code(rule_processor, use_mdfa): |
| 99 if use_mdfa: | 105 if use_mdfa: |
| 100 dfa = rule_processor.default_automata().minimal_dfa() | 106 dfa = rule_processor.default_automata().minimal_dfa() |
| 101 else: | 107 else: |
| 102 dfa = rule_processor.default_automata().dfa() | 108 dfa = rule_processor.default_automata().dfa() |
| (...skipping 17 matching lines...) Expand all Loading... |
| 120 //fprintf(stderr, "default action\\n"); | 126 //fprintf(stderr, "default action\\n"); |
| 121 %s | 127 %s |
| 122 goto code_%s; | 128 goto code_%s; |
| 123 return 0; | 129 return 0; |
| 124 } | 130 } |
| 125 | 131 |
| 126 } | 132 } |
| 127 } | 133 } |
| 128 ''' % (rule_processor.default_action, start_node_number) | 134 ''' % (rule_processor.default_action, start_node_number) |
| 129 return code | 135 return code |
| OLD | NEW |