[Python-checkins] python/nondist/sandbox/ast asdl_java.py,1.6,1.7

pedronis at users.sourceforge.net pedronis at users.sourceforge.net
Mon Aug 25 06:33:32 EDT 2003


Update of /cvsroot/python/python/nondist/sandbox/ast
In directory sc8-pr-cvs1:/tmp/cvs-serv3252

Modified Files:
	asdl_java.py 
Log Message:
minor tweaks. enable patch for using Jython parser outside of Jython: 
    PyObject -> java.lang.Object
Finer control over emitted java import statements, avoids spurious warnings
e.g. in Eclipse.


Index: asdl_java.py
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/ast/asdl_java.py,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** asdl_java.py	30 May 2002 16:59:56 -0000	1.6
--- asdl_java.py	25 Aug 2003 12:33:30 -0000	1.7
***************
*** 50,60 ****
          super(EmitVisitor, self).__init__()
  
!     def open(self, name):
!         self.file = open("%s.java" % name, "wb")
          print >> self.file, "// Autogenerated AST node"
          print >> self.file, 'package org.python.parser.ast;'
!         print >> self.file, 'import org.python.parser.SimpleNode;'
!         print >> self.file, 'import java.io.DataOutputStream;'
!         print >> self.file, 'import java.io.IOException;'
          print >> self.file
      
--- 50,62 ----
          super(EmitVisitor, self).__init__()
  
!     def open(self, name, refersToSimpleNode=1, useDataOutput=0):
!         self.file = open("%s.java" % name, "w")
          print >> self.file, "// Autogenerated AST node"
          print >> self.file, 'package org.python.parser.ast;'
!         if refersToSimpleNode:
!             print >> self.file, 'import org.python.parser.SimpleNode;'
!         if useDataOutput:
!             print >> self.file, 'import java.io.DataOutputStream;'
!             print >> self.file, 'import java.io.IOException;'
          print >> self.file
      
***************
*** 134,138 ****
  
      def simple_sum(self, sum, name, depth):
!         self.open("%sType" % name)
          self.emit("public interface %(name)sType {" % locals(), depth)
          for i in range(len(sum.types)):
--- 136,140 ----
  
      def simple_sum(self, sum, name, depth):
!         self.open("%sType" % name, refersToSimpleNode=0)
          self.emit("public interface %(name)sType {" % locals(), depth)
          for i in range(len(sum.types)):
***************
*** 160,164 ****
  
      def visitProduct(self, product, name, depth):
!         self.open("%sType" % name)
          self.emit("public class %(name)sType extends SimpleNode {" % locals(), depth)
          for f in product.fields:
--- 162,166 ----
  
      def visitProduct(self, product, name, depth):
!         self.open("%sType" % name, useDataOutput=1)
          self.emit("public class %(name)sType extends SimpleNode {" % locals(), depth)
          for f in product.fields:
***************
*** 173,177 ****
  
      def visitConstructor(self, cons, name, depth):
!         self.open(cons.name)
          enums = []
          for f in cons.fields:
--- 175,179 ----
  
      def visitConstructor(self, cons, name, depth):
!         self.open(cons.name, useDataOutput=1)
          enums = []
          for f in cons.fields:
***************
*** 277,281 ****
          'identifier' : 'String',
          'string' : 'String',
!         'object' : 'org.python.core.PyObject',
      }
  
--- 279,283 ----
          'identifier' : 'String',
          'string' : 'String',
!         'object' : 'Object', # was PyObject
      }
  
***************
*** 300,304 ****
          for dfn in mod.dfns:
              self.visit(dfn)
!         self.open("VisitorIF")
          self.emit('public interface VisitorIF {', 0)
          for ctor in self.ctors:
--- 302,306 ----
          for dfn in mod.dfns:
              self.visit(dfn)
!         self.open("VisitorIF", refersToSimpleNode=0)
          self.emit('public interface VisitorIF {', 0)
          for ctor in self.ctors:





More information about the Python-checkins mailing list