| 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 return state | 54 return state |
| 55 | 55 |
| 56 @staticmethod | 56 @staticmethod |
| 57 def generate_dot(start_node, terminal_set, edge_iterator): | 57 def generate_dot(start_node, terminal_set, edge_iterator): |
| 58 | 58 |
| 59 def escape(v): | 59 def escape(v): |
| 60 v = str(v).replace('\r', '\\\\r') | 60 v = str(v).replace('\r', '\\\\r') |
| 61 v = str(v).replace('\t', '\\\\t') | 61 v = str(v).replace('\t', '\\\\t') |
| 62 v = str(v).replace('\n', '\\\\n') | 62 v = str(v).replace('\n', '\\\\n') |
| 63 v = str(v).replace('\\', '\\\\') | 63 v = str(v).replace('\\', '\\\\') |
| 64 v = str(v).replace('\"', '\\\"') |
| 64 return v | 65 return v |
| 65 | 66 |
| 66 def f(node, node_content): | 67 def f(node, node_content): |
| 67 for key, values in node.transitions().items(): | 68 for key, values in node.transitions().items(): |
| 68 if key == TransitionKey.epsilon(): | 69 if key == TransitionKey.epsilon(): |
| 69 key = "ε" | 70 key = "ε" |
| 70 # TODO pass this action as parameter | 71 # TODO pass this action as parameter |
| 71 if type(values) == TupleType: | 72 if type(values) == TupleType: |
| 72 values = [values] | 73 values = [values] |
| 73 for (state, action) in values: | 74 for (state, action) in values: |
| (...skipping 22 matching lines...) Expand all Loading... |
| 96 rankdir=LR; | 97 rankdir=LR; |
| 97 node [shape = %s, style=filled, bgcolor=lightgrey]; S_%s | 98 node [shape = %s, style=filled, bgcolor=lightgrey]; S_%s |
| 98 node [shape = doublecircle, style=unfilled]; %s | 99 node [shape = doublecircle, style=unfilled]; %s |
| 99 node [shape = circle]; | 100 node [shape = circle]; |
| 100 %s | 101 %s |
| 101 } | 102 } |
| 102 ''' % (start_shape, | 103 ''' % (start_shape, |
| 103 start_number, | 104 start_number, |
| 104 " ".join(terminals), | 105 " ".join(terminals), |
| 105 "\n".join(node_content)) | 106 "\n".join(node_content)) |
| OLD | NEW |