[pypy-svn] r44355 - pypy/dist/pypy/rlib/parsing

cfbolz at codespeak.net cfbolz at codespeak.net
Tue Jun 19 00:11:09 CEST 2007


Author: cfbolz
Date: Tue Jun 19 00:11:09 2007
New Revision: 44355

Modified:
   pypy/dist/pypy/rlib/parsing/tree.py
Log:
adjust the tree support a bit to allow non-tree things to appear in a tree


Modified: pypy/dist/pypy/rlib/parsing/tree.py
==============================================================================
--- pypy/dist/pypy/rlib/parsing/tree.py	(original)
+++ pypy/dist/pypy/rlib/parsing/tree.py	Tue Jun 19 00:11:09 2007
@@ -52,8 +52,13 @@
         yield '"%s" [label="%s"];' % (id(self), self.symbol)
         for child in self.children:
             yield '"%s" -> "%s";' % (id(self), id(child))
-            for line in child.dot():
-                yield line
+            if isinstance(child, Node):
+                for line in child.dot():
+                    yield line
+            else:
+                yield '"%s" [label="%s"];' % (
+                    id(child),
+                    repr(child).replace('"', '').replace("\\", "\\\\"))
 
     def visit(self, visitor):
         "NOT_RPYTHON"
@@ -86,22 +91,16 @@
             if node.symbol not in dispatch_table:
                 if __general_nonterminal_visit:
                     return __general_nonterminal_visit(self, node)
-                elif __general_visit:
-                    return __general_visit(self, node)
-                else:
-                    raise VisitError(node)
             else:
                 return dispatch_table[node.symbol](self, node)
-        if isinstance(node, Symbol):
+        elif isinstance(node, Symbol):
             if node.symbol not in dispatch_table:
                 if __general_symbol_visit:
                     return __general_symbol_visit(self, node)
-                elif __general_visit:
-                    return __general_visit(self, node)
-                else:
-                    raise VisitError(node)
             else:
                 return dispatch_table[node.symbol](self, node)
+        if __general_visit:
+            return __general_visit(self, node)
         raise VisitError(node)
     return dispatch
 



More information about the Pypy-commit mailing list