| 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 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 def escape(v): | 130 def escape(v): |
| 131 v = str(v) | 131 v = str(v) |
| 132 v = v.replace('\r', '\\\\r').replace('\t', '\\\\t').replace('\n', '\\\\n') | 132 v = v.replace('\r', '\\\\r').replace('\t', '\\\\t').replace('\n', '\\\\n') |
| 133 v = v.replace('\\', '\\\\').replace('\"', '\\\"') | 133 v = v.replace('\\', '\\\\').replace('\"', '\\\"') |
| 134 return v | 134 return v |
| 135 | 135 |
| 136 def f(node, (node_content, edge_content)): | 136 def f(node, (node_content, edge_content)): |
| 137 if node.action(): | 137 if node.action(): |
| 138 action = node.action() | 138 action = node.action() |
| 139 if action.type() == 'code': | 139 if action.type() == 'code': |
| 140 # assert action.data() | |
| 141 action_text = action.data() | 140 action_text = action.data() |
| 141 elif action.type() == 'push_token': |
| 142 action_text = "token(" + action.data() + ")" |
| 142 else: | 143 else: |
| 143 action_text = action.type() | 144 action_text = action.type() |
| 144 action_text = escape(action_text) | 145 action_text = escape(action_text) |
| 145 node_content.append(' S_l%s[shape = box, label="%s"];' % | 146 node_content.append(' S_l%s[shape = box, label="%s"];' % |
| 146 (node.node_number(), action_text)) | 147 (node.node_number(), action_text)) |
| 147 node_content.append(' S_%s -> S_l%s [arrowhead = none];' % | 148 node_content.append(' S_%s -> S_l%s [arrowhead = none];' % |
| 148 (node.node_number(), node.node_number())) | 149 (node.node_number(), node.node_number())) |
| 149 for key, state in node.key_state_iter(): | 150 for key, state in node.key_state_iter(): |
| 150 if key == TransitionKey.epsilon(): | 151 if key == TransitionKey.epsilon(): |
| 151 key = "ε" | 152 key = "ε" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 173 node [shape = doublecircle, style=unfilled]; %s | 174 node [shape = doublecircle, style=unfilled]; %s |
| 174 node [shape = circle]; | 175 node [shape = circle]; |
| 175 %s | 176 %s |
| 176 %s | 177 %s |
| 177 } | 178 } |
| 178 ''' % (start_shape, | 179 ''' % (start_shape, |
| 179 start_number, | 180 start_number, |
| 180 " ".join(terminals), | 181 " ".join(terminals), |
| 181 "\n".join(edge_content), | 182 "\n".join(edge_content), |
| 182 "\n".join(node_content)) | 183 "\n".join(node_content)) |
| OLD | NEW |