You can subscribe to this list here.
2000 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(1) |
Nov
(107) |
Dec
(67) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2001 |
Jan
(76) |
Feb
(125) |
Mar
(72) |
Apr
(13) |
May
(18) |
Jun
(12) |
Jul
(129) |
Aug
(47) |
Sep
(1) |
Oct
(36) |
Nov
(128) |
Dec
(124) |
2002 |
Jan
(59) |
Feb
|
Mar
(14) |
Apr
(14) |
May
(72) |
Jun
(9) |
Jul
(3) |
Aug
(5) |
Sep
(18) |
Oct
(65) |
Nov
(28) |
Dec
(12) |
2003 |
Jan
(10) |
Feb
(2) |
Mar
(4) |
Apr
(33) |
May
(21) |
Jun
(9) |
Jul
(29) |
Aug
(34) |
Sep
(4) |
Oct
(8) |
Nov
(15) |
Dec
(4) |
2004 |
Jan
(26) |
Feb
(12) |
Mar
(11) |
Apr
(9) |
May
(7) |
Jun
|
Jul
(5) |
Aug
|
Sep
(3) |
Oct
(7) |
Nov
(1) |
Dec
(10) |
2005 |
Jan
(2) |
Feb
(72) |
Mar
(16) |
Apr
(39) |
May
(48) |
Jun
(97) |
Jul
(57) |
Aug
(13) |
Sep
(16) |
Oct
(24) |
Nov
(100) |
Dec
(24) |
2006 |
Jan
(15) |
Feb
(34) |
Mar
(33) |
Apr
(31) |
May
(79) |
Jun
(64) |
Jul
(41) |
Aug
(64) |
Sep
(31) |
Oct
(46) |
Nov
(55) |
Dec
(37) |
2007 |
Jan
(32) |
Feb
(61) |
Mar
(11) |
Apr
(58) |
May
(46) |
Jun
(30) |
Jul
(94) |
Aug
(93) |
Sep
(86) |
Oct
(69) |
Nov
(125) |
Dec
(177) |
2008 |
Jan
(169) |
Feb
(97) |
Mar
(74) |
Apr
(113) |
May
(120) |
Jun
(334) |
Jul
(215) |
Aug
(237) |
Sep
(72) |
Oct
(189) |
Nov
(126) |
Dec
(160) |
2009 |
Jan
(180) |
Feb
(45) |
Mar
(98) |
Apr
(140) |
May
(151) |
Jun
(71) |
Jul
(107) |
Aug
(119) |
Sep
(73) |
Oct
(121) |
Nov
(14) |
Dec
(6) |
2010 |
Jan
(13) |
Feb
(9) |
Mar
(10) |
Apr
(64) |
May
(3) |
Jun
(16) |
Jul
(7) |
Aug
(23) |
Sep
(17) |
Oct
(37) |
Nov
(5) |
Dec
(8) |
2011 |
Jan
(10) |
Feb
(11) |
Mar
(77) |
Apr
(11) |
May
(2) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Finn B. <bc...@us...> - 2002-05-30 20:22:38
|
Update of /cvsroot/jython/jython/org/python/modules/sre In directory usw-pr-cvs1:/tmp/cvs-serv12374 Modified Files: SRE_STATE.java Log Message: Fix for "[ 545235 ] unexpected match with re" Index: SRE_STATE.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/modules/sre/SRE_STATE.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** SRE_STATE.java 6 Jan 2002 15:53:25 -0000 1.8 --- SRE_STATE.java 30 May 2002 20:22:32 -0000 1.9 *************** *** 418,422 **** case SRE_OP_NOT_LITERAL_IGNORE: /* repeated non-literal */ ! chr = pattern[1]; //TRACE(pidx, ptr, "COUNT NOT_LITERAL_IGNORE " + (int) chr); while (ptr < end && lower(str[ptr]) != chr) --- 418,422 ---- case SRE_OP_NOT_LITERAL_IGNORE: /* repeated non-literal */ ! chr = pattern[pidx+1]; //TRACE(pidx, ptr, "COUNT NOT_LITERAL_IGNORE " + (int) chr); while (ptr < end && lower(str[ptr]) != chr) |
From: Finn B. <bc...@us...> - 2002-05-30 19:52:26
|
Update of /cvsroot/jython/bugtests In directory usw-pr-cvs1:/tmp/cvs-serv24230 Added Files: test362.py Log Message: Test for "[ 545235 ] unexpected match with re" --- NEW FILE: test362.py --- """ [ 545235 ] unexpected match with re """ import support import re rt = re.compile(r'c[^a]*t', re.IGNORECASE) if rt.match("cat") is not None: raise support.TestError('Should not match #1') rs = re.compile(r'c[^a]t', re.IGNORECASE) if rs.match('cat') is not None: raise support.TestError('Should not match #2') |
From: Finn B. <bc...@us...> - 2002-05-30 19:46:30
|
Update of /cvsroot/jython/bugtests In directory usw-pr-cvs1:/tmp/cvs-serv19482 Added Files: test361.py Log Message: Test for "[ 551888 ] Opening utf-8 files with codecs fails" --- NEW FILE: test361.py --- """ Test for [ 551888 ] Opening utf-8 files with codecs fails """ import support f = open("test361.out", "w") f.write("hello") f.close() import codecs f = codecs.open("test361.out", "r", "utf-8") print f.read() f.close() |
From: Finn B. <bc...@us...> - 2002-05-30 19:36:23
|
Update of /cvsroot/jython/jython/org/python/core In directory usw-pr-cvs1:/tmp/cvs-serv11721 Modified Files: PyDictionary.java PyStringMap.java Log Message: Fix for "[ 532747 ] for i in iter(d)". Adding a __iter__ method to the iterators. Index: PyDictionary.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/core/PyDictionary.java,v retrieving revision 2.18 retrieving revision 2.19 diff -C2 -d -r2.18 -r2.19 *** PyDictionary.java 6 Jan 2002 21:19:13 -0000 2.18 --- PyDictionary.java 30 May 2002 19:36:21 -0000 2.19 *************** *** 421,424 **** --- 421,432 ---- } + public PyObject __iter__() { + return this; + } + + public PyObject next() { + return __iternext__(); + } + public PyObject __iternext__() { if (!enumeration.hasMoreElements()) Index: PyStringMap.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/core/PyStringMap.java,v retrieving revision 2.13 retrieving revision 2.14 diff -C2 -d -r2.13 -r2.14 *** PyStringMap.java 6 Jan 2002 21:19:13 -0000 2.13 --- PyStringMap.java 30 May 2002 19:36:21 -0000 2.14 *************** *** 558,561 **** --- 558,569 ---- } + public PyObject __iter__() { + return this; + } + + public PyObject next() { + return __iternext__(); + } + public PyObject __iternext__() { int n = keyTable.length; |
From: Finn B. <bc...@us...> - 2002-05-30 19:34:27
|
Update of /cvsroot/jython/bugtests In directory usw-pr-cvs1:/tmp/cvs-serv10439 Modified Files: driver.py Log Message: Updated range to 370. Index: driver.py =================================================================== RCS file: /cvsroot/jython/bugtests/driver.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** driver.py 20 Dec 2001 16:41:42 -0000 1.7 --- driver.py 30 May 2002 19:34:22 -0000 1.8 *************** *** 17,21 **** warnings = "-w" in opts ! for i in range(360): m = None n = "test%3.3d" % i --- 17,21 ---- warnings = "-w" in opts ! for i in range(370): m = None n = "test%3.3d" % i |
From: Finn B. <bc...@us...> - 2002-05-30 19:30:46
|
Update of /cvsroot/jython/bugtests In directory usw-pr-cvs1:/tmp/cvs-serv7289 Added Files: test360.py Log Message: Test for "[ 532747 ] for i in iter(d)". --- NEW FILE: test360.py --- """ [ 532747 ] for i in iter(d) """ import support d = {1:2,3:4} l = [] for i in iter(d): l.append(i) |
From: Finn B. <bc...@us...> - 2002-05-30 19:25:40
|
Update of /cvsroot/jython/bugtests In directory usw-pr-cvs1:/tmp/cvs-serv3522 Modified Files: test109.py test110.py Log Message: Iteration and 'in' in dicts now works. Index: test109.py =================================================================== RCS file: /cvsroot/jython/bugtests/test109.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** test109.py 14 Jul 2001 18:17:28 -0000 1.1 --- test109.py 30 May 2002 19:25:35 -0000 1.2 *************** *** 5,14 **** import support ! try: ! for x in {3:'d', 2:'c', 1:'b', 0:'a'}: ! print x, ! except TypeError, e: ! pass ! else: ! raise support.TestError("Looping over dict should fail") --- 5,13 ---- import support + L = [] ! for x in {3:'d', 2:'c', 1:'b', 0:'a'}: ! L.append(x) ! L.sort() ! if L != [0, 1, 2, 3]: ! support.TestError("Looping over dict should work") Index: test110.py =================================================================== RCS file: /cvsroot/jython/bugtests/test110.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** test110.py 14 Jul 2001 18:17:28 -0000 1.1 --- test110.py 30 May 2002 19:25:35 -0000 1.2 *************** *** 5,12 **** import support ! try: ! print 1 in {2:2, 3:3} ! except TypeError, e: ! pass ! else: ! raise support.TestError("in keyword an a dict should fail") --- 5,10 ---- import support ! if 1 in {2:2, 3:3}: ! raise support.TestError("in keyword an a dict should work") ! if 2 not in {2:2, 3:3}: ! raise support.TestError("in keyword an a dict should work") |
From: Finn B. <bc...@us...> - 2002-05-30 19:20:31
|
Update of /cvsroot/jython/jython/org/python/core In directory usw-pr-cvs1:/tmp/cvs-serv31090/org/python/core Modified Files: Py.java imp.java Log Message: Renamed 'assert' to 'assert_' because it is a 1.4 reserved word. Index: Py.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/core/Py.java,v retrieving revision 2.66 retrieving revision 2.67 diff -C2 -d -r2.66 -r2.67 *** Py.java 30 May 2002 16:15:14 -0000 2.66 --- Py.java 30 May 2002 19:20:29 -0000 2.67 *************** *** 1008,1012 **** /* Equivalent to Python's assert statement */ ! public static void assert(PyObject test, PyObject message) { if (!test.__nonzero__()) { throw new PyException(Py.AssertionError, message); --- 1008,1012 ---- /* Equivalent to Python's assert statement */ ! public static void assert_(PyObject test, PyObject message) { if (!test.__nonzero__()) { throw new PyException(Py.AssertionError, message); *************** *** 1014,1019 **** } ! public static void assert(PyObject test) { ! assert(test, Py.None); } --- 1014,1019 ---- } ! public static void assert_(PyObject test) { ! assert_(test, Py.None); } Index: imp.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/core/imp.java,v retrieving revision 2.62 retrieving revision 2.63 diff -C2 -d -r2.62 -r2.63 *** imp.java 30 May 2002 16:15:14 -0000 2.62 --- imp.java 30 May 2002 19:20:29 -0000 2.63 *************** *** 13,17 **** public class imp { ! public static final int APIVersion = 11; private imp() { ; } --- 13,17 ---- public class imp { ! public static final int APIVersion = 12; private imp() { ; } |
From: Finn B. <bc...@us...> - 2002-05-30 19:20:31
|
Update of /cvsroot/jython/jython/org/python/compiler In directory usw-pr-cvs1:/tmp/cvs-serv31090/org/python/compiler Modified Files: CodeCompiler.java Log Message: Renamed 'assert' to 'assert_' because it is a 1.4 reserved word. Index: CodeCompiler.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/compiler/CodeCompiler.java,v retrieving revision 2.26 retrieving revision 2.27 diff -C2 -d -r2.26 -r2.27 *** CodeCompiler.java 30 May 2002 16:13:29 -0000 2.26 --- CodeCompiler.java 30 May 2002 19:20:28 -0000 2.27 *************** *** 722,726 **** if (mrefs.assert2 == 0) { mrefs.assert2 = code.pool.Methodref( ! "org/python/core/Py", "assert", "(" + $pyObj + $pyObj + ")V"); } --- 722,726 ---- if (mrefs.assert2 == 0) { mrefs.assert2 = code.pool.Methodref( ! "org/python/core/Py", "assert_", "(" + $pyObj + $pyObj + ")V"); } *************** *** 729,733 **** if (mrefs.assert1 == 0) { mrefs.assert1 = code.pool.Methodref( ! "org/python/core/Py", "assert", "(" + $pyObj + ")V"); } --- 729,733 ---- if (mrefs.assert1 == 0) { mrefs.assert1 = code.pool.Methodref( ! "org/python/core/Py", "assert_", "(" + $pyObj + ")V"); } |
From: Finn B. <bc...@us...> - 2002-05-30 19:20:31
|
Update of /cvsroot/jython/jython/com/ziclix/python/sql/pipe In directory usw-pr-cvs1:/tmp/cvs-serv31090/com/ziclix/python/sql/pipe Modified Files: Pipe.java Log Message: Renamed 'assert' to 'assert_' because it is a 1.4 reserved word. Index: Pipe.java =================================================================== RCS file: /cvsroot/jython/jython/com/ziclix/python/sql/pipe/Pipe.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Pipe.java 11 Jan 2002 21:46:01 -0000 1.2 --- Pipe.java 30 May 2002 19:20:28 -0000 1.3 *************** *** 94,98 **** String msg = zxJDBC.getString("inconsistentRowCount", counts); ! Py.assert(Py.Zero, Py.newString(msg)); } --- 94,98 ---- String msg = zxJDBC.getString("inconsistentRowCount", counts); ! Py.assert_(Py.Zero, Py.newString(msg)); } |
From: Finn B. <bc...@us...> - 2002-05-30 19:20:31
|
Update of /cvsroot/jython/jython/Tools/jythonc In directory usw-pr-cvs1:/tmp/cvs-serv31090/Tools/jythonc Modified Files: SrcGenCompiler.py Log Message: Renamed 'assert' to 'assert_' because it is a 1.4 reserved word. Index: SrcGenCompiler.py =================================================================== RCS file: /cvsroot/jython/jython/Tools/jythonc/SrcGenCompiler.py,v retrieving revision 2.1 retrieving revision 2.2 diff -C2 -d -r2.1 -r2.2 *** SrcGenCompiler.py 30 May 2002 16:20:13 -0000 2.1 --- SrcGenCompiler.py 30 May 2002 19:20:28 -0000 2.2 *************** *** 896,900 **** return jast.If(self.frame.getglobal("__debug__").nonzero(), ! jast.InvokeStatic("Py", "assert", args)) def visitReturn(self, node): --- 896,900 ---- return jast.If(self.frame.getglobal("__debug__").nonzero(), ! jast.InvokeStatic("Py", "assert_", args)) def visitReturn(self, node): |
From: Finn B. <bc...@us...> - 2002-05-30 19:20:31
|
Update of /cvsroot/jython/jython In directory usw-pr-cvs1:/tmp/cvs-serv31090 Modified Files: NEWS Log Message: Renamed 'assert' to 'assert_' because it is a 1.4 reserved word. Index: NEWS =================================================================== RCS file: /cvsroot/jython/jython/NEWS,v retrieving revision 2.46 retrieving revision 2.47 diff -C2 -d -r2.46 -r2.47 *** NEWS 13 Jan 2002 19:32:27 -0000 2.46 --- NEWS 30 May 2002 19:20:28 -0000 2.47 *************** *** 6,11 **** --- 6,13 ---- - Iterators (pep-234). - Changing the Division Operator (pep-238) + - Implemented a new compiler AST. Bug fixes. + - Renamed the use of the java1.4 reserved words 'assert'. 31-dec-2001 Jython 2.1 final |
From: Finn B. <bc...@us...> - 2002-05-30 19:19:25
|
Update of /cvsroot/jython/bugtests In directory usw-pr-cvs1:/tmp/cvs-serv30783 Added Files: test356.py Log Message: Test for [ 522828 ] struct.pack('>NNs', v) fails for NN > 20 --- NEW FILE: test356.py --- """ [ 522828 ] struct.pack('>NNs', v) fails for NN > 20 """ import support import struct a = 'abcd' * 8 struct.pack('>32s', a) |
From: Finn B. <bc...@us...> - 2002-05-30 16:55:59
|
Update of /cvsroot/jython/jython/Tools/jythonc In directory usw-pr-cvs1:/tmp/cvs-serv30537 Removed Files: BaseEvaluator.py PythonInterpreter.py PythonVisitor.py SimpleCompiler.py Log Message: File no longer needed when using the new AST. --- BaseEvaluator.py DELETED --- --- PythonInterpreter.py DELETED --- --- PythonVisitor.py DELETED --- --- SimpleCompiler.py DELETED --- |
From: Finn B. <bc...@us...> - 2002-05-30 16:21:42
|
Update of /cvsroot/jython/jython/Tools/jythonc In directory usw-pr-cvs1:/tmp/cvs-serv29907 Modified Files: ImportName.py Log Message: Removed reference to SimpleCompiler. Index: ImportName.py =================================================================== RCS file: /cvsroot/jython/jython/Tools/jythonc/ImportName.py,v retrieving revision 2.6 retrieving revision 2.7 diff -C2 -d -r2.6 -r2.7 *** ImportName.py 26 Nov 2001 15:21:08 -0000 2.6 --- ImportName.py 30 May 2002 16:21:38 -0000 2.7 *************** *** 181,185 **** import sys print sys.path ! print importName("pawt.colors"), importName("SimpleCompiler"), \ importName("pawt") print importName("os.path") --- 181,185 ---- import sys print sys.path ! print importName("pawt.colors"), importName("SrcGenCompiler"), \ importName("pawt") print importName("os.path") |
From: Finn B. <bc...@us...> - 2002-05-30 16:20:16
|
Update of /cvsroot/jython/jython/Tools/jythonc/jast In directory usw-pr-cvs1:/tmp/cvs-serv28538/jast Modified Files: Statement.py Log Message: Implementation of the new AST tree. Index: Statement.py =================================================================== RCS file: /cvsroot/jython/jython/Tools/jythonc/jast/Statement.py,v retrieving revision 2.6 retrieving revision 2.7 diff -C2 -d -r2.6 -r2.7 *** Statement.py 26 Nov 2001 15:21:09 -0000 2.6 --- Statement.py 30 May 2002 16:20:13 -0000 2.7 *************** *** 141,145 **** out.writeln("/* %s", lines[0]) for line in lines[1:-1]: ! out.writeln(line) out.writeln("%s */", lines[-1]) --- 141,145 ---- out.writeln("/* %s", lines[0]) for line in lines[1:-1]: ! out.writeln(line.replace("\\", "\\\\")) out.writeln("%s */", lines[-1]) |
From: Finn B. <bc...@us...> - 2002-05-30 16:20:16
|
Update of /cvsroot/jython/jython/Tools/jythonc In directory usw-pr-cvs1:/tmp/cvs-serv28538 Modified Files: Object.py ObjectFactory.py PythonModule.py compile.py Added Files: SrcGenCompiler.py Log Message: Implementation of the new AST tree. --- NEW FILE: SrcGenCompiler.py --- # Copyright (c) Corporation for National Research Initiatives import jast import ImportName COMMASPACE = ', ' from org.python.compiler import ScopesCompiler, Future, CompilationContext from org.python.compiler.ScopeConstants import * from org.python.parser import ast import warnings from org.python.parser import ParseException, Visitor def getDocString(suite): if len(suite) > 0: n = suite[0] if isinstance(n, ast.Expr) and isinstance(n.value, ast.Str): return n.value.s [...1046 lines suppressed...] def addSetAttribute(self, obj, name, value): #print ' add set attribute', name, value self.module.addAttribute(name, value) def setline(self, node): self.lineno = node.beginLine def execstring(self, data): self.data = data from org.python.core import parser node = parser.parse(data, 'exec') return self.parse(node) def unhandled_node(self, node): raise Exception("Unhandled node " + str(node)) #def open_level(self, node): # print "open", node #def close_level(self, node): # print "close", node Index: Object.py =================================================================== RCS file: /cvsroot/jython/jython/Tools/jythonc/Object.py,v retrieving revision 2.6 retrieving revision 2.7 diff -C2 -d -r2.6 -r2.7 *** Object.py 26 Nov 2001 15:21:08 -0000 2.6 --- Object.py 30 May 2002 16:20:13 -0000 2.7 *************** *** 24,28 **** findType(java.lang.Class.forName("[Ljava.lang.String;"))) - class DelegateMethod: --- 24,27 ---- *************** *** 164,175 **** def unop(self, code, op): ! return self.domethod(code, '__'+op+'__') def compop(self, code, op, y): ! return self.domethod(code, "_"+op, y) binop = compop ! def aug_binop(self, code, op, y): return self.domethod(code, op, y) --- 163,174 ---- def unop(self, code, op): ! return self.domethod(code, op) def compop(self, code, op, y): ! return self.domethod(code, op, y) binop = compop ! def augbinop(self, code, op, y): return self.domethod(code, op, y) Index: ObjectFactory.py =================================================================== RCS file: /cvsroot/jython/jython/Tools/jythonc/ObjectFactory.py,v retrieving revision 2.13 retrieving revision 2.14 diff -C2 -d -r2.13 -r2.14 *** ObjectFactory.py 7 Dec 2001 12:58:17 -0000 2.13 --- ObjectFactory.py 30 May 2002 16:20:13 -0000 2.14 *************** *** 3,7 **** import org, java from Object import Object, PyObject, Generic ! --- 3,7 ---- import org, java from Object import Object, PyObject, Generic ! from org.python.parser import ast *************** *** 18,22 **** return jast.FilledArray("PyObject", aargs) ! import SimpleCompiler --- 18,22 ---- return jast.FilledArray("PyObject", aargs) ! import SrcGenCompiler *************** *** 100,103 **** --- 100,106 ---- return Object(jast.Null, Generic) + def makePyNone(self): + return Object(jast.GetStaticAttribute("Py", "None"), Generic) + def makeSlice(self, items): code = jast.New("PySlice", *************** *** 106,110 **** def getCompiler(self, parent_compiler, frameCtr, scope, className): ! return SimpleCompiler.SimpleCompiler(self.parent.module, self, parent = parent_compiler, frameCtr = frameCtr, --- 109,113 ---- def getCompiler(self, parent_compiler, frameCtr, scope, className): ! return SrcGenCompiler.SrcGenCompiler(self.parent.module, self, parent = parent_compiler, frameCtr = frameCtr, *************** *** 141,145 **** "f_globals") pycode = self.makeCode() ! defaults = [ d.visit(self.def_compiler.visitor) for d in self.scope.ac.defaults ] clos = self.def_compiler.frame.makeClosure(self.scope) ctrargs = [globals, PyObjectArray(defaults), pycode] --- 144,148 ---- "f_globals") pycode = self.makeCode() ! defaults = [ self.def_compiler.visit(d) for d in self.scope.ac.defaults ] clos = self.def_compiler.frame.makeClosure(self.scope) ctrargs = [globals, PyObjectArray(defaults), pycode] *************** *** 152,163 **** ac = self.scope.ac # Parse the body ! comp = self.factory.getCompiler(self.def_compiler,SimpleCompiler.FunctionFrame,self.scope, self.def_compiler.className) for argname in ac.names: comp.frame.setname(argname, self.factory.makePyObject(None)) ! tree = self.body ! if ac.init_code.numChildren > 0: ! ac.init_code.jjtAddChild(tree, ac.init_code.numChildren) ! tree = ac.init_code code = jast.Block([comp.parse(tree)]) # Set up a code object --- 155,166 ---- ac = self.scope.ac # Parse the body ! comp = self.factory.getCompiler(self.def_compiler, ! SrcGenCompiler.FunctionFrame, self.scope, ! self.def_compiler.className) for argname in ac.names: comp.frame.setname(argname, self.factory.makePyObject(None)) ! tree = ast.Suite(self.body) ! ac.appendInitCode(tree) code = jast.Block([comp.parse(tree)]) # Set up a code object *************** *** 267,273 **** def makeCode(self): comp = self.factory.getCompiler(self.def_compiler, ! SimpleCompiler.ClassFrame, self.scope, self.name) ! code = jast.Block([comp.parse(self.body), jast.Return(jast.Invoke(comp.frame.frame, "getf_locals", []))]) --- 270,276 ---- def makeCode(self): comp = self.factory.getCompiler(self.def_compiler, ! SrcGenCompiler.ClassFrame, self.scope, self.name) ! code = jast.Block([comp.parse(ast.Suite(self.body)), jast.Return(jast.Invoke(comp.frame.frame, "getf_locals", []))]) *************** *** 322,328 **** if __name__ == '__main__': ! mod = SimpleCompiler.BasicModule("foo") fact = ObjectFactory() ! pi = SimpleCompiler.SimpleCompiler(mod, fact) fact.parent = pi code = jast.Block(pi.execstring(data)) --- 325,331 ---- if __name__ == '__main__': ! mod = SrcGenCompiler.BasicModule("foo") fact = ObjectFactory() ! pi = SrcGenCompiler.SrcGenCompiler(mod, fact) fact.parent = pi code = jast.Block(pi.execstring(data)) Index: PythonModule.py =================================================================== RCS file: /cvsroot/jython/jython/Tools/jythonc/PythonModule.py,v retrieving revision 2.19 retrieving revision 2.20 diff -C2 -d -r2.19 -r2.20 *** PythonModule.py 13 Jan 2002 18:33:59 -0000 2.19 --- PythonModule.py 30 May 2002 16:20:13 -0000 2.20 *************** *** 154,158 **** freenames, jast.IntegerConstant(npurecell), ! jast.IntegerConstant((frame.opt_globals and CO_OPTIMIZED) | (frame.scope.nested_scopes and CO_NESTED))] newcode = jast.InvokeStatic("Py", "newCode", cargs) self.constants.append(("PyCode", jast.Identifier(label), newcode)) --- 154,158 ---- freenames, jast.IntegerConstant(npurecell), ! jast.IntegerConstant((frame.opt_globals and CO_OPTIMIZED) | CO_NESTED)] newcode = jast.InvokeStatic("Py", "newCode", cargs) self.constants.append(("PyCode", jast.Identifier(label), newcode)) Index: compile.py =================================================================== RCS file: /cvsroot/jython/jython/Tools/jythonc/compile.py,v retrieving revision 2.21 retrieving revision 2.22 diff -C2 -d -r2.21 -r2.22 *** compile.py 26 Nov 2001 15:21:09 -0000 2.21 --- compile.py 30 May 2002 16:20:13 -0000 2.22 *************** *** 5,9 **** from types import StringType ! from SimpleCompiler import SimpleCompiler from PythonModule import PythonModule from ObjectFactory import ObjectFactory --- 5,9 ---- from types import StringType ! from SrcGenCompiler import SrcGenCompiler from PythonModule import PythonModule from ObjectFactory import ObjectFactory *************** *** 205,209 **** mod = PythonModule(name, filename, frozen=self.deep) fact = ObjectFactory() ! pi = SimpleCompiler(mod, fact, options=self.options) fact.parent = pi code = pi.execstring(data) --- 205,209 ---- mod = PythonModule(name, filename, frozen=self.deep) fact = ObjectFactory() ! pi = SrcGenCompiler(mod, fact, options=self.options) fact.parent = pi code = pi.execstring(data) |
From: Finn B. <bc...@us...> - 2002-05-30 16:17:22
|
Update of /cvsroot/jython/jython In directory usw-pr-cvs1:/tmp/cvs-serv26069 Modified Files: build.xml Log Message: Updated the 'clean' list of generated sources. Index: build.xml =================================================================== RCS file: /cvsroot/jython/jython/build.xml,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** build.xml 29 May 2002 18:41:51 -0000 1.31 --- build.xml 30 May 2002 16:17:19 -0000 1.32 *************** *** 106,109 **** --- 106,112 ---- <target name="clean" depends="init"> <delete dir="${outputDir}/" /> + <delete> + <fileset dir="${distDir}" excludes="jython.jar"/> + </delete> <property name="parser" value="${sourceDir}/org/python/parser" /> <delete file="${parser}/python.jj" /> *************** *** 112,119 **** <delete file="${parser}/PythonGrammarTokenManager.java" /> <delete file="${parser}/PythonGrammarTreeConstants.java" /> - <delete file="${parser}/Node.java" /> <delete file="${parser}/Token.java" /> <delete file="${parser}/ASCII_CharStream.java" /> - <delete file="${parser}/JJTPythonGrammarState.java" /> </target> --- 115,120 ---- |
From: Finn B. <bc...@us...> - 2002-05-30 16:16:16
|
Update of /cvsroot/jython/jython/org/python/modules In directory usw-pr-cvs1:/tmp/cvs-serv25656 Modified Files: codeop.java Log Message: Implementation of the new AST tree. Index: codeop.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/modules/codeop.java,v retrieving revision 2.9 retrieving revision 2.10 diff -C2 -d -r2.9 -r2.10 *** codeop.java 27 Nov 2001 19:07:22 -0000 2.9 --- codeop.java 30 May 2002 16:16:13 -0000 2.10 *************** *** 36,40 **** String filename, String kind, CompilerFlags cflags) { ! org.python.parser.SimpleNode node = parser.partialParse(string+"\n", kind, filename, cflags); --- 36,40 ---- String filename, String kind, CompilerFlags cflags) { ! org.python.parser.ast.modType node = parser.partialParse(string+"\n", kind, filename, cflags); |
From: Finn B. <bc...@us...> - 2002-05-30 16:15:17
|
Update of /cvsroot/jython/jython/org/python/core In directory usw-pr-cvs1:/tmp/cvs-serv24701 Modified Files: CompilerFlags.java Py.java imp.java parser.java Log Message: Implementation of the new AST tree. Index: CompilerFlags.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/core/CompilerFlags.java,v retrieving revision 2.5 retrieving revision 2.6 diff -C2 -d -r2.5 -r2.6 *** CompilerFlags.java 13 Jan 2002 18:15:55 -0000 2.5 --- CompilerFlags.java 30 May 2002 16:15:14 -0000 2.6 *************** *** 11,15 **** } ! public boolean nested_scopes; public boolean division; --- 11,15 ---- } ! public boolean nested_scopes = true; public boolean division; Index: Py.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/core/Py.java,v retrieving revision 2.65 retrieving revision 2.66 diff -C2 -d -r2.65 -r2.66 *** Py.java 26 May 2002 20:29:47 -0000 2.65 --- Py.java 30 May 2002 16:15:14 -0000 2.66 *************** *** 2,6 **** package org.python.core; ! import org.python.parser.SimpleNode; import java.lang.reflect.InvocationTargetException; import java.io.*; --- 2,6 ---- package org.python.core; ! import org.python.parser.ast.modType; import java.lang.reflect.InvocationTargetException; import java.io.*; *************** *** 1537,1545 **** // w/o compiler-flags ! public static PyCode compile(SimpleNode node, String filename) { return compile(node, getName(), filename); } ! public static PyCode compile(SimpleNode node, String name, String filename) { --- 1537,1545 ---- // w/o compiler-flags ! public static PyCode compile(modType node, String filename) { return compile(node, getName(), filename); } ! public static PyCode compile(modType node, String name, String filename) { *************** *** 1547,1551 **** } ! public static PyCode compile(SimpleNode node, String name, String filename, boolean linenumbers, --- 1547,1551 ---- } ! public static PyCode compile(modType node, String name, String filename, boolean linenumbers, *************** *** 1564,1568 **** // with compiler-flags ! public static PyCode compile_flags(SimpleNode node, String name, String filename, boolean linenumbers, --- 1564,1568 ---- // with compiler-flags ! public static PyCode compile_flags(modType node, String name, String filename, boolean linenumbers, *************** *** 1586,1590 **** String type,CompilerFlags cflags) { ! SimpleNode node = parser.parse(istream, type, filename, cflags); boolean printResults = false; if (type.equals("single")) --- 1586,1590 ---- String type,CompilerFlags cflags) { ! modType node = parser.parse(istream, type, filename, cflags); boolean printResults = false; if (type.equals("single")) *************** *** 1689,1693 **** ! static void saveClassFile(String name, ByteArrayOutputStream bytestream) { String dirname = Options.proxyDebugDirectory; if (dirname == null) --- 1689,1693 ---- ! public static void saveClassFile(String name, ByteArrayOutputStream bytestream) { String dirname = Options.proxyDebugDirectory; if (dirname == null) *************** *** 1702,1706 **** o.write(bytes); o.close(); ! } catch (Throwable t) { } } --- 1702,1706 ---- o.write(bytes); o.close(); ! } catch (Throwable t) { t.printStackTrace(); } } Index: imp.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/core/imp.java,v retrieving revision 2.61 retrieving revision 2.62 diff -C2 -d -r2.61 -r2.62 *** imp.java 13 Jan 2002 18:20:31 -0000 2.61 --- imp.java 30 May 2002 16:15:14 -0000 2.62 *************** *** 120,124 **** if (filename == null) filename = "<unknown>"; ! org.python.parser.SimpleNode node = null; //*Forte* try { node = parser.parse(fp, "exec", filename, null); --- 120,124 ---- if (filename == null) filename = "<unknown>"; ! org.python.parser.ast.modType node = null; //*Forte* try { node = parser.parse(fp, "exec", filename, null); Index: parser.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/core/parser.java,v retrieving revision 2.14 retrieving revision 2.15 diff -C2 -d -r2.14 -r2.15 *** parser.java 27 Nov 2001 19:07:21 -0000 2.14 --- parser.java 30 May 2002 16:15:14 -0000 2.15 *************** *** 3,6 **** --- 3,7 ---- import org.python.parser.*; + import org.python.parser.ast.modType; import java.io.*; *************** *** 18,22 **** try { String text=null; ! for(int i=0; i <line; i++) { text = reader.readLine(); } --- 19,23 ---- try { String text=null; ! for(int i=0; i < line; i++) { text = reader.readLine(); } *************** *** 74,78 **** ! public static SimpleNode parse(InputStream istream, String kind, String filename, CompilerFlags cflags) { --- 75,79 ---- ! public static modType parse(InputStream istream, String kind, String filename, CompilerFlags cflags) { *************** *** 109,113 **** PythonGrammar g = new PythonGrammar(new ReaderCharStream(bufreader)); ! SimpleNode node = null; try { if (kind.equals("eval")) { --- 110,114 ---- PythonGrammar g = new PythonGrammar(new ReaderCharStream(bufreader)); ! modType node = null; try { if (kind.equals("eval")) { *************** *** 141,149 **** } ! public static SimpleNode partialParse(String string, String kind, String filename, CompilerFlags cflags) { ! SimpleNode node = null; //System.err.println(new PyString(string).__repr__().toString()); try { --- 142,150 ---- } ! public static modType partialParse(String string, String kind, String filename, CompilerFlags cflags) { ! modType node = null; //System.err.println(new PyString(string).__repr__().toString()); try { |
From: Finn B. <bc...@us...> - 2002-05-30 16:13:33
|
Update of /cvsroot/jython/jython/org/python/compiler In directory usw-pr-cvs1:/tmp/cvs-serv22958 Modified Files: ArgListCompiler.java CodeCompiler.java CompilationContext.java Future.java Module.java ScopeInfo.java ScopesCompiler.java SymInfo.java Log Message: Implementation of the new AST tree. Index: ArgListCompiler.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/compiler/ArgListCompiler.java,v retrieving revision 2.8 retrieving revision 2.9 diff -C2 -d -r2.8 -r2.9 *** ArgListCompiler.java 27 Nov 2001 19:07:21 -0000 2.8 --- ArgListCompiler.java 30 May 2002 16:13:28 -0000 2.9 *************** *** 4,107 **** import org.python.parser.*; import java.io.IOException; import java.util.Vector; import java.util.Enumeration; ! public class ArgListCompiler extends org.python.parser.Visitor implements PythonGrammarTreeConstants { public boolean arglist, keywordlist; ! public Vector defaults; public Vector names; ! public SimpleNode init_code; public ArgListCompiler() { arglist = keywordlist = false; ! defaults = new Vector(); names = new Vector(); ! init_code = new SimpleNode(JJTSUITE); } public void reset() { arglist = keywordlist = false; ! defaults.removeAllElements(); names.removeAllElements(); ! //init_code.removeAllElements(); ! } ! ! public SimpleNode[] getDefaults() { ! SimpleNode[] children = new SimpleNode[defaults.size()]; ! for (int i=0; i<children.length; i++) { ! children[i] = (SimpleNode)defaults.elementAt(i); ! } ! return children; ! } ! ! public Object varargslist(SimpleNode node) throws Exception { ! int n = node.getNumChildren(); ! for (int i=0; i<n; i++) { ! node.getChild(i).visit(this); ! } ! return null; } ! public Object ExtraArgList(SimpleNode node) throws Exception { ! arglist = true; ! names.addElement(node.getChild(0).visit(this)); ! return null; } ! public Object ExtraKeywordList(SimpleNode node) throws Exception { ! keywordlist = true; ! names.addElement(node.getChild(0).visit(this)); ! return null; } ! public Object defaultarg(SimpleNode node) throws Exception { ! Object name = node.getChild(0).visit(this); ! // make sure the named argument isn't already in the list of arguments ! for (Enumeration e=names.elements(); e.hasMoreElements();) { ! String objname = (String)e.nextElement(); ! if (objname.equals(name)) ! throw new ParseException("duplicate argument name found: " + ! name, node); } ! names.addElement(name); ! ! //Handle tuple arguments properly ! if (node.getChild(0).id == JJTFPLIST) { ! SimpleNode expr = new SimpleNode(JJTEXPR_STMT); ! // Set the right line number for this expr ! expr.beginLine = node.beginLine; ! expr.jjtAddChild(node.getChild(0), 0); ! SimpleNode nm = new SimpleNode(JJTNAME); ! nm.setInfo(name); ! expr.jjtAddChild(nm, 1); ! init_code.jjtAddChild(expr, init_code.getNumChildren()); } ! ! // Handle default args if specified ! if (node.getNumChildren() > 1) { ! defaults.addElement(node.getChild(1)); ! } else { ! if (defaults.size() > 0) throw new ParseException( ! "non-default argument follows default argument"); } - return null; } ! public Object fplist(SimpleNode node) throws Exception { ! String name = "("; ! int n = node.getNumChildren(); ! for (int i=0; i<n-1; i++) { ! name = name+node.getChild(i).visit(this)+", "; } ! name = name+node.getChild(n-1).visit(this)+")"; ! return name; } ! public Object Name(SimpleNode node) throws ParseException, IOException { ! return node.getInfo(); } } --- 4,99 ---- import org.python.parser.*; + import org.python.parser.ast.*; import java.io.IOException; import java.util.Vector; import java.util.Enumeration; ! public class ArgListCompiler extends Visitor implements PythonGrammarTreeConstants { public boolean arglist, keywordlist; ! public exprType[] defaults; public Vector names; ! public Vector fpnames; ! public Vector init_code; public ArgListCompiler() { arglist = keywordlist = false; ! defaults = null; names = new Vector(); ! fpnames = new Vector(); ! init_code = new Vector(); } public void reset() { arglist = keywordlist = false; ! defaults = null; names.removeAllElements(); ! init_code.removeAllElements(); } ! public void appendInitCode(Suite node) { ! int n = node.body.length; ! stmtType[] newtree = new stmtType[init_code.size() + n]; ! init_code.copyInto(newtree); ! System.arraycopy(node.body, 0, newtree, init_code.size(), n); ! node.body = newtree; } ! public exprType[] getDefaults() { ! return defaults; } ! public void visitArgs(argumentsType args) throws Exception { ! for (int i = 0; i < args.args.length; i++) { ! String name = (String) visit(args.args[i]); ! names.addElement(name); ! if (args.args[i] instanceof Tuple) { ! Assign ass = new Assign( ! new exprType[] { args.args[i] }, ! new Name(name, Name.Load, args.args[i]), args.args[i]); ! init_code.addElement(ass); ! } } ! if (args.vararg != null) { ! arglist = true; ! names.addElement(args.vararg); } ! if (args.kwarg != null) { ! keywordlist = true; ! names.addElement(args.kwarg); ! } ! ! defaults = args.defaults; ! for (int i = 0; i < defaults.length; i++) { ! if (defaults[i] == null) throw new ParseException( ! "non-default argument follows default argument", ! args.args[args.args.length - defaults.length + i]); } } ! public Object visitName(Name node) throws Exception { ! if (node.ctx != Name.Store) ! return null; ! ! if (fpnames.contains(node.id)) { ! throw new ParseException("duplicate argument name found: " + ! node.id, node); } ! fpnames.addElement(node.id); ! return node.id; } ! public Object visitTuple(Tuple node) throws Exception { ! StringBuffer name = new StringBuffer("("); ! int n = node.elts.length; ! for (int i = 0; i < n-1; i++) { ! name.append(visit(node.elts[i])); ! name.append(", "); ! } ! name.append(visit(node.elts[n - 1])); ! name.append(")"); ! return name.toString(); } } Index: CodeCompiler.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/compiler/CodeCompiler.java,v retrieving revision 2.25 retrieving revision 2.26 diff -C2 -d -r2.25 -r2.26 *** CodeCompiler.java 13 Jan 2002 18:31:55 -0000 2.25 --- CodeCompiler.java 30 May 2002 16:13:29 -0000 2.26 *************** *** 4,9 **** --- 4,15 ---- import org.python.parser.*; + import org.python.parser.ast.*; + import org.python.parser.ast.Attribute; import org.python.core.Py; import org.python.core.PyObject; + import org.python.core.PyInteger; + import org.python.core.PyFloat; + import org.python.core.PyLong; [...3017 lines suppressed...] ! public Object String(SimpleNode node) throws Exception { ! String s = (String)node.getInfo(); if (s.length() > 32767) { throw new ParseException( --- 2127,2132 ---- } ! public Object visitStr(Str node) throws Exception { ! String s = node.s; if (s.length() > 32767) { throw new ParseException( *************** *** 2463,2465 **** --- 2138,2143 ---- } + protected Object unhandled_node(SimpleNode node) throws Exception { + throw new Exception("Unhandled node " + node); + } } Index: CompilationContext.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/compiler/CompilationContext.java,v retrieving revision 2.3 retrieving revision 2.4 diff -C2 -d -r2.3 -r2.4 *** CompilationContext.java 27 Nov 2001 19:07:21 -0000 2.3 --- CompilationContext.java 30 May 2002 16:13:29 -0000 2.4 *************** *** 12,14 **** --- 12,16 ---- public String getFilename(); + + public ScopeInfo getScopeInfo(SimpleNode node); } Index: Future.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/compiler/Future.java,v retrieving revision 2.6 retrieving revision 2.7 diff -C2 -d -r2.6 -r2.7 *** Future.java 13 Jan 2002 18:31:55 -0000 2.6 --- Future.java 30 May 2002 16:13:29 -0000 2.7 *************** *** 4,40 **** import org.python.parser.*; public class Future extends Object implements PythonGrammarTreeConstants { - private boolean nested_scopes; private boolean division; private static final String FUTURE = "__future__"; ! private boolean check(SimpleNode cand) throws Exception { ! SimpleNode dotted_name = cand.getChild(0); ! if (dotted_name.getNumChildren() != 1 || ! !((String)dotted_name.getChild(0).getInfo()).equals(FUTURE)) return false; ! int n = cand.getNumChildren(); ! if (n == 1) { throw new ParseException( "future statement does not support import *",cand); } ! for (int i = 1; i < n; i++) { ! SimpleNode imp = cand.getChild(i); ! String feature; ! switch(imp.id) { ! default: ! case JJTNAME: ! feature = (String)imp.getInfo(); ! break; ! case JJTIMPORT_AS_NAME: ! feature = (String)imp.getChild(0).getInfo(); ! break; ! } // *known* features if (feature.equals("nested_scopes")) { - nested_scopes = true; continue; } --- 4,28 ---- import org.python.parser.*; + import org.python.parser.ast.*; + import org.python.parser.ast.Module; public class Future extends Object implements PythonGrammarTreeConstants { private boolean division; private static final String FUTURE = "__future__"; ! private boolean check(ImportFrom cand) throws Exception { ! if (!cand.module.equals(FUTURE)) return false; ! int n = cand.names.length; ! if (n == 0) { throw new ParseException( "future statement does not support import *",cand); } ! for (int i = 0; i < n; i++) { ! String feature = cand.names[i].name; // *known* features if (feature.equals("nested_scopes")) { continue; } *************** *** 49,79 **** } ! public void preprocessFutures(SimpleNode node, org.python.core.CompilerFlags cflags) throws Exception { if (cflags != null) { - nested_scopes = cflags.nested_scopes; division = cflags.division; } - if ( node.id != JJTFILE_INPUT && node.id != JJTSINGLE_INPUT) - return; - int n = node.getNumChildren(); - if (n == 0) return; - int beg = 0; ! if (node.id == JJTFILE_INPUT && ! node.getChild(0).id == JJTEXPR_STMT && ! node.getChild(0).getChild(0).id == JJTSTRING) beg++; ! for (int i = beg; i < n; i++) { ! SimpleNode stmt = node.getChild(i); ! if (stmt.id != JJTIMPORTFROM) break; stmt.from_future_checked = true; ! if (!check(stmt)) break; } if (cflags != null) { - cflags.nested_scopes = cflags.nested_scopes || nested_scopes; cflags.division = cflags.division || division; } --- 37,71 ---- } ! public void preprocessFutures(modType node, org.python.core.CompilerFlags cflags) throws Exception { if (cflags != null) { division = cflags.division; } int beg = 0; ! stmtType[] suite = null; ! if (node instanceof Module) { ! suite = ((Module) node).body; ! if (suite.length > 0 && suite[0] instanceof Expr && ! ((Expr) suite[0]).value instanceof Str) { ! beg++; ! } ! } else if (node instanceof Interactive) { ! suite = new stmtType[] { ((Interactive) node).body }; ! } else { ! return; ! } ! for (int i = beg; i < suite.length; i++) { ! stmtType stmt = suite[i]; ! if (!(stmt instanceof ImportFrom)) ! break; stmt.from_future_checked = true; ! if (!check((ImportFrom) stmt)) ! break; } if (cflags != null) { cflags.division = cflags.division || division; } *************** *** 81,97 **** ! public static void checkFromFuture(SimpleNode node) throws Exception { ! if (node.from_future_checked) return; ! SimpleNode dotted_name = node.getChild(0); ! if (dotted_name.getNumChildren() == 1 && ! ((String)dotted_name.getChild(0).getInfo()).equals(FUTURE)) { throw new ParseException("from __future__ imports must occur " + "at the beginning of the file",node); } node.from_future_checked = true; - } - - public boolean areNestedScopesOn() { - return nested_scopes; } --- 73,84 ---- ! public static void checkFromFuture(ImportFrom node) throws Exception { ! if (node.from_future_checked) ! return; ! if (node.module.equals(FUTURE)) { throw new ParseException("from __future__ imports must occur " + "at the beginning of the file",node); } node.from_future_checked = true; } Index: Module.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/compiler/Module.java,v retrieving revision 2.11 retrieving revision 2.12 diff -C2 -d -r2.11 -r2.12 *** Module.java 13 Jan 2002 18:31:55 -0000 2.11 --- Module.java 30 May 2002 16:13:29 -0000 2.12 *************** *** 6,9 **** --- 6,12 ---- import java.util.*; import org.python.parser.*; + import org.python.parser.ast.*; + import org.python.core.Py; + import org.python.core.PyException; class PyIntegerConstant extends Constant implements ClassConstants *************** *** 255,259 **** } ! public class Module implements ClassConstants { ClassFile classfile; --- 258,262 ---- } ! public class Module implements ClassConstants, CompilationContext { ClassFile classfile; *************** *** 264,267 **** --- 267,271 ---- public boolean setFile=true; Future futures; + Hashtable scopes; public Module(String name, String filename, boolean linenumbers) { *************** *** 277,280 **** --- 281,285 ---- codes = new Vector(); futures = new Future(); + scopes = new Hashtable(); } *************** *** 367,371 **** private int to_cell; ! public PyCodeConstant PyCode(SimpleNode tree, String name, boolean fast_locals, String className, boolean classBody, boolean printResults, --- 372,376 ---- private int to_cell; ! public PyCodeConstant PyCode(modType tree, String name, boolean fast_locals, String className, boolean classBody, boolean printResults, *************** *** 378,385 **** ! public PyCodeConstant PyCode(SimpleNode tree, String name, boolean fast_locals, String className, boolean classBody, boolean printResults, ! int firstlineno, ScopeInfo scope, org.python.core.CompilerFlags cflags) throws Exception --- 383,391 ---- ! public PyCodeConstant PyCode(modType tree, String name, boolean fast_locals, String className, boolean classBody, boolean printResults, ! int firstlineno, ! ScopeInfo scope, org.python.core.CompilerFlags cflags) throws Exception *************** *** 414,420 **** CodeCompiler compiler = new CodeCompiler(this, printResults); ! if (ac != null && ac.init_code.getNumChildren() > 0) { ! ac.init_code.jjtAddChild(tree, ac.init_code.getNumChildren()); ! tree = ac.init_code; } --- 420,425 ---- CodeCompiler compiler = new CodeCompiler(this, printResults); ! if (ac != null && ac.init_code.size() > 0) { ! ac.appendInitCode((Suite) tree); } *************** *** 439,443 **** compiler.parse(tree, c, fast_locals, className, classBody, ! scope,cflags); // !classdef only --- 444,448 ---- compiler.parse(tree, c, fast_locals, className, classBody, ! scope, cflags); // !classdef only *************** *** 453,459 **** code.moreflags |= org.python.core.PyTableCode.CO_OPTIMIZED; } - if (compiler.my_scope.nested_scopes) { - code.moreflags |= org.python.core.PyTableCode.CO_NESTED; - } code.module = this; --- 458,461 ---- *************** *** 575,579 **** } ! public static void compile(SimpleNode node, OutputStream ostream, String name, String filename, boolean linenumbers, boolean printResults, --- 577,607 ---- } ! // Implementation of CompilationContext ! public Future getFutures() { return futures; } ! ! public String getFilename() { return sfilename; } ! ! public ScopeInfo getScopeInfo(SimpleNode node) { ! return (ScopeInfo) scopes.get(node); ! } ! ! public void error(String msg,boolean err,SimpleNode node) ! throws Exception ! { ! if (!err) { ! try { ! Py.warning(Py.SyntaxWarning, msg, ! (sfilename != null) ? sfilename : "?", ! node.beginLine ,null, Py.None); ! return; ! } catch(PyException e) { ! if (!Py.matchException(e, Py.SyntaxWarning)) ! throw e; ! } ! } ! throw new ParseException(msg,node); ! } ! ! public static void compile(modType node, OutputStream ostream, String name, String filename, boolean linenumbers, boolean printResults, *************** *** 585,593 **** module.setFile = setFile; module.futures.preprocessFutures(node, cflags); //Add __doc__ if it exists //Add __file__ for filename (if it exists?) Constant main = module.PyCode(node, "?", false, null, false, ! printResults, 0, null, cflags); module.mainCode = main; module.write(ostream); --- 613,625 ---- module.setFile = setFile; module.futures.preprocessFutures(node, cflags); + new ScopesCompiler(module, module.scopes).parse(node); + //Add __doc__ if it exists //Add __file__ for filename (if it exists?) Constant main = module.PyCode(node, "?", false, null, false, ! printResults, 0, ! module.getScopeInfo(node), ! cflags); module.mainCode = main; module.write(ostream); Index: ScopeInfo.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/compiler/ScopeInfo.java,v retrieving revision 2.6 retrieving revision 2.7 diff -C2 -d -r2.6 -r2.7 *** ScopeInfo.java 27 Nov 2001 19:07:21 -0000 2.6 --- ScopeInfo.java 30 May 2002 16:13:30 -0000 2.7 *************** *** 12,15 **** --- 12,16 ---- public int level; public int func_level; + public int list_comprehension_count; public void dump() { // for debugging *************** *** 39,44 **** public ScopeInfo(String name, SimpleNode node, int level, int kind, ! int func_level, ArgListCompiler ac, ! boolean nested_scopes) { scope_name = name; scope_node = node; --- 40,44 ---- public ScopeInfo(String name, SimpleNode node, int level, int kind, ! int func_level, ArgListCompiler ac) { scope_name = name; scope_node = node; *************** *** 47,55 **** this.func_level = func_level; this.ac = ac; - this.nested_scopes = nested_scopes; } public int kind; - public boolean nested_scopes; public boolean unqual_exec; --- 47,53 ---- *************** *** 78,81 **** --- 76,80 ---- public void addParam(String name) { + //System.out.println("addParam " + name); tbl.put(name, new SymInfo(PARAM|BOUND,local++)); names.addElement(name); *************** *** 120,124 **** if (up == null) return; // top level => nop - boolean nested_scopes = this.nested_scopes; boolean func = kind == FUNCSCOPE; Vector purecells = new Vector(); --- 119,122 ---- *************** *** 137,152 **** // not func global and bound ? if ((flags&NGLOBAL) == 0 && (flags&BOUND) != 0) { ! if (nested_scopes) { ! info.flags |= CELL; ! if ((info.flags&PARAM) != 0) ! jy_paramcells.addElement(name); ! cellvars.addElement(name); ! info.env_index = cell++; ! if ((flags&PARAM) == 0) purecells.addElement(name); ! continue; ! } ! ctxt.error("local name '"+name+"' in '"+scope_name+ ! "' shadows use as global in nested scopes", ! false, scope_node); } } else { --- 135,145 ---- // not func global and bound ? if ((flags&NGLOBAL) == 0 && (flags&BOUND) != 0) { ! info.flags |= CELL; ! if ((info.flags&PARAM) != 0) ! jy_paramcells.addElement(name); ! cellvars.addElement(name); ! info.env_index = cell++; ! if ((flags&PARAM) == 0) purecells.addElement(name); ! continue; } } else { *************** *** 204,208 **** else why = " because it contains free variables"; ! ctxt.error(illegal + why, nested_scopes, scope_node); } --- 197,201 ---- else why = " because it contains free variables"; ! ctxt.error(illegal + why, true, scope_node); } *************** *** 210,214 **** public void setup_closure(ScopeInfo up) { - if (!nested_scopes) return; int free = cell; // env = cell...,free... Hashtable up_tbl = up.tbl; --- 203,206 ---- Index: ScopesCompiler.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/compiler/ScopesCompiler.java,v retrieving revision 2.6 retrieving revision 2.7 diff -C2 -d -r2.6 -r2.7 *** ScopesCompiler.java 13 Jan 2002 18:31:55 -0000 2.6 --- ScopesCompiler.java 30 May 2002 16:13:30 -0000 2.7 *************** *** 4,7 **** --- 4,8 ---- import org.python.parser.*; + import org.python.parser.ast.*; import java.util.*; *************** *** 10,17 **** private CompilationContext code_compiler; - private boolean nested_scopes = false; - private Stack scopes; private ScopeInfo cur = null; private int mode; --- 11,17 ---- private CompilationContext code_compiler; private Stack scopes; private ScopeInfo cur = null; + private Hashtable nodeScopes; private int mode; *************** *** 24,53 **** private int func_level = 0; ! public ScopesCompiler(CompilationContext code_compiler) { this.code_compiler = code_compiler; scopes = new Stack(); mode = GET; - nested_scopes = code_compiler.getFutures().areNestedScopesOn(); - // System.err.println("nested-scopes: "+nested_scopes); - } - - public Object set(SimpleNode node) throws Exception { - return modal(node,SET); - } - - public Object del(SimpleNode node) throws Exception { - return modal(node,DEL); - } - - - public Object augset(SimpleNode node) throws Exception { - return modal(node,AUGSET); - } - - public Object modal(SimpleNode node, int newmode)throws Exception { - mode = newmode; - node.visit(this); - mode = GET; - return null; } --- 24,34 ---- private int func_level = 0; ! public ScopesCompiler(CompilationContext code_compiler, ! Hashtable nodeScopes) ! { this.code_compiler = code_compiler; + this.nodeScopes = nodeScopes; scopes = new Stack(); mode = GET; } *************** *** 59,64 **** } if (kind == FUNCSCOPE) func_level++; ! node.scope = cur = new ScopeInfo(name, node, level++, kind, ! func_level, ac, nested_scopes); } --- 40,46 ---- } if (kind == FUNCSCOPE) func_level++; ! cur = new ScopeInfo(name, node, level++, kind, ! func_level, ac); ! nodeScopes.put(node, cur); } *************** *** 74,78 **** public void parse(SimpleNode node) throws Exception { try { ! node.visit(this); } catch(Throwable t) { throw org.python.core.parser.fixParseError(null, t, --- 56,60 ---- public void parse(SimpleNode node) throws Exception { try { ! visit(node); } catch(Throwable t) { throw org.python.core.parser.fixParseError(null, t, *************** *** 81,211 **** } ! public Object single_input(SimpleNode node) throws Exception { ! beginScope("<single-top>",TOPSCOPE,node,null); ! suite(node); endScope(); return null; } ! public Object file_input(SimpleNode node) throws Exception { ! beginScope("<file-top>",TOPSCOPE,node,null); ! suite(node); endScope(); return null; } ! public Object eval_input(SimpleNode node) throws Exception { ! beginScope("<eval-top>",TOPSCOPE,node,null); ! return_stmt(node); endScope(); return null; } ! private String def(SimpleNode node) { ! String name = (String)node.getChild(0).getInfo(); cur.addBound(name); - return name; } ! public Object funcdef(SimpleNode node) throws Exception { ! String my_name = def(node); ArgListCompiler ac = new ArgListCompiler(); ! SimpleNode suite; ! if (node.getNumChildren() == 3) { ! suite = node.getChild(2); ! //Parse arguments ! node.getChild(1).visit(ac); ! } else { ! suite = node.getChild(1); ! } ! SimpleNode[] defaults = ac.getDefaults(); int defc = defaults.length; ! for(int i=0; i<defc; i++) { ! defaults[i].visit(this); } ! beginScope(my_name,FUNCSCOPE,node,ac); int n = ac.names.size(); ! for (int i=0; i<n; i++) { cur.addParam((String)ac.names.elementAt(i)); } ! ac.init_code.visit(this); cur.markFromParam(); ! suite.visit(this); endScope(); return null; } ! public Object expr_stmt(SimpleNode node) throws Exception { ! int n = node.getNumChildren(); ! node.getChild(n-1).visit(this); ! for (int i=0; i<n-1; i++) { ! set(node.getChild(i)); ! } ! return null; ! } ! ! public Object print_ext(SimpleNode node) throws Exception { ! node.getChild(0).visit(this); ! return null; ! } ! public Object print_stmt(SimpleNode node) throws Exception { ! int n = node.getNumChildren(); ! if ( n > 0 ) { ! for (int i=0; i<n-1; i++) { ! node.getChild(i).visit(this); ! } ! if(node.getChild(n-1).id != PythonGrammarTreeConstants.JJTCOMMA) ! node.getChild(n-1).visit(this); } - return null; - } ! public Object del_stmt(SimpleNode node) throws Exception { ! int n = node.getNumChildren(); ! for (int i=0; i<n; i++) { ! del(node.getChild(i)); } return null; } ! public Object pass_stmt(SimpleNode n) throws Exception { ! return null; ! } ! ! public Object break_stmt(SimpleNode n) throws Exception { ! return null; ! } ! ! public Object continue_stmt(SimpleNode n) throws Exception { ! return null; ! } ! ! public Object return_stmt(SimpleNode node) throws Exception { ! if (node.getNumChildren() == 1) node.getChild(0).visit(this); ! return null; ! } ! ! public void stmt(SimpleNode node) throws Exception { ! int n = node.getNumChildren(); ! for (int i=0; i<n; i++) node.getChild(i).visit(this); ! } ! ! public Object raise_stmt(SimpleNode node) throws Exception { ! stmt(node); ! return null; } ! public Object Import(SimpleNode node) throws Exception { ! int n = node.getNumChildren(); ! for(int i = 0; i < n; i++) { ! SimpleNode imp = node.getChild(i); ! switch(imp.id) { ! case PythonGrammarTreeConstants.JJTDOTTED_NAME: ! cur.addBound((String)imp.getChild(0).getInfo()); ! break; ! case PythonGrammarTreeConstants.JJTDOTTED_AS_NAME: ! cur.addBound((String)imp.getChild(1).getInfo()); ! break; } } --- 63,157 ---- } ! public Object visitInteractive(Interactive node) throws Exception { ! beginScope("<single-top>", TOPSCOPE, node, null); ! visit(node.body); endScope(); return null; } ! public Object visitModule(org.python.parser.ast.Module node) ! throws Exception ! { ! beginScope("<file-top>", TOPSCOPE, node, null); ! suite(node.body); endScope(); return null; } ! public Object visitExpression(Expression node) throws Exception { ! beginScope("<eval-top>", TOPSCOPE, node, null); ! visit(new Return(node.body)); endScope(); return null; } ! private void def(String name) { cur.addBound(name); } ! public Object visitFunctionDef(FunctionDef node) throws Exception { ! def(node.name); ArgListCompiler ac = new ArgListCompiler(); ! ac.visitArgs(node.args); ! ! exprType[] defaults = ac.getDefaults(); int defc = defaults.length; ! for (int i = 0; i < defc; i++) { ! visit(defaults[i]); } ! ! beginScope(node.name, FUNCSCOPE, node, ac); int n = ac.names.size(); ! for (int i = 0; i < n; i++) { cur.addParam((String)ac.names.elementAt(i)); } ! for (int i = 0; i < ac.init_code.size(); i++) { ! visit((stmtType) ac.init_code.elementAt(i)); ! } cur.markFromParam(); ! suite(node.body); endScope(); return null; } ! public Object visitLambda(Lambda node) throws Exception { ! ArgListCompiler ac = new ArgListCompiler(); ! ac.visitArgs(node.args); ! SimpleNode[] defaults = ac.getDefaults(); ! int defc = defaults.length; ! for (int i = 0; i < defc; i++) { ! visit(defaults[i]); } ! beginScope("<lambda>", FUNCSCOPE, node, ac); ! int n = ac.names.size(); ! for (int i = 0; i < n; i++) { ! cur.addParam((String)ac.names.elementAt(i)); } + for (int i = 0; i < ac.init_code.size(); i++) + visit((stmtType) ac.init_code.elementAt(i)); + cur.markFromParam(); + visit(node.body); + endScope(); return null; } ! public void suite(stmtType[] stmts) throws Exception { ! int n = stmts.length; ! for (int i = 0; i < n; i++) ! visit(stmts[i]); } ! public Object visitImport(Import node) throws Exception { ! int n = node.names.length; ! for (int i = 0; i < n; i++) { ! if (node.names[i].asname != null) ! cur.addBound(node.names[i].asname); ! else { ! String name = node.names[i].name; ! if (name.indexOf('.') > 0) ! name = name.substring(0, name.indexOf('.')); ! cur.addBound(name); } } *************** *** 213,242 **** } ! public Object ImportFrom(SimpleNode node) throws Exception { Future.checkFromFuture(node); // future stmt support ! int n = node.getNumChildren(); ! if (n == 1) { cur.from_import_star = true; return null; } ! for (int i = 1; i < n; i++) { ! SimpleNode imp = node.getChild(i); ! switch(imp.id) { ! case PythonGrammarTreeConstants.JJTNAME: ! cur.addBound((String)imp.getInfo()); ! break; ! case PythonGrammarTreeConstants.JJTIMPORT_AS_NAME: ! cur.addBound((String)imp.getChild(1).getInfo()); ! break; ! } } - return null; } ! public Object global_stmt(SimpleNode node) throws Exception { ! int n = node.getNumChildren(); ! for(int i = 0; i < n; i++) { ! String name = (String)node.getChild(i).getInfo(); int prev = cur.addGlobal(name); if (prev >= 0) { --- 159,182 ---- } ! public Object visitImportFrom(ImportFrom node) throws Exception { Future.checkFromFuture(node); // future stmt support ! int n = node.names.length; ! if (n == 0) { cur.from_import_star = true; return null; } ! for (int i = 0; i < n; i++) { ! if (node.names[i].asname != null) ! cur.addBound(node.names[i].asname); ! else ! cur.addBound(node.names[i].name); } return null; } ! public Object visitGlobal(Global node) throws Exception { ! int n = node.names.length; ! for (int i = 0; i < n; i++) { ! String name = node.names[i]; int prev = cur.addGlobal(name); if (prev >= 0) { *************** *** 254,311 **** } ! public Object exec_stmt(SimpleNode node) throws Exception { cur.exec = true; ! int n = node.getNumChildren(); ! if (n == 1) cur.unqual_exec = true; ! for (int i = 0; i < n; i++) node.getChild(i).visit(this); ! return null; ! } ! ! public Object assert_stmt(SimpleNode node) throws Exception { ! stmt(node); ! return null; ! } ! ! public Object if_stmt(SimpleNode node) throws Exception { ! stmt(node); ! return null; ! } ! ! public Object while_stmt(SimpleNode node) throws Exception { ! stmt(node); ! return null; ! } ! ! public Object for_stmt(SimpleNode node) throws Exception { ! if (mode != GET) illassign(node); ! set(node.getChild(0)); ! node.getChild(1).visit(this); ! node.getChild(2).visit(this); ! if (node.getNumChildren()>3) node.getChild(3).visit(this); ! return null; ! } ! ! public Object try_stmt(SimpleNode node) throws Exception { ! int n = node.getNumChildren(); ! for (int i=0; i<n; i++) { ! if (i%2 == 1 && i != n-1) { ! switch(node.getChild(i).getNumChildren()) { ! case 2: ! set(node.getChild(i).getChild(1)); ! case 1: ! node.getChild(i).getChild(0).visit(this); ! } ! continue; ! } ! node.getChild(i).visit(this); ! } ! return null; ! } ! ! public Object suite(SimpleNode node) throws Exception { ! stmt(node); return null; } private static void illassign(SimpleNode node) throws Exception { String target = "operator"; --- 194,206 ---- } ! public Object visitExec(Exec node) throws Exception { cur.exec = true; ! if (node.globals == null && node.locals == null) ! cur.unqual_exec = true; ! traverse(node); return null; } + /* private static void illassign(SimpleNode node) throws Exception { String target = "operator"; *************** *** 317,600 **** throw new ParseException("can't assign to "+target,node); } ! public void binaryop(SimpleNode node) throws Exception { ! if (mode != GET) illassign(node); ! node.getChild(0).visit(this); ! node.getChild(1).visit(this); ! } ! ! public void unaryop(SimpleNode node) throws Exception { ! if (mode != GET) illassign(node); ! node.getChild(0).visit(this); ! } ! ! ! public Object or_boolean(SimpleNode node) throws Exception { ! binaryop(node); ! return null; ! } ! ! public Object and_boolean(SimpleNode node) throws Exception { ! binaryop(node); ! return null; ! } ! ! public Object not_1op(SimpleNode node) throws Exception { ! unaryop(node); ! return null; ! } ! ! public Object comparision(SimpleNode node) throws Exception { ! if (mode != GET) illassign(node); ! int n = node.getNumChildren(); ! for (int i=0; i<n; i++) { ! if (i%2 == 0) node.getChild(i).visit(this); ! } ! return null; ! } ! ! public Object or_2op(SimpleNode node) throws Exception { ! binaryop(node); ! return null; ! } ! ! public Object xor_2op(SimpleNode node) throws Exception { ! binaryop(node); ! return null; ! } ! ! public Object and_2op(SimpleNode node) throws Exception { ! binaryop(node); ! return null; ! } ! ! public Object lshift_2op(SimpleNode node) throws Exception { ! binaryop(node); ! return null; ! } ! ! public Object rshift_2op(SimpleNode node) throws Exception { ! binaryop(node); ! return null; ! } ! ! public Object add_2op(SimpleNode node) throws Exception { ! binaryop(node); ! return null; ! } ! ! public Object sub_2op(SimpleNode node) throws Exception { ! binaryop(node); ! return null; ! } ! ! public Object mul_2op(SimpleNode node) throws Exception { ! binaryop(node); ! return null; ! } ! ! public Object div_2op(SimpleNode node) throws Exception { ! binaryop(node); ! return null; ! } ! ! public Object floordiv_2op(SimpleNode node) throws Exception { ! binaryop(node); ! return null; ! } ! ! public Object mod_2op(SimpleNode node) throws Exception { ! binaryop(node); ! return null; ! } ! ! public Object pos_1op(SimpleNode node) throws Exception { ! unaryop(node); ! return null; ! } ! ! public Object neg_1op(SimpleNode node) throws Exception { ! unaryop(node); ! return null; ! } ! ! public Object invert_1op(SimpleNode node) throws Exception { ! unaryop(node); ! return null; ! } ! ! public Object pow_2op(SimpleNode node) throws Exception { ! binaryop(node); ! return null; ! } ! ! public Object str_1op(SimpleNode node) throws Exception { ! unaryop(node); ! return null; ! } ! ! public Object strjoin(SimpleNode node) throws Exception { ! binaryop(node); ! return null; ! } ! ! public Object Call_Op(SimpleNode node) throws Exception { ! if (mode != GET) illassign(node); ! node.getChild(0).visit(this); ! if (node.getNumChildren()>1) { ! SimpleNode args=node.getChild(1); ! int n = args.getNumChildren(); ! for (int i=0; i<n; i++) { ! SimpleNode arg = args.getChild(i); ! switch(arg.id) { ! case PythonGrammarTreeConstants.JJTKEYWORD: ! arg.getChild(1).visit(this); ! break; ! case PythonGrammarTreeConstants.JJTEXTRAARGVALUELIST: ! case PythonGrammarTreeConstants.JJTEXTRAKEYWORDVALUELIST: ! arg.getChild(0).visit(this); ! break; ! default: ! arg.visit(this); ! } ! } ! } ! return null; ! } ! ! public Object Index_Op(SimpleNode node) throws Exception { ! int prevmode= mode; ! mode = GET; ! node.getChild(0).visit(this); ! node.getChild(1).visit(this); ! mode = prevmode; ! return null; ! } ! ! public Object Dot_Op(SimpleNode node) throws Exception { ! int prevmode = mode; ! mode = GET; ! node.getChild(0).visit(this); ! mode = prevmode; ! return null; ! } ! ! public Object tuple(SimpleNode node) throws Exception { ! if (mode ==AUGSET) { ! throw new ParseException( ! "augmented assign to tuple not possible", node); ! } ! int n = node.getNumChildren(); ! if (n > 0) { ! for (int i=0; i<n-1; i++) node.getChild(i).visit(this); ! if (node.getChild(n-1).id != PythonGrammarTreeConstants.JJTCOMMA) ! node.getChild(n-1).visit(this); ! } ! return null; ! } ! ! public Object fplist(SimpleNode node) throws Exception { ! return list(node); ! } ! ! public Object list(SimpleNode node) throws Exception { ! if (mode ==AUGSET) { ! throw new ParseException( ! "augmented assign to list not possible", node); ! } ! int n = node.getNumChildren(); ! if (n > 0) { ! for (int i=0; i<n-1; i++) node.getChild(i).visit(this); ! if (node.getChild(n-1).id != PythonGrammarTreeConstants.JJTCOMMA) ! node.getChild(n-1).visit(this); ! } ! return null; ! } ! ! public Object list_iter(SimpleNode node) throws Exception { ! if (node.getNumChildren() == 1) node.getChild(0).visit(this); ! return null; ! } ! ! public Object dictionary(SimpleNode node) throws Exception { ! if (mode != GET) illassign(node); ! stmt(node); ! return null; ! } ! ! public Object lambdef(SimpleNode node) throws Exception { ! if (mode != GET) illassign(node); ! ArgListCompiler ac = new ArgListCompiler(); ! SimpleNode expr; ! if (node.getNumChildren() == 2) { ! expr = node.getChild(1); ! //Parse arguments ! node.getChild(0).visit(ac); ! } else { ! expr = node.getChild(0); ! } ! SimpleNode[] defaults = ac.getDefaults(); ! int defc = defaults.length; ! for(int i=0; i<defc; i++) { ! defaults[i].visit(this); ! } ! beginScope("<lambda>",FUNCSCOPE,node,ac); ! int n = ac.names.size(); ! for (int i=0; i<n; i++) { ! cur.addParam((String)ac.names.elementAt(i)); ! } ! ac.init_code.visit(this); ! cur.markFromParam(); ! expr.visit(this); ! endScope(); ! return null; ! } ! ! public Object Ellipses(SimpleNode n) throws Exception { ! return null; ! } ! ! public Object Slice(SimpleNode node) throws Exception { ! int n = node.getNumChildren(); ! for (int i=0; i<n; i++) { ! SimpleNode snode = node.getChild(i); ! if (snode.id != PythonGrammarTreeConstants.JJTCOLON) { ! snode.visit(this); ! } ! } ! return null; ! } ! ! public Object classdef(SimpleNode node) throws Exception { ! String cl_name = def(node); ! int n = node.getNumChildren(); ! SimpleNode suite = node.getChild(n-1); ! for (int i=1; i<n-1; i++) node.getChild(i).visit(this); ! beginScope(cl_name,CLASSSCOPE,node,null); ! suite.visit(this); endScope(); return null; } ! public Object Int(SimpleNode node) throws Exception { ! if (mode != GET) illassign(node); ! return null; ! } ! ! public Object Float(SimpleNode node) throws Exception { ! if (mode != GET) illassign(node); ! return null; ! } ! ! public Object Complex(SimpleNode node) throws Exception { ! if (mode != GET) illassign(node); ! return null; ! } ! ! public Object Name(SimpleNode node) throws Exception { ! String name = (String)node.getInfo(); ! if ( mode != GET) { if (name.equals("__debug__")) ! code_compiler.error("can not assign to __debug__",false,node); cur.addBound(name); } --- 212,233 ---- throw new ParseException("can't assign to "+target,node); } + */ ! public Object visitClassDef(ClassDef node) throws Exception { ! def(node.name); ! int n = node.bases.length; ! for (int i = 0; i < n; i++) ! visit(node.bases[i]); ! beginScope(node.name, CLASSSCOPE, node, null); ! suite(node.body); endScope(); return null; } ! public Object visitName(Name node) throws Exception { ! String name = node.id; ! if (node.ctx != expr_contextType.Load) { if (name.equals("__debug__")) ! code_compiler.error("can not assign to __debug__", true,node); cur.addBound(name); } *************** *** 603,675 **** } ! public Object String(SimpleNode node) throws Exception { ! if (mode != GET) illassign(node); ! return null; ! } ! ! public void aug_assign(SimpleNode node) throws Exception { ! augset(node.getChild(0)); ! node.getChild(1).visit(this); ! } ! ! public Object aug_plus(SimpleNode node) throws Exception { ! aug_assign(node); ! return null; ! } ! ! public Object aug_minus(SimpleNode node) throws Exception { ! aug_assign(node); ! return null; ! } ! ! public Object aug_multiply(SimpleNode node) throws Exception { ! aug_assign(node); ! return null; ! } ! ! public Object aug_divide(SimpleNode node) throws Exception { ! aug_assign(node); ! return null; ! } ! ! public Object aug_floordivide(SimpleNode node) throws Exception { ! aug_assign(node); ! return null; ! } ! ! public Object aug_modulo(SimpleNode node) throws Exception { ! aug_assign(node); ! return null; ! } ! ! public Object aug_and(SimpleNode node) throws Exception { ! aug_assign(node); ! return null; ! } ! ! public Object aug_or(SimpleNode node) throws Exception { ! aug_assign(node); ! return null; ! } ! ! public Object aug_xor(SimpleNode node) throws Exception { ! aug_assign(node); ! return null; ! } ! ! public Object aug_lshift(SimpleNode node) throws Exception { ! aug_assign(node); ! return null; ! } ! ! public Object aug_rshift(SimpleNode node) throws Exception { ! aug_assign(node); ! return null; ! } ! ! public Object aug_power(SimpleNode node) throws Exception { ! aug_assign(node); return null; } - } --- 236,244 ---- } ! public Object visitListComp(ListComp node) throws Exception { ! String tmp = "_[" + (++cur.list_comprehension_count) + "]"; ! cur.addBound(tmp); ! traverse(node); return null; } } Index: SymInfo.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/compiler/SymInfo.java,v retrieving revision 2.2 retrieving revision 2.3 diff -C2 -d -r2.2 -r2.3 *** SymInfo.java 27 Nov 2001 13:51:37 -0000 2.2 --- SymInfo.java 30 May 2002 16:13:30 -0000 2.3 *************** *** 17,19 **** --- 17,24 ---- public int env_index; + + public String toString() { + return "SymInfo[" + flags + " " + locals_index + " " + + env_index + "]"; + } } |
From: Finn B. <bc...@us...> - 2002-05-30 16:09:38
|
Update of /cvsroot/jython/jython/org/python/parser In directory usw-pr-cvs1:/tmp/cvs-serv18771 Modified Files: PythonGrammar.java PythonGrammarConstants.java PythonGrammarTokenManager.java PythonGrammarTreeConstants.java Log Message: Committing generated JavaCC files. Index: PythonGrammar.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/parser/PythonGrammar.java,v retrieving revision 2.16 retrieving revision 2.17 diff -C2 -d -r2.16 -r2.17 *** PythonGrammar.java 13 Jan 2002 18:26:51 -0000 2.16 --- PythonGrammar.java 30 May 2002 16:09:33 -0000 2.17 *************** *** 1,23 **** /* Generated By:JJTree&JavaCC: Do not edit this line. PythonGrammar.java */ package org.python.parser; public class PythonGrammar/*@bgen(jjtree)*/implements PythonGrammarTreeConstants, PythonGrammarConstants {/*@bgen(jjtree)*/ protected JJTPythonGrammarState jjtree = new JJTPythonGrammarState();void jjtreeOpenNodeScope(Node n) { ! ((SimpleNode)n).beginLine = getToken(1).beginLine; ! ((SimpleNode)n).beginColumn = getToken(1).beginColumn; } void jjtreeCloseNodeScope(Node n) { [...7688 lines suppressed...] for (int j = 0; j < 32; j++) { --- 6956,6960 ---- jj_kind = -1; } ! for (int i = 0; i < 103; i++) { if (jj_la1[i] == jj_gen) { for (int j = 0; j < 32; j++) { *************** *** 6842,6846 **** } } ! for (int i = 0; i < 116; i++) { if (la1tokens[i]) { jj_expentry = new int[1]; --- 6974,6978 ---- } } ! for (int i = 0; i < 118; i++) { if (la1tokens[i]) { jj_expentry = new int[1]; Index: PythonGrammarConstants.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/parser/PythonGrammarConstants.java,v retrieving revision 2.8 retrieving revision 2.9 diff -C2 -d -r2.8 -r2.9 *** PythonGrammarConstants.java 13 Jan 2002 18:26:51 -0000 2.8 --- PythonGrammarConstants.java 30 May 2002 16:09:33 -0000 2.9 *************** *** 80,103 **** int CONTINUE = 80; int RETURN = 81; ! int IMPORT = 82; ! int FROM = 83; ! int DEL = 84; ! int RAISE = 85; ! int GLOBAL = 86; ! int EXEC = 87; ! int ASSERT = 88; ! int AS = 89; ! int NAME = 90; ! int LETTER = 91; ! int DECNUMBER = 92; ! int HEXNUMBER = 93; ! int OCTNUMBER = 94; ! int FLOAT = 95; ! int EXPONENT = 96; ! int DIGIT = 97; ! int SINGLE_STRING = 102; ! int SINGLE_STRING2 = 103; ! int TRIPLE_STRING = 104; ! int TRIPLE_STRING2 = 105; int DEFAULT = 0; --- 80,105 ---- int CONTINUE = 80; int RETURN = 81; ! int YIELD = 82; ! int IMPORT = 83; ! int FROM = 84; ! int DEL = 85; ! int RAISE = 86; ! int GLOBAL = 87; ! int EXEC = 88; ! int ASSERT = 89; ! int AS = 90; ! int NAME = 91; ! int LETTER = 92; ! int DECNUMBER = 93; ! int HEXNUMBER = 94; ! int OCTNUMBER = 95; ! int FLOAT = 96; ! int COMPLEX = 97; ! int EXPONENT = 98; ! int DIGIT = 99; ! int SINGLE_STRING = 104; ! int SINGLE_STRING2 = 105; ! int TRIPLE_STRING = 106; ! int TRIPLE_STRING2 = 107; int DEFAULT = 0; *************** *** 196,199 **** --- 198,202 ---- "\"continue\"", "\"return\"", + "\"yield\"", "\"import\"", "\"from\"", *************** *** 210,219 **** "<OCTNUMBER>", "<FLOAT>", "<EXPONENT>", "<DIGIT>", - "<token of kind 98>", - "<token of kind 99>", "<token of kind 100>", "<token of kind 101>", "\"\\\'\"", "\"\\\"\"", --- 213,223 ---- "<OCTNUMBER>", "<FLOAT>", + "<COMPLEX>", "<EXPONENT>", "<DIGIT>", "<token of kind 100>", "<token of kind 101>", + "<token of kind 102>", + "<token of kind 103>", "\"\\\'\"", "\"\\\"\"", *************** *** 221,232 **** "\"\\\"\\\"\\\"\"", "\"\\\\\\r\\n\"", - "<token of kind 107>", - "<token of kind 108>", "<token of kind 109>", "\"\\r\\n\"", "\"\\n\"", "\"\\r\"", ! "<token of kind 113>", ! "<token of kind 114>", "\"`\"", }; --- 225,236 ---- "\"\\\"\\\"\\\"\"", "\"\\\\\\r\\n\"", "<token of kind 109>", + "<token of kind 110>", + "<token of kind 111>", "\"\\r\\n\"", "\"\\n\"", "\"\\r\"", ! "<token of kind 115>", ! "<token of kind 116>", "\"`\"", }; Index: PythonGrammarTokenManager.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/parser/PythonGrammarTokenManager.java,v retrieving revision 2.15 retrieving revision 2.16 diff -C2 -d -r2.15 -r2.16 *** PythonGrammarTokenManager.java 13 Jan 2002 18:26:51 -0000 2.15 --- PythonGrammarTokenManager.java 30 May 2002 16:09:33 -0000 2.16 *************** *** 1,4 **** --- 1,7 ---- /* Generated By:JJTree&JavaCC: Do not edit this line. PythonGrammarTokenManager.java */ package org.python.parser; + import org.python.core.Py; + import org.python.core.PyString; + import org.python.parser.ast.modType; public class PythonGrammarTokenManager implements PythonGrammarConstants *************** *** 52,67 **** [...2100 lines suppressed...] image = new StringBuffer(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1)))); --- 3027,3031 ---- matchedToken.image = image.toString(); break; ! case 106 : if (image == null) image = new StringBuffer(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1)))); *************** *** 2944,2948 **** matchedToken.image = image.toString(); break; ! case 105 : if (image == null) image = new StringBuffer(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1)))); --- 3034,3038 ---- matchedToken.image = image.toString(); break; ! case 107 : if (image == null) image = new StringBuffer(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1)))); Index: PythonGrammarTreeConstants.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/parser/PythonGrammarTreeConstants.java,v retrieving revision 2.8 retrieving revision 2.9 diff -C2 -d -r2.8 -r2.9 *** PythonGrammarTreeConstants.java 13 Jan 2002 18:26:51 -0000 2.8 --- PythonGrammarTreeConstants.java 30 May 2002 16:09:33 -0000 2.9 *************** *** 10,38 **** public int JJTFUNCDEF = 3; public int JJTVOID = 4; ! public int JJTVARARGSLIST = 5; ! public int JJTEXTRAARGLIST = 6; ! public int JJTEXTRAKEYWORDLIST = 7; ! public int JJTDEFAULTARG = 8; ! public int JJTFPLIST = 9; ! public int JJTEXPR_STMT = 10; ! public int JJTAUG_PLUS = 11; ! public int JJTAUG_MINUS = 12; ! public int JJTAUG_MULTIPLY = 13; ! public int JJTAUG_DIVIDE = 14; ! public int JJTAUG_FLOORDIVIDE = 15; ! public int JJTAUG_MODULO = 16; ! public int JJTAUG_AND = 17; ! public int JJTAUG_OR = 18; ! public int JJTAUG_XOR = 19; ! public int JJTAUG_LSHIFT = 20; ! public int JJTAUG_RSHIFT = 21; ! public int JJTAUG_POWER = 22; public int JJTPRINT_STMT = 23; ! public int JJTPRINT_EXT = 24; ! public int JJTDEL_STMT = 25; ! public int JJTPASS_STMT = 26; ! public int JJTBREAK_STMT = 27; ! public int JJTCONTINUE_STMT = 28; ! public int JJTRETURN_STMT = 29; public int JJTRAISE_STMT = 30; public int JJTIMPORT = 31; --- 10,38 ---- public int JJTFUNCDEF = 3; public int JJTVOID = 4; ! public int JJTEXTRAARGLIST = 5; ! public int JJTEXTRAKEYWORDLIST = 6; ! public int JJTDEFAULTARG = 7; ! public int JJTTUPLE = 8; ! public int JJTAUG_PLUS = 9; ! public int JJTAUG_MINUS = 10; ! public int JJTAUG_MULTIPLY = 11; ! public int JJTAUG_DIVIDE = 12; ! public int JJTAUG_FLOORDIVIDE = 13; ! public int JJTAUG_MODULO = 14; ! public int JJTAUG_AND = 15; ! public int JJTAUG_OR = 16; ! public int JJTAUG_XOR = 17; ! public int JJTAUG_LSHIFT = 18; ! public int JJTAUG_RSHIFT = 19; ! public int JJTAUG_POWER = 20; ! public int JJTEXPR_STMT = 21; ! public int JJTPRINTEXT_STMT = 22; public int JJTPRINT_STMT = 23; ! public int JJTDEL_STMT = 24; ! public int JJTPASS_STMT = 25; ! public int JJTBREAK_STMT = 26; ! public int JJTCONTINUE_STMT = 27; ! public int JJTRETURN_STMT = 28; ! public int JJTYIELD_STMT = 29; public int JJTRAISE_STMT = 30; public int JJTIMPORT = 31; *************** *** 48,86 **** public int JJTFOR_STMT = 41; public int JJTTRY_STMT = 42; ! public int JJTEXCEPT_CLAUSE = 43; ! public int JJTSUITE = 44; ! public int JJTOR_BOOLEAN = 45; ! public int JJTAND_BOOLEAN = 46; ! public int JJTNOT_1OP = 47; ! public int JJTCOMPARISION = 48; ! public int JJTLESS_CMP = 49; ! public int JJTGREATER_CMP = 50; ! public int JJTEQUAL_CMP = 51; ! public int JJTGREATER_EQUAL_CMP = 52; ! public int JJTLESS_EQUAL_CMP = 53; ! public int JJTNOTEQUAL_CMP = 54; ! public int JJTIN_CMP = 55; ! public int JJTNOT_IN_CMP = 56; ! public int JJTIS_NOT_CMP = 57; ! public int JJTIS_CMP = 58; ! public int JJTOR_2OP = 59; ! public int JJTXOR_2OP = 60; ! public int JJTAND_2OP = 61; ! public int JJTLSHIFT_2OP = 62; ! public int JJTRSHIFT_2OP = 63; ! public int JJTADD_2OP = 64; ! public int JJTSUB_2OP = 65; ! public int JJTMUL_2OP = 66; ! public int JJTDIV_2OP = 67; ! public int JJTFLOORDIV_2OP = 68; ! public int JJTMOD_2OP = 69; ! public int JJTPOS_1OP = 70; ! public int JJTNEG_1OP = 71; ! public int JJTINVERT_1OP = 72; ! public int JJTPOW_2OP = 73; ! public int JJTCALL_OP = 74; ! public int JJTINDEX_OP = 75; ! public int JJTDOT_OP = 76; ! public int JJTTUPLE = 77; public int JJTLIST = 78; public int JJTDICTIONARY = 79; --- 48,86 ---- public int JJTFOR_STMT = 41; public int JJTTRY_STMT = 42; ! public int JJTTRYFINALLY_STMT = 43; ! public int JJTEXCEPT_CLAUSE = 44; ! public int JJTSUITE = 45; ! public int JJTOR_BOOLEAN = 46; ! public int JJTAND_BOOLEAN = 47; ! public int JJTNOT_1OP = 48; ! public int JJTCOMPARISION = 49; ! public int JJTLESS_CMP = 50; ! public int JJTGREATER_CMP = 51; ! public int JJTEQUAL_CMP = 52; ! public int JJTGREATER_EQUAL_CMP = 53; ! public int JJTLESS_EQUAL_CMP = 54; ! public int JJTNOTEQUAL_CMP = 55; ! public int JJTIN_CMP = 56; ! public int JJTNOT_IN_CMP = 57; ! public int JJTIS_NOT_CMP = 58; ! public int JJTIS_CMP = 59; ! public int JJTOR_2OP = 60; ! public int JJTXOR_2OP = 61; ! public int JJTAND_2OP = 62; ! public int JJTLSHIFT_2OP = 63; ! public int JJTRSHIFT_2OP = 64; ! public int JJTADD_2OP = 65; ! public int JJTSUB_2OP = 66; ! public int JJTMUL_2OP = 67; ! public int JJTDIV_2OP = 68; ! public int JJTFLOORDIV_2OP = 69; ! public int JJTMOD_2OP = 70; ! public int JJTPOS_1OP = 71; ! public int JJTNEG_1OP = 72; ! public int JJTINVERT_1OP = 73; ! public int JJTPOW_2OP = 74; ! public int JJTCALL_OP = 75; ! public int JJTINDEX_OP = 76; ! public int JJTDOT_OP = 77; public int JJTLIST = 78; public int JJTDICTIONARY = 79; *************** *** 88,106 **** public int JJTSTRJOIN = 81; public int JJTLAMBDEF = 82; ! public int JJTELLIPSES = 83; ! public int JJTSLICE = 84; ! public int JJTCOLON = 85; ! public int JJTCOMMA = 86; ! public int JJTLIST_ITER = 87; ! public int JJTCLASSDEF = 88; ! public int JJTARGLIST = 89; public int JJTEXTRAARGVALUELIST = 90; public int JJTEXTRAKEYWORDVALUELIST = 91; public int JJTKEYWORD = 92; ! public int JJTINT = 93; ! public int JJTFLOAT = 94; ! public int JJTCOMPLEX = 95; ! public int JJTNAME = 96; ! public int JJTSTRING = 97; --- 88,105 ---- public int JJTSTRJOIN = 81; public int JJTLAMBDEF = 82; ! public int JJTSUBSCRIPTLIST = 83; ! public int JJTELLIPSES = 84; ! public int JJTSLICE = 85; ! public int JJTCOLON = 86; ! public int JJTCOMMA = 87; ! public int JJTLIST_FOR = 88; ! public int JJTCLASSDEF = 89; public int JJTEXTRAARGVALUELIST = 90; public int JJTEXTRAKEYWORDVALUELIST = 91; public int JJTKEYWORD = 92; ! public int JJTNUM = 93; ! public int JJTCOMPLEX = 94; ! public int JJTNAME = 95; ! public int JJTSTRING = 96; *************** *** 111,120 **** "funcdef", "void", - "varargslist", "ExtraArgList", "ExtraKeywordList", "defaultarg", ! "fplist", ! "expr_stmt", "aug_plus", "aug_minus", --- 110,117 ---- "funcdef", "void", "ExtraArgList", "ExtraKeywordList", "defaultarg", ! "tuple", "aug_plus", "aug_minus", *************** *** 129,134 **** "aug_rshift", "aug_power", "print_stmt", - "print_ext", "del_stmt", "pass_stmt", --- 126,132 ---- "aug_rshift", "aug_power", + "expr_stmt", + "printext_stmt", "print_stmt", "del_stmt", "pass_stmt", *************** *** 136,139 **** --- 134,138 ---- "continue_stmt", "return_stmt", + "yield_stmt", "raise_stmt", "Import", *************** *** 149,152 **** --- 148,152 ---- "for_stmt", "try_stmt", + "tryfinally_stmt", "except_clause", "suite", *************** *** 183,187 **** "Index_Op", "Dot_Op", - "tuple", "list", "dictionary", --- 183,186 ---- *************** *** 189,204 **** "strjoin", "lambdef", "Ellipses", "Slice", "Colon", "Comma", ! "list_iter", "classdef", - "arglist", "ExtraArgValueList", "ExtraKeywordValueList", "Keyword", ! "Int", ! "Float", "Complex", "Name", --- 188,202 ---- "strjoin", "lambdef", + "subscriptlist", "Ellipses", "Slice", "Colon", "Comma", ! "list_for", "classdef", "ExtraArgValueList", "ExtraKeywordValueList", "Keyword", ! "Num", "Complex", "Name", |
Update of /cvsroot/jython/jython/org/python/parser In directory usw-pr-cvs1:/tmp/cvs-serv17046 Modified Files: JJTPythonGrammarState.java Node.java ParseException.java SimpleNode.java Visitor.java python.jjt Added Files: TreeBuilder.java Log Message: Implementation of the new AST tree. --- NEW FILE: TreeBuilder.java --- package org.python.parser; import org.python.parser.ast.*; import org.python.core.PyObject; public class TreeBuilder implements PythonGrammarTreeConstants { private JJTPythonGrammarState stack; CtxVisitor ctx; public TreeBuilder(JJTPythonGrammarState stack) { this.stack = stack; ctx = new CtxVisitor(); } private stmtType[] makeStmts(int l) { stmtType[] stmts = new stmtType[l]; for (int i = l-1; i >= 0; i--) { stmts[i] = (stmtType) stack.popNode(); } return stmts; } private stmtType[] popSuite() { return ((Suite) popNode()).body; } private exprType[] makeExprs() { if (stack.nodeArity() > 0 && peekNode().getId() == JJTCOMMA) popNode(); return makeExprs(stack.nodeArity()); } private exprType[] makeExprs(int l) { exprType[] exprs = new exprType[l]; for (int i = l-1; i >= 0; i--) { exprs[i] = makeExpr(); } return exprs; } private exprType makeExpr(SimpleNode node) { return (exprType) node; } private exprType makeExpr() { return makeExpr((SimpleNode) stack.popNode()); } private String makeIdentifier() { return ((Name) stack.popNode()).id; } private String[] makeIdentifiers() { int l = stack.nodeArity(); String[] ids = new String[l]; for (int i = l - 1; i >= 0; i--) { ids[i] = makeIdentifier(); } return ids; } private aliasType[] makeAliases() { return makeAliases(stack.nodeArity()); } private aliasType[] makeAliases(int l) { aliasType[] aliases = new aliasType[l]; for (int i = l-1; i >= 0; i--) { aliases[i] = (aliasType) stack.popNode(); } return aliases; } private static SimpleNode[] nodes = new SimpleNode[PythonGrammarTreeConstants.jjtNodeName.length]; public SimpleNode openNode(int id) { if (nodes[id] == null) nodes[id] = new IdentityNode(id); return nodes[id]; } public SimpleNode closeNode(SimpleNode n, int arity) throws Exception { exprType value; exprType[] exprs; switch (n.getId()) { case -1: System.out.println("Illegal node"); case JJTSINGLE_INPUT: return new Interactive((stmtType) popNode()); case JJTFILE_INPUT: return new Module(makeStmts(arity)); case JJTEVAL_INPUT: return new Expression(makeExpr()); case JJTNAME: return new Name(n.getImage().toString(), Name.Load); case JJTNUM: return new Num((PyObject) n.getImage()); case JJTSTRING: return new Str(n.getImage().toString()); case JJTSUITE: stmtType[] stmts = new stmtType[arity]; for (int i = arity-1; i >= 0; i--) { stmts[i] = (stmtType) popNode(); } return new Suite(stmts); case JJTEXPR_STMT: value = makeExpr(); if (arity > 1) { exprs = makeExprs(arity-1); ctx.setStore(exprs); return new Assign(exprs, value); } else { return new Expr(value); } case JJTINDEX_OP: sliceType slice = (sliceType) stack.popNode(); value = makeExpr(); return new Subscript(value, slice, Subscript.Load); case JJTDOT_OP: String attr = makeIdentifier(); value = makeExpr(); return new Attribute(value, attr, Attribute.Load); case JJTDEL_STMT: exprs = makeExprs(arity); ctx.setDelete(exprs); return new Delete(exprs); case JJTPRINT_STMT: boolean nl = true; if (stack.nodeArity() == 0) return new Print(null, null, true); if (peekNode().getId() == JJTCOMMA) { popNode(); nl = false; } return new Print(null, makeExprs(), nl); case JJTPRINTEXT_STMT: nl = true; if (peekNode().getId() == JJTCOMMA) { popNode(); nl = false; } exprs = makeExprs(stack.nodeArity()-1); return new Print(makeExpr(), exprs, nl); case JJTFOR_STMT: stmtType[] orelse = null; if (stack.nodeArity() == 4) orelse = popSuite(); stmtType[] body = popSuite(); exprType iter = makeExpr(); exprType target = makeExpr(); ctx.setStore(target); return new For(target, iter, body, orelse); case JJTWHILE_STMT: orelse = null; if (stack.nodeArity() == 3) orelse = popSuite(); body = popSuite(); exprType test = makeExpr(); return new While(test, body, orelse); case JJTIF_STMT: orelse = null; if (arity % 2 == 1) orelse = popSuite(); body = popSuite(); test = makeExpr(); If last = new If(test, body, orelse); for (int i = 0; i < (arity / 2)-1; i++) { body = popSuite(); test = makeExpr(); last = new If(test, body, new stmtType[] { last }); } return last; case JJTPASS_STMT: return new Pass(); case JJTBREAK_STMT: return new Break(); case JJTCONTINUE_STMT: return new Continue(); case JJTFUNCDEF: body = popSuite(); argumentsType arguments = makeArguments(arity - 2); String name = makeIdentifier(); return new FunctionDef(name, arguments, body); case JJTDEFAULTARG: value = (arity == 1) ? null : makeExpr(); return new DefaultArg(makeExpr(), value); case JJTEXTRAARGLIST: return new ExtraArg(makeIdentifier(), JJTEXTRAARGLIST); case JJTEXTRAKEYWORDLIST: return new ExtraArg(makeIdentifier(), JJTEXTRAKEYWORDLIST); /* case JJTFPLIST: fpdefType[] list = new fpdefType[arity]; for (int i = arity-1; i >= 0; i--) { list[i] = popFpdef(); } return new FpList(list); */ case JJTCLASSDEF: body = popSuite(); exprType[] bases = makeExprs(stack.nodeArity() - 1); name = makeIdentifier(); return new ClassDef(name, bases, body); case JJTRETURN_STMT: value = arity == 1 ? makeExpr() : null; return new Return(value); case JJTYIELD_STMT: return new Yield(makeExpr()); case JJTRAISE_STMT: exprType tback = arity >= 3 ? makeExpr() : null; exprType inst = arity >= 2 ? makeExpr() : null; exprType type = arity >= 1 ? makeExpr() : null; return new Raise(type, inst, tback); case JJTGLOBAL_STMT: return new Global(makeIdentifiers()); case JJTEXEC_STMT: exprType globals = arity >= 3 ? makeExpr() : null; exprType locals = arity >= 2 ? makeExpr() : null; value = makeExpr(); return new Exec(value, locals, globals); case JJTASSERT_STMT: exprType msg = arity == 2 ? makeExpr() : null; test = makeExpr(); return new Assert(test, msg); case JJTTRYFINALLY_STMT: orelse = popSuite(); return new TryFinally(popSuite(), orelse); case JJTTRY_STMT: orelse = null; if (peekNode() instanceof Suite) { arity--; orelse = popSuite(); } int l = arity - 1; excepthandlerType[] handlers = new excepthandlerType[l]; for (int i = l - 1; i >= 0; i--) { handlers[i] = (excepthandlerType) popNode(); } return new TryExcept(popSuite(), handlers, orelse); case JJTEXCEPT_CLAUSE: body = popSuite(); exprType excname = arity == 3 ? makeExpr() : null; if (excname != null) ctx.setStore(excname); type = arity >= 2 ? makeExpr() : null; return new excepthandlerType(type, excname, body); case JJTOR_BOOLEAN: return new BoolOp(BoolOp.Or, makeExprs()); case JJTAND_BOOLEAN: return new BoolOp(BoolOp.And, makeExprs()); case JJTCOMPARISION: l = arity / 2; exprType[] comparators = new exprType[l]; int[] ops = new int[l]; for (int i = l-1; i >= 0; i--) { comparators[i] = makeExpr(); SimpleNode op = (SimpleNode) stack.popNode(); switch (op.getId()) { case JJTLESS_CMP: ops[i] = Compare.Lt; break; case JJTGREATER_CMP: ops[i] = Compare.Gt; break; case JJTEQUAL_CMP: ops[i] = Compare.Eq; break; case JJTGREATER_EQUAL_CMP: ops[i] = Compare.GtE; break; case JJTLESS_EQUAL_CMP: ops[i] = Compare.LtE; break; case JJTNOTEQUAL_CMP: ops[i] = Compare.NotEq; break; case JJTIN_CMP: ops[i] = Compare.In; break; case JJTNOT_IN_CMP: ops[i] = Compare.NotIn; break; case JJTIS_NOT_CMP: ops[i] = Compare.IsNot; break; case JJTIS_CMP: ops[i] = Compare.Is; break; default: throw new RuntimeException("Unknown cmp op:" + op.getId()); } } return new Compare(makeExpr(), ops, comparators); case JJTLESS_CMP: case JJTGREATER_CMP: case JJTEQUAL_CMP: case JJTGREATER_EQUAL_CMP: case JJTLESS_EQUAL_CMP: case JJTNOTEQUAL_CMP: case JJTIN_CMP: case JJTNOT_IN_CMP: case JJTIS_NOT_CMP: case JJTIS_CMP: return n; case JJTOR_2OP: return makeBinOp(BinOp.BitOr); case JJTXOR_2OP: return makeBinOp(BinOp.BitXor); case JJTAND_2OP: return makeBinOp(BinOp.BitAnd); case JJTLSHIFT_2OP: return makeBinOp(BinOp.LShift); case JJTRSHIFT_2OP: return makeBinOp(BinOp.RShift); case JJTADD_2OP: return makeBinOp(BinOp.Add); case JJTSUB_2OP: return makeBinOp(BinOp.Sub); case JJTMUL_2OP: return makeBinOp(BinOp.Mult); case JJTDIV_2OP: return makeBinOp(BinOp.Div); case JJTMOD_2OP: return makeBinOp(BinOp.Mod); case JJTPOW_2OP: return makeBinOp(BinOp.Pow); case JJTFLOORDIV_2OP: return makeBinOp(BinOp.FloorDiv); case JJTPOS_1OP: return new UnaryOp(UnaryOp.UAdd, makeExpr()); case JJTNEG_1OP: return new UnaryOp(UnaryOp.USub, makeExpr()); case JJTINVERT_1OP: return new UnaryOp(UnaryOp.Invert, makeExpr()); case JJTNOT_1OP: return new UnaryOp(UnaryOp.Not, makeExpr()); case JJTCALL_OP: //if (arity == 1) // return new Call(makeExpr(), null, null, null, null); exprType starargs = null; exprType kwargs = null; l = arity - 1; if (l > 0 && peekNode().getId() == JJTEXTRAKEYWORDVALUELIST) { kwargs = ((ExtraArgValue) popNode()).value; l--; } if (l > 0 && peekNode().getId() == JJTEXTRAARGVALUELIST) { starargs = ((ExtraArgValue) popNode()).value; l--; } int nargs = l; SimpleNode[] tmparr = new SimpleNode[l]; for (int i = l - 1; i >= 0; i--) { tmparr[i] = popNode(); if (tmparr[i] instanceof keywordType) { nargs = i; } } exprType[] args = new exprType[nargs]; for (int i = 0; i < nargs; i++) { args[i] = makeExpr(tmparr[i]); } keywordType[] keywords = new keywordType[l - nargs]; for (int i = nargs; i < l; i++) { if (!(tmparr[i] instanceof keywordType)) throw new ParseException( "non-keyword argument following keyword", tmparr[i]); keywords[i - nargs] = (keywordType) tmparr[i]; } exprType func = makeExpr(); return new Call(func, args, keywords, starargs, kwargs); case JJTEXTRAKEYWORDVALUELIST: return new ExtraArgValue(makeExpr(), JJTEXTRAKEYWORDVALUELIST); case JJTEXTRAARGVALUELIST: return new ExtraArgValue(makeExpr(), JJTEXTRAARGVALUELIST); case JJTKEYWORD: value = makeExpr(); name = makeIdentifier(); return new keywordType(name, value); case JJTTUPLE: return new Tuple(makeExprs(), Tuple.Load); case JJTLIST: if (peekNode() instanceof listcompType) { listcompType[] generators = new listcompType[arity-1]; for (int i = arity-2; i >= 0; i--) { generators[i] = (listcompType) popNode(); } return new ListComp(makeExpr(), generators); } return new List(makeExprs(), List.Load); case JJTDICTIONARY: l = arity / 2; exprType[] keys = new exprType[l]; exprType[] vals = new exprType[l]; for (int i = l - 1; i >= 0; i--) { vals[i] = makeExpr(); keys[i] = makeExpr(); } return new Dict(keys, vals); case JJTSTR_1OP: return new Repr(makeExpr()); case JJTSTRJOIN: String str2 = ((Str) popNode()).s; String str1 = ((Str) popNode()).s; return new Str(str1 + str2); case JJTLAMBDEF: test = makeExpr(); arguments = makeArguments(arity - 1); return new Lambda(arguments, test); case JJTELLIPSES: return new Ellipsis(); case JJTSLICE: SimpleNode[] arr = new SimpleNode[arity]; for (int i = arity-1; i >= 0; i--) { arr[i] = popNode(); } exprType[] values = new exprType[3]; int k = 0; for (int j = 0; j < arity; j++) { if (arr[j].getId() == JJTCOLON) k++; else values[k] = makeExpr(arr[j]); } if (k == 0) { return new Index(values[0]); } else { return new Slice(values[0], values[1], values[2]); } case JJTSUBSCRIPTLIST: sliceType[] dims = new sliceType[arity]; for (int i = arity - 1; i >= 0; i--) { dims[i] = (sliceType) popNode(); } return new ExtSlice(dims); case JJTAUG_PLUS: return makeAugAssign(AugAssign.Add); case JJTAUG_MINUS: return makeAugAssign(AugAssign.Sub); case JJTAUG_MULTIPLY: return makeAugAssign(AugAssign.Mult); case JJTAUG_DIVIDE: return makeAugAssign(AugAssign.Div); case JJTAUG_MODULO: return makeAugAssign(AugAssign.Mod); case JJTAUG_AND: return makeAugAssign(AugAssign.BitAnd); case JJTAUG_OR: return makeAugAssign(AugAssign.BitOr); case JJTAUG_XOR: return makeAugAssign(AugAssign.BitXor); case JJTAUG_LSHIFT: return makeAugAssign(AugAssign.LShift); case JJTAUG_RSHIFT: return makeAugAssign(AugAssign.RShift); case JJTAUG_POWER: return makeAugAssign(AugAssign.Pow); case JJTAUG_FLOORDIVIDE: return makeAugAssign(AugAssign.FloorDiv); case JJTLIST_FOR: exprType[] ifs = new exprType[arity-2]; for (int i = arity-3; i >= 0; i--) { ifs[i] = makeExpr(); } iter = makeExpr(); target = makeExpr(); ctx.setStore(target); return new listcompType(target, iter, ifs); case JJTIMPORTFROM: aliasType[] aliases = makeAliases(arity - 1); String module = makeIdentifier(); return new ImportFrom(module, aliases); case JJTIMPORT: return new Import(makeAliases()); case JJTDOTTED_NAME: StringBuffer sb = new StringBuffer(); for (int i = 0; i < arity; i++) { if (i > 0) sb.insert(0, '.'); sb.insert(0, makeIdentifier()); } return new Name(sb.toString(), Name.Load); case JJTDOTTED_AS_NAME: String asname = null; if (arity > 1) asname = makeIdentifier(); return new aliasType(makeIdentifier(), asname); case JJTIMPORT_AS_NAME: asname = null; if (arity > 1) asname = makeIdentifier(); return new aliasType(makeIdentifier(), asname); case JJTCOMMA: case JJTCOLON: return n; default: return null; } } private stmtType makeAugAssign(int op) throws Exception { exprType value = makeExpr(); exprType target = makeExpr(); ctx.setAugStore(target); return new AugAssign(target, op, value); } private void dumpStack() { int n = stack.nodeArity(); System.out.println("nodeArity:" + n); if (n > 0) { System.out.println("peek:" + stack.peekNode()); } } SimpleNode peekNode() { return (SimpleNode) stack.peekNode(); } SimpleNode popNode() { return (SimpleNode) stack.popNode(); } BinOp makeBinOp(int op) { exprType right = makeExpr(); exprType left = makeExpr(); return new BinOp(left, op, right); } argumentsType makeArguments(int l) throws Exception { String kwarg = null; String stararg = null; if (l > 0 && peekNode().getId() == JJTEXTRAKEYWORDLIST) { kwarg = ((ExtraArg) popNode()).name; l--; } if (l > 0 && peekNode().getId() == JJTEXTRAARGLIST) { stararg = ((ExtraArg) popNode()).name; l--; } int startofdefaults = l; exprType fpargs[] = new exprType[l]; exprType defaults[] = new exprType[l]; for (int i = l-1; i >= 0; i--) { DefaultArg node = (DefaultArg) popNode(); fpargs[i] = node.parameter; ctx.setStore(fpargs[i]); defaults[i] = node.value; if (node.value != null) startofdefaults = i; } //System.out.println("start "+ startofdefaults + " " + l); exprType[] newdefs = new exprType[l-startofdefaults]; System.arraycopy(defaults, startofdefaults, newdefs, 0, newdefs.length); return new argumentsType(fpargs, stararg, kwarg, newdefs); } } class DefaultArg extends SimpleNode { public exprType parameter; public exprType value; DefaultArg(exprType parameter, exprType value) { this.parameter = parameter; this.value = value; } } class ExtraArg extends SimpleNode { public String name; public int id; ExtraArg(String name, int id) { this.name = name; this.id = id; } public int getId() { return id; } } class ExtraArgValue extends SimpleNode { public exprType value; public int id; ExtraArgValue(exprType value, int id) { this.value = value; this.id = id; } public int getId() { return id; } } class IdentityNode extends SimpleNode { public int id; public Object image; IdentityNode(int id) { this.id = id; } public int getId() { return id; } public void setImage(Object image) { this.image = image; } public Object getImage() { return image; } public String toString() { return "IdNode[" + PythonGrammarTreeConstants.jjtNodeName[id] + ", " + image + "]"; } } class CtxVisitor extends Visitor { private int ctx; public CtxVisitor() { } public void setStore(SimpleNode node) throws Exception { this.ctx = expr_contextType.Store; visit(node); } public void setStore(SimpleNode[] nodes) throws Exception { for (int i = 0; i < nodes.length; i++) setStore(nodes[i]); } public void setDelete(SimpleNode node) throws Exception { this.ctx = expr_contextType.Del; visit(node); } public void setDelete(SimpleNode[] nodes) throws Exception { for (int i = 0; i < nodes.length; i++) setDelete(nodes[i]); } public void setAugStore(SimpleNode node) throws Exception { this.ctx = expr_contextType.AugStore; visit(node); } public Object visitName(Name node) throws Exception { node.ctx = ctx; return null; } public Object visitAttribute(Attribute node) throws Exception { node.ctx = ctx; return null; } public Object visitSubscript(Subscript node) throws Exception { node.ctx = ctx; return null; } public Object visitList(List node) throws Exception { if (ctx == expr_contextType.AugStore) { throw new ParseException( "augmented assign to list not possible", node); } node.ctx = ctx; traverse(node); return null; } public Object visitTuple(Tuple node) throws Exception { if (ctx == expr_contextType.AugStore) { throw new ParseException( "augmented assign to tuple not possible", node); } node.ctx = ctx; traverse(node); return null; } public Object visitCall(Call node) throws Exception { throw new ParseException("can't assign to function call", node); } public Object visitListComp(Call node) throws Exception { throw new ParseException("can't assign to list comprehension call", node); } public Object unhandled_node(SimpleNode node) throws Exception { throw new ParseException("can't assign to operator", node); } } Index: JJTPythonGrammarState.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/parser/JJTPythonGrammarState.java,v retrieving revision 2.2 retrieving revision 2.3 diff -C2 -d -r2.2 -r2.3 *** JJTPythonGrammarState.java 6 Jan 2002 21:19:14 -0000 2.2 --- JJTPythonGrammarState.java 30 May 2002 16:08:02 -0000 2.3 *************** *** 1,123 **** ! /* Generated By:JJTree: Do not edit this line. D:/jython/CVS/org/python/parser\JJTPythonGrammarState.java */ package org.python.parser; class JJTPythonGrammarState { ! private java.util.Stack nodes; ! private java.util.Stack marks; ! private int sp; // number of nodes on stack ! private int mk; // current mark ! private boolean node_created; ! JJTPythonGrammarState() { ! nodes = new java.util.Stack(); ! marks = new java.util.Stack(); ! sp = 0; ! mk = 0; ! } ! /* Determines whether the current node was actually closed and ! pushed. This should only be called in the final user action of a ! node scope. */ ! boolean nodeCreated() { ! return node_created; ! } ! /* Call this to reinitialize the node stack. It is called ! automatically by the parser's ReInit() method. */ ! void reset() { ! nodes.removeAllElements(); ! marks.removeAllElements(); ! sp = 0; ! mk = 0; ! } ! /* Returns the root node of the AST. It only makes sense to call ! this after a successful parse. */ ! Node rootNode() { ! return (Node)nodes.elementAt(0); ! } ! /* Pushes a node on to the stack. */ ! void pushNode(Node n) { ! nodes.push(n); ! ++sp; ! } ! /* Returns the node on the top of the stack, and remove it from the ! stack. */ ! Node popNode() { ! if (--sp < mk) { ! mk = ((Integer)marks.pop()).intValue(); } - return (Node)nodes.pop(); - } ! /* Returns the node currently on the top of the stack. */ ! Node peekNode() { ! return (Node)nodes.peek(); ! } ! /* Returns the number of children on the stack in the current node ! scope. */ ! int nodeArity() { ! return sp - mk; ! } ! void clearNodeScope(Node n) { ! while (sp > mk) { ! popNode(); } - mk = ((Integer)marks.pop()).intValue(); - } - void openNodeScope(Node n) { - marks.push(new Integer(mk)); - mk = sp; - n.jjtOpen(); - } ! /* A definite node is constructed from a specified number of ! children. That number of nodes are popped from the stack and ! made the children of the definite node. Then the definite node ! is pushed on to the stack. */ ! void closeNodeScope(Node n, int num) { ! mk = ((Integer)marks.pop()).intValue(); ! while (num-- > 0) { ! Node c = popNode(); ! c.jjtSetParent(n); ! n.jjtAddChild(c, num); } - n.jjtClose(); - pushNode(n); - node_created = true; - } ! /* A conditional node is constructed if its condition is true. All ! the nodes that have been pushed since the node was opened are ! made children of the the conditional node, which is then pushed ! on to the stack. If the condition is false the node is not ! constructed and they are left on the stack. */ ! void closeNodeScope(Node n, boolean condition) { ! if (condition) { ! int a = nodeArity(); ! mk = ((Integer)marks.pop()).intValue(); ! while (a-- > 0) { ! Node c = popNode(); ! c.jjtSetParent(n); ! n.jjtAddChild(c, a); ! } ! n.jjtClose(); ! pushNode(n); ! node_created = true; ! } else { ! mk = ((Integer)marks.pop()).intValue(); ! node_created = false; } - } } --- 1,219 ---- ! /* Generated By:JJTree: Do not edit this line. D:/jython/CVS.parser/org/python/parser\JJTPythonGrammarState.java */ ! ! // Modified by hand. The two closeNodeScope method have been rewritten ! // completely and is used when building the AST tree bottom-up. package org.python.parser; class JJTPythonGrammarState { ! private java.util.Stack nodes; ! private IntStack marks; ! private IntStack lines; ! private IntStack columns; ! private int sp; // number of nodes on stack ! private int mk; // current mark ! private boolean node_created; ! private TreeBuilder builder; ! JJTPythonGrammarState() { ! nodes = new java.util.Stack(); ! marks = new IntStack(); ! lines = new IntStack(); ! columns = new IntStack(); ! sp = 0; ! mk = 0; ! builder = new TreeBuilder(this); ! } ! /* Determines whether the current node was actually closed and ! pushed. This should only be called in the final user action of a ! node scope. */ ! boolean nodeCreated() { ! return node_created; ! } ! /* Call this to reinitialize the node stack. It is called ! automatically by the parser's ReInit() method. */ ! void reset() { ! nodes.removeAllElements(); ! marks.removeAllElements(); ! sp = 0; ! mk = 0; ! } ! /* Returns the root node of the AST. It only makes sense to call ! this after a successful parse. */ ! Node rootNode() { ! return (Node)nodes.elementAt(0); ! } ! /* Pushes a node on to the stack. */ ! void pushNode(Node n) { ! nodes.push(n); ! ++sp; } ! /* Returns the node on the top of the stack, and remove it from the ! stack. */ ! Node popNode() { ! if (--sp < mk) { ! mk = marks.pop(); ! } ! return (Node)nodes.pop(); ! } ! /* Returns the node currently on the top of the stack. */ ! Node peekNode() { ! return (Node)nodes.peek(); ! } + /* Returns the number of children on the stack in the current node + scope. */ + int nodeArity() { + return sp - mk; + } ! void pushNodePos(int line, int col) { ! lines.push(line); ! columns.push(col); } + void setNodePos() { + SimpleNode n = (SimpleNode) peekNode(); + n.beginLine = lines.pop(); + n.beginColumn = columns.pop(); + } + void clearNodeScope(Node n) { + while (sp > mk) { + popNode(); + } + mk = marks.pop(); + } ! ! void openNodeScope(Node n) { ! marks.push(mk); ! mk = sp; } ! /* A definite node is constructed from a specified number of ! children. That number of nodes are popped from the stack and ! made the children of the definite node. Then the definite node ! is pushed on to the stack. */ ! void closeNodeScope(Node n, int num) throws ParseException { ! SimpleNode sn = (SimpleNode) n; ! mk = marks.pop(); ! SimpleNode newNode = null; ! try { ! newNode = builder.closeNode(sn, num); ! } catch (ParseException exc) { ! throw exc; ! } catch (Exception exc) { ! exc.printStackTrace(); ! throw new ParseException("Internal error:" + exc); ! } ! if (newNode == null) { ! throw new ParseException("Internal AST builder error"); ! } ! pushNode(newNode); ! node_created = true; ! } ! ! ! /* A conditional node is constructed if its condition is true. All ! the nodes that have been pushed since the node was opened are ! made children of the the conditional node, which is then pushed ! on to the stack. If the condition is false the node is not ! constructed and they are left on the stack. */ ! void closeNodeScope(Node n, boolean condition) throws ParseException { ! SimpleNode sn = (SimpleNode) n; ! if (condition) { ! SimpleNode newNode = null; ! try { ! newNode = builder.closeNode(sn, nodeArity()); ! } catch (ParseException exc) { ! throw exc; ! } catch (Exception exc) { ! exc.printStackTrace(); ! throw new ParseException("Internal error:" + exc); ! } ! if (newNode == null) { ! throw new ParseException("Internal AST builder error"); ! } ! mk = marks.pop(); ! pushNode(newNode); ! node_created = true; ! } else { ! mk = marks.pop(); ! node_created = false; ! } ! } ! ! public void dumpTop(String reason) { ! int a = nodeArity(); ! System.out.println("dumpTop:" + reason); ! System.out.println("arity:" + a); ! for (int i = 0; i < a; i++) { ! Node n = (Node) nodes.elementAt(nodes.size() - i-1); ! System.out.println(" " + n); ! } ! } ! ! public Node openNode(int id) { ! return builder.openNode(id); ! } ! ! public void dump(String reason) { ! int a = nodeArity(); ! System.out.println("dump:" + reason); ! System.out.println(" mk:" + mk + " sp:" + sp); ! for (int i = 0; i < nodes.size(); i++) { ! Node n = (Node) nodes.elementAt(i); ! System.out.println(" " + n); ! } ! for (int i = 0; i < marks.size(); i++) { ! System.out.println(" " + marks.elementAt(i)); ! } ! } ! } ! ! ! class IntStack { ! int[] stack; ! int sp = 0; ! ! public IntStack() { ! stack = new int[50]; ! } ! ! ! public void removeAllElements() { ! sp = 0; ! } ! ! public int size() { ! return sp; ! } ! ! public int elementAt(int idx) { ! return stack[idx]; ! } ! ! public void push(int val) { ! if (sp >= stack.length) { ! int[] newstack = new int[sp*2]; ! System.arraycopy(stack, 0, newstack, 0, sp); ! stack = newstack; ! } ! stack[sp++] = val; ! } ! ! public int pop() { ! return stack[--sp]; } } Index: Node.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/parser/Node.java,v retrieving revision 2.1 retrieving revision 2.2 diff -C2 -d -r2.1 -r2.2 *** Node.java 3 Mar 1999 21:42:26 -0000 2.1 --- Node.java 30 May 2002 16:08:02 -0000 2.2 *************** *** 9,34 **** public interface Node { - /** This method is called after the node has been made the current - node. It indicates that child nodes can now be added to it. */ - public void jjtOpen(); - - /** This method is called after all the child nodes have been - added. */ - public void jjtClose(); - - /** This pair of methods are used to inform the node of its - parent. */ - public void jjtSetParent(Node n); - public Node jjtGetParent(); - - /** This method tells the node to add its argument to the node's - list of children. */ - public void jjtAddChild(Node n, int i); - - /** This method returns a child node. The children are numbered - from zero, left to right. */ - public Node jjtGetChild(int i); - - /** Return the number of children the node has. */ - public int jjtGetNumChildren(); } --- 9,12 ---- public interface Node { } + Index: ParseException.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/parser/ParseException.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ParseException.java 29 Jan 1999 15:37:58 -0000 1.3 --- ParseException.java 30 May 2002 16:08:02 -0000 1.4 *************** *** 63,68 **** t.beginLine = node.beginLine; t.beginColumn = node.beginColumn; - t.endLine = node.endLine; - t.endColumn = node.endColumn; currentToken = new Token(); --- 63,66 ---- *************** *** 71,76 **** t.beginLine = node.beginLine; t.beginColumn = node.beginColumn; - t.endLine = node.endLine; - t.endColumn = node.endColumn; specialConstructor = false; --- 69,72 ---- Index: SimpleNode.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/parser/SimpleNode.java,v retrieving revision 2.18 retrieving revision 2.19 diff -C2 -d -r2.18 -r2.19 *** SimpleNode.java 13 Jan 2002 18:23:08 -0000 2.18 --- SimpleNode.java 30 May 2002 16:08:02 -0000 2.19 *************** *** 2,366 **** package org.python.parser; ! import org.python.core.Py; ! import org.python.core.PyString; ! public class SimpleNode implements Node ! { ! protected Node parent; ! public SimpleNode[] children; ! public int id; ! protected PythonGrammar parser; ! public int endLine, endColumn, beginLine, beginColumn; ! Object info; ! public int aug_tmp1, aug_tmp2, aug_tmp3, aug_tmp4; - public org.python.compiler.ScopeInfo scope; // for nested scopes public boolean from_future_checked = false; // from __future__ support ! public SimpleNode(int i) { ! id = i; ! } ! ! public SimpleNode(PythonGrammar p, int i) { ! this(i); ! parser = p; ! } ! public static Node jjtCreate(int id) { ! return new SimpleNode(id); } ! public static Node jjtCreate(PythonGrammar p, int id) { ! return new SimpleNode(p, id); } ! public void jjtOpen() { } ! public void jjtClose() { } ! public void jjtSetParent(Node n) { parent = n; } ! public Node jjtGetParent() { return parent; } ! public void jjtAddChild(Node n, int i) { ! if (children == null) { ! children = new SimpleNode[i + 1]; ! } else if (i >= children.length) { ! SimpleNode c[] = new SimpleNode[i + 1]; ! System.arraycopy(children, 0, c, 0, children.length); ! children = c; ! } ! children[i] = (SimpleNode)n; } ! public Node jjtGetChild(int i) { ! return children[i]; } ! public int jjtGetNumChildren() { ! return (children == null) ? 0 : children.length; } ! public SimpleNode getChild(int i) { ! return children[i]; } ! public int getNumChildren() { ! return (children == null) ? 0 : children.length; } ! public Object getInfo() { return info; } ! public void setInfo(Object o) { ! info = o; ! //System.out.println("name: "+info); } ! public void setString(String s, int quotes) { ! info = parseString(s, quotes, beginLine, beginColumn); } ! public static String parseString(String s, int quotes, ! int beginLine, int beginColumn) { ! //System.out.println("string: "+s); ! char quoteChar = s.charAt(0); ! int start=0; ! boolean ustring = false; ! if (quoteChar == 'u' || quoteChar == 'U') { ! ustring = true; ! start++; ! } ! quoteChar = s.charAt(start); ! if (quoteChar == 'r' || quoteChar == 'R') { ! return s.substring(quotes+start+1, s.length()-quotes); } else { ! StringBuffer sb = new StringBuffer(s.length()); ! char[] ca = s.toCharArray(); ! int n = ca.length-quotes; ! int i=quotes+start; ! int last_i=i; ! ! return PyString.decode_UnicodeEscape(s, i, n, "strict", ustring); } } ! public void setInteger(String s, int radix) { ! if (s.endsWith("j") || s.endsWith("J")) { ! setFloat(s); } else { ! if (s.endsWith("L") || s.endsWith("l")) { ! s = s.substring(0, s.length()-1); ! if (radix == 10) setInfo(s); ! else setInfo(new java.math.BigInteger(s, radix).toString()); ! } else { ! int ndigits = s.length(); ! int i=0; ! while (i < ndigits && s.charAt(i) == '0') i++; ! if ((ndigits - i) > 11) { ! throw Py.OverflowError("integer literal too large"); ! } ! long l = Long.valueOf(s, radix).longValue(); ! if (l > 0xffffffffl || (radix == 10 && l > Integer.MAX_VALUE)) ! { ! throw Py.OverflowError("integer literal too large"); ! } ! setInfo(new Integer((int)l)); } } } ! public void setFloat(String s) { ! if (s.endsWith("j") || s.endsWith("J")) { ! setInfo(Double.valueOf(s.substring(0, s.length()-1))); ! id = PythonGrammarTreeConstants.JJTCOMPLEX; } else { ! setInfo(Double.valueOf(s)); } } ! /* You can override these two methods in subclasses of SimpleNode to ! customize the way the node appears when the tree is dumped. If ! your output uses more than one line you should override ! toString(String), otherwise overriding toString() is probably all ! you need to do. */ ! ! public String toString() { ! return PythonGrammarTreeConstants.jjtNodeName[id]+":"+info+ ! " at line "+beginLine; } - public String toString(String prefix) { return prefix + toString(); } ! /* Override this method if you want to customize how the node dumps ! out its children. */ ! public void dump(String prefix) { ! System.out.println(toString(prefix)); ! if (children != null) { ! for (int i = 0; i < children.length; ++i) { ! SimpleNode n = (SimpleNode)children[i]; ! if (n != null) { ! n.dump(prefix + " "); ! } } } } ! public Object visit(Visitor visitor) throws Exception { ! switch(id) { ! case PythonGrammarTreeConstants.JJTSINGLE_INPUT: ! return visitor.single_input(this); ! case PythonGrammarTreeConstants.JJTFILE_INPUT: ! return visitor.file_input(this); ! case PythonGrammarTreeConstants.JJTEVAL_INPUT: ! return visitor.eval_input(this); ! case PythonGrammarTreeConstants.JJTFUNCDEF: ! return visitor.funcdef(this); ! case PythonGrammarTreeConstants.JJTVARARGSLIST: ! return visitor.varargslist(this); ! case PythonGrammarTreeConstants.JJTEXTRAARGLIST: ! return visitor.ExtraArgList(this); ! case PythonGrammarTreeConstants.JJTEXTRAKEYWORDLIST: ! return visitor.ExtraKeywordList(this); ! case PythonGrammarTreeConstants.JJTDEFAULTARG: ! return visitor.defaultarg(this); ! case PythonGrammarTreeConstants.JJTFPLIST: ! return visitor.fplist(this); ! case PythonGrammarTreeConstants.JJTEXPR_STMT: ! return visitor.expr_stmt(this); ! case PythonGrammarTreeConstants.JJTPRINT_STMT: ! return visitor.print_stmt(this); ! case PythonGrammarTreeConstants.JJTPRINT_EXT: ! return visitor.print_ext(this); ! case PythonGrammarTreeConstants.JJTDEL_STMT: ! return visitor.del_stmt(this); ! case PythonGrammarTreeConstants.JJTPASS_STMT: ! return visitor.pass_stmt(this); ! case PythonGrammarTreeConstants.JJTBREAK_STMT: ! return visitor.break_stmt(this); ! case PythonGrammarTreeConstants.JJTCONTINUE_STMT: ! return visitor.continue_stmt(this); ! case PythonGrammarTreeConstants.JJTRETURN_STMT: ! return visitor.return_stmt(this); ! case PythonGrammarTreeConstants.JJTRAISE_STMT: ! return visitor.raise_stmt(this); ! case PythonGrammarTreeConstants.JJTIMPORT: ! return visitor.Import(this); ! case PythonGrammarTreeConstants.JJTIMPORTFROM: ! return visitor.ImportFrom(this); ! case PythonGrammarTreeConstants.JJTDOTTED_NAME: ! return visitor.dotted_name(this); ! case PythonGrammarTreeConstants.JJTGLOBAL_STMT: ! return visitor.global_stmt(this); ! case PythonGrammarTreeConstants.JJTEXEC_STMT: ! return visitor.exec_stmt(this); ! case PythonGrammarTreeConstants.JJTASSERT_STMT: ! return visitor.assert_stmt(this); ! case PythonGrammarTreeConstants.JJTIF_STMT: ! return visitor.if_stmt(this); ! case PythonGrammarTreeConstants.JJTWHILE_STMT: ! return visitor.while_stmt(this); ! case PythonGrammarTreeConstants.JJTFOR_STMT: ! return visitor.for_stmt(this); ! case PythonGrammarTreeConstants.JJTTRY_STMT: ! return visitor.try_stmt(this); ! case PythonGrammarTreeConstants.JJTEXCEPT_CLAUSE: ! return visitor.except_clause(this); ! case PythonGrammarTreeConstants.JJTSUITE: ! return visitor.suite(this); ! case PythonGrammarTreeConstants.JJTOR_BOOLEAN: ! return visitor.or_boolean(this); ! case PythonGrammarTreeConstants.JJTAND_BOOLEAN: ! return visitor.and_boolean(this); ! case PythonGrammarTreeConstants.JJTNOT_1OP: ! return visitor.not_1op(this); ! case PythonGrammarTreeConstants.JJTCOMPARISION: ! return visitor.comparision(this); ! case PythonGrammarTreeConstants.JJTLESS_CMP: ! return visitor.less_cmp(this); ! case PythonGrammarTreeConstants.JJTGREATER_CMP: ! return visitor.greater_cmp(this); ! case PythonGrammarTreeConstants.JJTEQUAL_CMP: ! return visitor.equal_cmp(this); ! case PythonGrammarTreeConstants.JJTGREATER_EQUAL_CMP: ! return visitor.greater_equal_cmp(this); ! case PythonGrammarTreeConstants.JJTLESS_EQUAL_CMP: ! return visitor.less_equal_cmp(this); ! case PythonGrammarTreeConstants.JJTNOTEQUAL_CMP: ! return visitor.notequal_cmp(this); ! case PythonGrammarTreeConstants.JJTIN_CMP: ! return visitor.in_cmp(this); ! case PythonGrammarTreeConstants.JJTNOT_IN_CMP: ! return visitor.not_in_cmp(this); ! case PythonGrammarTreeConstants.JJTIS_NOT_CMP: ! return visitor.is_not_cmp(this); ! case PythonGrammarTreeConstants.JJTIS_CMP: ! return visitor.is_cmp(this); ! case PythonGrammarTreeConstants.JJTOR_2OP: ! return visitor.or_2op(this); ! case PythonGrammarTreeConstants.JJTXOR_2OP: ! return visitor.xor_2op(this); ! case PythonGrammarTreeConstants.JJTAND_2OP: ! return visitor.and_2op(this); ! case PythonGrammarTreeConstants.JJTLSHIFT_2OP: ! return visitor.lshift_2op(this); ! case PythonGrammarTreeConstants.JJTRSHIFT_2OP: ! return visitor.rshift_2op(this); ! case PythonGrammarTreeConstants.JJTADD_2OP: ! return visitor.add_2op(this); ! case PythonGrammarTreeConstants.JJTSUB_2OP: ! return visitor.sub_2op(this); ! case PythonGrammarTreeConstants.JJTMUL_2OP: ! return visitor.mul_2op(this); ! case PythonGrammarTreeConstants.JJTDIV_2OP: ! return visitor.div_2op(this); ! case PythonGrammarTreeConstants.JJTFLOORDIV_2OP: ! return visitor.floordiv_2op(this); ! case PythonGrammarTreeConstants.JJTMOD_2OP: ! return visitor.mod_2op(this); ! case PythonGrammarTreeConstants.JJTPOS_1OP: ! return visitor.pos_1op(this); ! case PythonGrammarTreeConstants.JJTNEG_1OP: ! return visitor.neg_1op(this); ! case PythonGrammarTreeConstants.JJTINVERT_1OP: ! return visitor.invert_1op(this); ! case PythonGrammarTreeConstants.JJTPOW_2OP: ! return visitor.pow_2op(this); ! case PythonGrammarTreeConstants.JJTCALL_OP: ! return visitor.Call_Op(this); ! case PythonGrammarTreeConstants.JJTINDEX_OP: ! return visitor.Index_Op(this); ! case PythonGrammarTreeConstants.JJTDOT_OP: ! return visitor.Dot_Op(this); ! case PythonGrammarTreeConstants.JJTTUPLE: ! return visitor.tuple(this); ! case PythonGrammarTreeConstants.JJTLIST: ! return visitor.list(this); ! case PythonGrammarTreeConstants.JJTDICTIONARY: ! return visitor.dictionary(this); ! case PythonGrammarTreeConstants.JJTSTR_1OP: ! return visitor.str_1op(this); ! case PythonGrammarTreeConstants.JJTSTRJOIN: ! return visitor.strjoin(this); ! case PythonGrammarTreeConstants.JJTLAMBDEF: ! return visitor.lambdef(this); ! case PythonGrammarTreeConstants.JJTELLIPSES: ! return visitor.Ellipses(this); ! case PythonGrammarTreeConstants.JJTSLICE: ! return visitor.Slice(this); ! case PythonGrammarTreeConstants.JJTCOLON: ! return visitor.Colon(this); ! case PythonGrammarTreeConstants.JJTCOMMA: ! return visitor.Comma(this); ! case PythonGrammarTreeConstants.JJTCLASSDEF: ! return visitor.classdef(this); ! case PythonGrammarTreeConstants.JJTARGLIST: ! return visitor.arglist(this); ! case PythonGrammarTreeConstants.JJTKEYWORD: ! return visitor.Keyword(this); ! case PythonGrammarTreeConstants.JJTINT: ! return visitor.Int(this); ! case PythonGrammarTreeConstants.JJTFLOAT: ! return visitor.Float(this); ! case PythonGrammarTreeConstants.JJTCOMPLEX: ! return visitor.Complex(this); ! case PythonGrammarTreeConstants.JJTNAME: ! return visitor.Name(this); ! case PythonGrammarTreeConstants.JJTSTRING: ! return visitor.String(this); ! case PythonGrammarTreeConstants.JJTAUG_PLUS: ! return visitor.aug_plus(this); ! case PythonGrammarTreeConstants.JJTAUG_MINUS: ! return visitor.aug_minus(this); ! case PythonGrammarTreeConstants.JJTAUG_MULTIPLY: ! return visitor.aug_multiply(this); ! case PythonGrammarTreeConstants.JJTAUG_DIVIDE: ! return visitor.aug_divide(this); ! case PythonGrammarTreeConstants.JJTAUG_FLOORDIVIDE: ! return visitor.aug_floordivide(this); ! case PythonGrammarTreeConstants.JJTAUG_MODULO: ! return visitor.aug_modulo(this); ! case PythonGrammarTreeConstants.JJTAUG_AND: ! return visitor.aug_and(this); ! case PythonGrammarTreeConstants.JJTAUG_OR: ! return visitor.aug_or(this); ! case PythonGrammarTreeConstants.JJTAUG_XOR: ! return visitor.aug_xor(this); ! case PythonGrammarTreeConstants.JJTAUG_LSHIFT: ! return visitor.aug_lshift(this); ! case PythonGrammarTreeConstants.JJTAUG_RSHIFT: ! return visitor.aug_rshift(this); ! case PythonGrammarTreeConstants.JJTAUG_POWER: ! return visitor.aug_power(this); ! case PythonGrammarTreeConstants.JJTLIST_ITER: ! return visitor.list_iter(this); ! default: ! throw new ParseException("Unexpected node: "+this); ! } ! } } --- 2,192 ---- package org.python.parser; ! import org.python.core.PyObject; ! import org.python.parser.ast.*; ! import java.io.DataOutputStream; ! import java.io.IOException; ! public class SimpleNode implements Node { ! public int beginLine, beginColumn; public boolean from_future_checked = false; // from __future__ support ! public SimpleNode() { } ! public static Node jjtCreate(PythonGrammar p, int id) { ! return p.jjtree.openNode(id); } ! public int getId() { ! return -1; } ! public Object getImage() { ! return null; } ! public void setImage(Object image) { } ! /* You can override these two methods in subclasses of SimpleNode to ! customize the way the node appears when the tree is dumped. If ! your output uses more than one line you should override ! toString(String), otherwise overriding toString() is probably all ! you need to do. */ ! public String toString() { ! return super.toString() + " at line "+beginLine; } + public String toString(String prefix) { return prefix + toString(); } ! public Object accept(VisitorIF visitor) throws Exception { ! throw new ParseException("Unexpected node: "+this); } ! public void traverse(VisitorIF visitor) throws Exception { ! throw new ParseException("Unexpected node: "+this); } ! /* Override this method if you want to customize how the node dumps ! ut its children. */ ! ! protected String dumpThis(String s) { ! return s; } ! protected String dumpThis(Object o) { ! return String.valueOf(o); } ! protected String dumpThis(Object[] s) { ! StringBuffer sb = new StringBuffer(); ! if (s == null) { ! sb.append("null"); ! } else { ! sb.append("["); ! for (int i = 0; i < s.length; i++) { ! if (i > 0) ! sb.append(", "); ! sb.append(String.valueOf(s[i])); ! } ! sb.append("]"); ! } ! ! return sb.toString(); ! } ! protected String dumpThis(int i) { ! return Integer.toString(i); } ! protected String dumpThis(int i, String[] names) { ! // XXX Verify bounds. ! return names[i]; } ! protected String dumpThis(int[] arr, String[] names) { ! StringBuffer sb = new StringBuffer(); ! if (arr == null) { ! sb.append("null"); } else { ! sb.append("["); ! for (int i = 0; i < arr.length; i++) { ! if (i > 0) ! sb.append(", "); ! // XXX Verify bounds. ! sb.append(names[arr[i]]); ! } ! sb.append("]"); } + return sb.toString(); } + protected String dumpThis(boolean b) { + return Boolean.toString(b); + } ! public void pickle(DataOutputStream ostream) throws IOException { ! throw new IOException("Pickling not implemented"); ! } ! ! protected void pickleThis(String s, DataOutputStream ostream) ! throws IOException ! { ! if (s == null) { ! ostream.writeInt(-1); } else { ! ostream.writeInt(s.length()); ! ostream.writeBytes(s); ! } ! } ! protected void pickleThis(String[] s, DataOutputStream ostream) ! throws IOException ! { ! if (s == null) { ! ostream.writeInt(-1); ! } else { ! ostream.writeInt(s.length); ! for (int i = 0; i < s.length; i++) { ! pickleThis(s[i], ostream); } } } ! protected void pickleThis(SimpleNode o, DataOutputStream ostream) ! throws IOException ! { ! if (o == null) { ! ostream.writeInt(-1); } else { ! o.pickle(ostream); } } ! protected void pickleThis(SimpleNode[] s, DataOutputStream ostream) ! throws IOException ! { ! if (s == null) { ! ostream.writeInt(-1); ! } else { ! ostream.writeInt(s.length); ! for (int i = 0; i < s.length; i++) { ! pickleThis(s[i], ostream); ! } ! } } ! protected void pickleThis(int i, DataOutputStream ostream) ! throws IOException ! { ! ostream.writeInt(i); ! } ! protected void pickleThis(int[] arr, DataOutputStream ostream) ! throws IOException ! { ! if (arr == null) { ! ostream.writeInt(-1); ! } else { ! ostream.writeInt(arr.length); ! for (int i = 0; i < arr.length; i++) { ! ostream.writeInt(arr[i]); } } } ! protected void pickleThis(boolean b, DataOutputStream ostream) ! throws IOException ! { ! ostream.writeBoolean(b); } + protected void pickleThis(PyObject n, DataOutputStream ostream) + throws IOException + { + String s = n.toString(); + ostream.writeInt(s.length()); + ostream.writeBytes(s); + } } Index: Visitor.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/parser/Visitor.java,v retrieving revision 2.6 retrieving revision 2.7 diff -C2 -d -r2.6 -r2.7 *** Visitor.java 13 Jan 2002 18:23:08 -0000 2.6 --- Visitor.java 30 May 2002 16:08:02 -0000 2.7 *************** *** 1,380 **** - // Copyright (c) Corporation for National Research Initiatives package org.python.parser; ! public class Visitor { ! public Object single_input(SimpleNode n) throws Exception { ! throw new ParseException("Unhandled Node: "+n); ! } ! ! public Object file_input(SimpleNode n) throws Exception { ! throw new ParseException("Unhandled Node: "+n); ! } ! ! public Object eval_input(SimpleNode n) throws Exception { ! throw new ParseException("Unhandled Node: "+n); ! } ! ! public Object funcdef(SimpleNode n) throws Exception { ! throw new ParseException("Unhandled Node: "+n); ! } ! ! public Object varargslist(SimpleNode n) throws Exception { ! throw new ParseException("Unhandled Node: "+n); ! } ! ! public Object ExtraArgList(SimpleNode n) throws Exception { ! throw new ParseException("Unhandled Node: "+n); ! } ! ! public Object ExtraKeywordList(SimpleNode n) throws Exception { ! throw new ParseException("Unhandled Node: "+n); ! } ! ! public Object defaultarg(SimpleNode n) throws Exception { ! throw new ParseException("Unhandled Node: "+n); ! } ! ! public Object fplist(SimpleNode n) throws Exception { ! throw new ParseException("Unhandled Node: "+n); ! } ! ! public Object expr_stmt(SimpleNode n) throws Exception { ! throw new ParseException("Unhandled Node: "+n); ! } ! ! public Object print_stmt(SimpleNode n) throws Exception { ! throw new ParseException("Unhandled Node: "+n); ! } ! ! public Object print_ext(SimpleNode n) throws Exception { ! throw new ParseException("Unhandled Node: "+n); ! } ! ! public Object del_stmt(SimpleNode n) throws Exception { ! throw new ParseException("Unhandled Node: "+n); ! } ! ! public Object pass_stmt(SimpleNode n) throws Exception { ! throw new ParseException("Unhandled Node: "+n); ! } ! ! public Object break_stmt(SimpleNode n) throws Exception { ! throw new ParseException("Unhandled Node: "+n); ! } ! ! public Object continue_stmt(SimpleNode n) throws Exception { ! throw new ParseException("Unhandled Node: "+n); ! } ! ! public Object return_stmt(SimpleNode n) throws Exception { ! throw new ParseException("Unhandled Node: "+n); ! } ! ! public Object raise_stmt(SimpleNode n) throws Exception { ! throw new ParseException("Unhandled Node: "+n); ! } ! ! public Object Import(SimpleNode n) throws Exception { ! throw new ParseException("Unhandled Node: "+n); ! } ! ! public Object ImportFrom(SimpleNode n) throws Exception { ! throw new ParseException("Unhandled Node: "+n); ! } ! ! public Object dotted_name(SimpleNode n) throws Exception { ! throw new ParseException("Unhandled Node: "+n); ! } ! ! public Object global_stmt(SimpleNode n) throws Exception { ! throw new ParseException("Unhandled Node: "+n); ! } ! ! public Object exec_stmt(SimpleNode n) throws Exception { ! throw new ParseException("Unhandled Node: "+n); ! } ! ! public Object assert_stmt(SimpleNode n) throws Exception { ! throw new ParseException("Unhandled Node: "+n); ! } ! ! public Object if_stmt(SimpleNode n) throws Exception { ! throw new ParseException("Unhandled Node: "+n); ! } ! ! public Object while_stmt(SimpleNode n) throws Exception { ! throw new ParseException("Unhandled Node: "+n); ! } ! ! public Object for_stmt(SimpleNode n) throws Exception { ! throw new ParseException("Unhandled Node: "+n); ! } ! ! public Object try_stmt(SimpleNode n) throws Exception { ! throw new ParseException("Unhandled Node: "+n); ! } ! ! public Object except_clause(SimpleNode n) throws Exception { ! throw new ParseException("Unhandled Node: "+n); ! } ! ! public Object suite(SimpleNode n... [truncated message content] |
Update of /cvsroot/jython/jython/org/python/parser/ast In directory usw-pr-cvs1:/tmp/cvs-serv12231 Added Files: Assert.java Assign.java Attribute.java AugAssign.java BinOp.java BoolOp.java Break.java Call.java ClassDef.java Compare.java Continue.java Delete.java Dict.java Ellipsis.java Exec.java Expr.java Expression.java ExtSlice.java For.java FunctionDef.java Global.java If.java Import.java ImportFrom.java Index.java Interactive.java Lambda.java List.java ListComp.java Module.java Name.java Num.java Pass.java Print.java Raise.java Repr.java Return.java Slice.java Str.java Subscript.java Suite.java TryExcept.java TryFinally.java Tuple.java UnaryOp.java VisitorBase.java VisitorIF.java While.java Yield.java aliasType.java argumentsType.java boolopType.java cmpopType.java excepthandlerType.java exprType.java expr_contextType.java keywordType.java listcompType.java modType.java operatorType.java sliceType.java stmtType.java unaryopType.java Log Message: AST nodes generated from python.asdl. Python.asdl is currently located in CPython's nondist/sandbox/ast. --- NEW FILE: Assert.java --- // Autogenerated AST node package org.python.parser.ast; import org.python.parser.SimpleNode; import java.io.DataOutputStream; import java.io.IOException; public class Assert extends stmtType { public exprType test; public exprType msg; public Assert(exprType test, exprType msg) { this.test = test; this.msg = msg; } public Assert(exprType test, exprType msg, SimpleNode parent) { this(test, msg); this.beginLine = parent.beginLine; this.beginColumn = parent.beginColumn; } public String toString() { StringBuffer sb = new StringBuffer("Assert["); sb.append("test="); sb.append(dumpThis(this.test)); sb.append(", "); sb.append("msg="); sb.append(dumpThis(this.msg)); sb.append("]"); return sb.toString(); } public void pickle(DataOutputStream ostream) throws IOException { pickleThis(19, ostream); pickleThis(this.test, ostream); pickleThis(this.msg, ostream); } public Object accept(VisitorIF visitor) throws Exception { return visitor.visitAssert(this); } public void traverse(VisitorIF visitor) throws Exception { if (test != null) test.accept(visitor); if (msg != null) msg.accept(visitor); } } --- NEW FILE: Assign.java --- // Autogenerated AST node package org.python.parser.ast; import org.python.parser.SimpleNode; import java.io.DataOutputStream; import java.io.IOException; public class Assign extends stmtType { public exprType[] targets; public exprType value; public Assign(exprType[] targets, exprType value) { this.targets = targets; this.value = value; } public Assign(exprType[] targets, exprType value, SimpleNode parent) { this(targets, value); this.beginLine = parent.beginLine; this.beginColumn = parent.beginColumn; } public String toString() { StringBuffer sb = new StringBuffer("Assign["); sb.append("targets="); sb.append(dumpThis(this.targets)); sb.append(", "); sb.append("value="); sb.append(dumpThis(this.value)); sb.append("]"); return sb.toString(); } public void pickle(DataOutputStream ostream) throws IOException { pickleThis(10, ostream); pickleThis(this.targets, ostream); pickleThis(this.value, ostream); } public Object accept(VisitorIF visitor) throws Exception { return visitor.visitAssign(this); } public void traverse(VisitorIF visitor) throws Exception { if (targets != null) { for (int i = 0; i < targets.length; i++) { if (targets[i] != null) targets[i].accept(visitor); } } if (value != null) value.accept(visitor); } } --- NEW FILE: Attribute.java --- // Autogenerated AST node package org.python.parser.ast; import org.python.parser.SimpleNode; import java.io.DataOutputStream; import java.io.IOException; public class Attribute extends exprType implements expr_contextType { public exprType value; public String attr; public int ctx; public Attribute(exprType value, String attr, int ctx) { this.value = value; this.attr = attr; this.ctx = ctx; } public Attribute(exprType value, String attr, int ctx, SimpleNode parent) { this(value, attr, ctx); this.beginLine = parent.beginLine; this.beginColumn = parent.beginColumn; } public String toString() { StringBuffer sb = new StringBuffer("Attribute["); sb.append("value="); sb.append(dumpThis(this.value)); sb.append(", "); sb.append("attr="); sb.append(dumpThis(this.attr)); sb.append(", "); sb.append("ctx="); sb.append(dumpThis(this.ctx, expr_contextType.expr_contextTypeNames)); sb.append("]"); return sb.toString(); } public void pickle(DataOutputStream ostream) throws IOException { pickleThis(39, ostream); pickleThis(this.value, ostream); pickleThis(this.attr, ostream); pickleThis(this.ctx, ostream); } public Object accept(VisitorIF visitor) throws Exception { return visitor.visitAttribute(this); } public void traverse(VisitorIF visitor) throws Exception { if (value != null) value.accept(visitor); } } --- NEW FILE: AugAssign.java --- // Autogenerated AST node package org.python.parser.ast; import org.python.parser.SimpleNode; import java.io.DataOutputStream; import java.io.IOException; public class AugAssign extends stmtType implements operatorType { public exprType target; public int op; public exprType value; public AugAssign(exprType target, int op, exprType value) { this.target = target; this.op = op; this.value = value; } public AugAssign(exprType target, int op, exprType value, SimpleNode parent) { this(target, op, value); this.beginLine = parent.beginLine; this.beginColumn = parent.beginColumn; } public String toString() { StringBuffer sb = new StringBuffer("AugAssign["); sb.append("target="); sb.append(dumpThis(this.target)); sb.append(", "); sb.append("op="); sb.append(dumpThis(this.op, operatorType.operatorTypeNames)); sb.append(", "); sb.append("value="); sb.append(dumpThis(this.value)); sb.append("]"); return sb.toString(); } public void pickle(DataOutputStream ostream) throws IOException { pickleThis(11, ostream); pickleThis(this.target, ostream); pickleThis(this.op, ostream); pickleThis(this.value, ostream); } public Object accept(VisitorIF visitor) throws Exception { return visitor.visitAugAssign(this); } public void traverse(VisitorIF visitor) throws Exception { if (target != null) target.accept(visitor); if (value != null) value.accept(visitor); } } --- NEW FILE: BinOp.java --- // Autogenerated AST node package org.python.parser.ast; import org.python.parser.SimpleNode; import java.io.DataOutputStream; import java.io.IOException; public class BinOp extends exprType implements operatorType { public exprType left; public int op; public exprType right; public BinOp(exprType left, int op, exprType right) { this.left = left; this.op = op; this.right = right; } public BinOp(exprType left, int op, exprType right, SimpleNode parent) { this(left, op, right); this.beginLine = parent.beginLine; this.beginColumn = parent.beginColumn; } public String toString() { StringBuffer sb = new StringBuffer("BinOp["); sb.append("left="); sb.append(dumpThis(this.left)); sb.append(", "); sb.append("op="); sb.append(dumpThis(this.op, operatorType.operatorTypeNames)); sb.append(", "); sb.append("right="); sb.append(dumpThis(this.right)); sb.append("]"); return sb.toString(); } public void pickle(DataOutputStream ostream) throws IOException { pickleThis(29, ostream); pickleThis(this.left, ostream); pickleThis(this.op, ostream); pickleThis(this.right, ostream); } public Object accept(VisitorIF visitor) throws Exception { return visitor.visitBinOp(this); } public void traverse(VisitorIF visitor) throws Exception { if (left != null) left.accept(visitor); if (right != null) right.accept(visitor); } } --- NEW FILE: BoolOp.java --- // Autogenerated AST node package org.python.parser.ast; import org.python.parser.SimpleNode; import java.io.DataOutputStream; import java.io.IOException; public class BoolOp extends exprType implements boolopType { public int op; public exprType[] values; public BoolOp(int op, exprType[] values) { this.op = op; this.values = values; } public BoolOp(int op, exprType[] values, SimpleNode parent) { this(op, values); this.beginLine = parent.beginLine; this.beginColumn = parent.beginColumn; } public String toString() { StringBuffer sb = new StringBuffer("BoolOp["); sb.append("op="); sb.append(dumpThis(this.op, boolopType.boolopTypeNames)); sb.append(", "); sb.append("values="); sb.append(dumpThis(this.values)); sb.append("]"); return sb.toString(); } public void pickle(DataOutputStream ostream) throws IOException { pickleThis(28, ostream); pickleThis(this.op, ostream); pickleThis(this.values, ostream); } public Object accept(VisitorIF visitor) throws Exception { return visitor.visitBoolOp(this); } public void traverse(VisitorIF visitor) throws Exception { if (values != null) { for (int i = 0; i < values.length; i++) { if (values[i] != null) values[i].accept(visitor); } } } } --- NEW FILE: Break.java --- // Autogenerated AST node package org.python.parser.ast; import org.python.parser.SimpleNode; import java.io.DataOutputStream; import java.io.IOException; public class Break extends stmtType { public Break() { } public Break(SimpleNode parent) { this(); this.beginLine = parent.beginLine; this.beginColumn = parent.beginColumn; } public String toString() { StringBuffer sb = new StringBuffer("Break["); sb.append("]"); return sb.toString(); } public void pickle(DataOutputStream ostream) throws IOException { pickleThis(26, ostream); } public Object accept(VisitorIF visitor) throws Exception { return visitor.visitBreak(this); } public void traverse(VisitorIF visitor) throws Exception { } } --- NEW FILE: Call.java --- // Autogenerated AST node package org.python.parser.ast; import org.python.parser.SimpleNode; import java.io.DataOutputStream; import java.io.IOException; public class Call extends exprType { public exprType func; public exprType[] args; public keywordType[] keywords; public exprType starargs; public exprType kwargs; public Call(exprType func, exprType[] args, keywordType[] keywords, exprType starargs, exprType kwargs) { this.func = func; this.args = args; this.keywords = keywords; this.starargs = starargs; this.kwargs = kwargs; } public Call(exprType func, exprType[] args, keywordType[] keywords, exprType starargs, exprType kwargs, SimpleNode parent) { this(func, args, keywords, starargs, kwargs); this.beginLine = parent.beginLine; this.beginColumn = parent.beginColumn; } public String toString() { StringBuffer sb = new StringBuffer("Call["); sb.append("func="); sb.append(dumpThis(this.func)); sb.append(", "); sb.append("args="); sb.append(dumpThis(this.args)); sb.append(", "); sb.append("keywords="); sb.append(dumpThis(this.keywords)); sb.append(", "); sb.append("starargs="); sb.append(dumpThis(this.starargs)); sb.append(", "); sb.append("kwargs="); sb.append(dumpThis(this.kwargs)); sb.append("]"); return sb.toString(); } public void pickle(DataOutputStream ostream) throws IOException { pickleThis(35, ostream); pickleThis(this.func, ostream); pickleThis(this.args, ostream); pickleThis(this.keywords, ostream); pickleThis(this.starargs, ostream); pickleThis(this.kwargs, ostream); } public Object accept(VisitorIF visitor) throws Exception { return visitor.visitCall(this); } public void traverse(VisitorIF visitor) throws Exception { if (func != null) func.accept(visitor); if (args != null) { for (int i = 0; i < args.length; i++) { if (args[i] != null) args[i].accept(visitor); } } if (keywords != null) { for (int i = 0; i < keywords.length; i++) { if (keywords[i] != null) keywords[i].accept(visitor); } } if (starargs != null) starargs.accept(visitor); if (kwargs != null) kwargs.accept(visitor); } } --- NEW FILE: ClassDef.java --- // Autogenerated AST node package org.python.parser.ast; import org.python.parser.SimpleNode; import java.io.DataOutputStream; import java.io.IOException; public class ClassDef extends stmtType { public String name; public exprType[] bases; public stmtType[] body; public ClassDef(String name, exprType[] bases, stmtType[] body) { this.name = name; this.bases = bases; this.body = body; } public ClassDef(String name, exprType[] bases, stmtType[] body, SimpleNode parent) { this(name, bases, body); this.beginLine = parent.beginLine; this.beginColumn = parent.beginColumn; } public String toString() { StringBuffer sb = new StringBuffer("ClassDef["); sb.append("name="); sb.append(dumpThis(this.name)); sb.append(", "); sb.append("bases="); sb.append(dumpThis(this.bases)); sb.append(", "); sb.append("body="); sb.append(dumpThis(this.body)); sb.append("]"); return sb.toString(); } public void pickle(DataOutputStream ostream) throws IOException { pickleThis(6, ostream); pickleThis(this.name, ostream); pickleThis(this.bases, ostream); pickleThis(this.body, ostream); } public Object accept(VisitorIF visitor) throws Exception { return visitor.visitClassDef(this); } public void traverse(VisitorIF visitor) throws Exception { if (bases != null) { for (int i = 0; i < bases.length; i++) { if (bases[i] != null) bases[i].accept(visitor); } } if (body != null) { for (int i = 0; i < body.length; i++) { if (body[i] != null) body[i].accept(visitor); } } } } --- NEW FILE: Compare.java --- // Autogenerated AST node package org.python.parser.ast; import org.python.parser.SimpleNode; import java.io.DataOutputStream; import java.io.IOException; public class Compare extends exprType implements cmpopType { public exprType left; public int[] ops; public exprType[] comparators; public Compare(exprType left, int[] ops, exprType[] comparators) { this.left = left; this.ops = ops; this.comparators = comparators; } public Compare(exprType left, int[] ops, exprType[] comparators, SimpleNode parent) { this(left, ops, comparators); this.beginLine = parent.beginLine; this.beginColumn = parent.beginColumn; } public String toString() { StringBuffer sb = new StringBuffer("Compare["); sb.append("left="); sb.append(dumpThis(this.left)); sb.append(", "); sb.append("ops="); sb.append(dumpThis(this.ops, cmpopType.cmpopTypeNames)); sb.append(", "); sb.append("comparators="); sb.append(dumpThis(this.comparators)); sb.append("]"); return sb.toString(); } public void pickle(DataOutputStream ostream) throws IOException { pickleThis(34, ostream); pickleThis(this.left, ostream); pickleThis(this.ops, ostream); pickleThis(this.comparators, ostream); } public Object accept(VisitorIF visitor) throws Exception { return visitor.visitCompare(this); } public void traverse(VisitorIF visitor) throws Exception { if (left != null) left.accept(visitor); if (comparators != null) { for (int i = 0; i < comparators.length; i++) { if (comparators[i] != null) comparators[i].accept(visitor); } } } } --- NEW FILE: Continue.java --- // Autogenerated AST node package org.python.parser.ast; import org.python.parser.SimpleNode; import java.io.DataOutputStream; import java.io.IOException; public class Continue extends stmtType { public Continue() { } public Continue(SimpleNode parent) { this(); this.beginLine = parent.beginLine; this.beginColumn = parent.beginColumn; } public String toString() { StringBuffer sb = new StringBuffer("Continue["); sb.append("]"); return sb.toString(); } public void pickle(DataOutputStream ostream) throws IOException { pickleThis(27, ostream); } public Object accept(VisitorIF visitor) throws Exception { return visitor.visitContinue(this); } public void traverse(VisitorIF visitor) throws Exception { } } --- NEW FILE: Delete.java --- // Autogenerated AST node package org.python.parser.ast; import org.python.parser.SimpleNode; import java.io.DataOutputStream; import java.io.IOException; public class Delete extends stmtType { public exprType[] targets; public Delete(exprType[] targets) { this.targets = targets; } public Delete(exprType[] targets, SimpleNode parent) { this(targets); this.beginLine = parent.beginLine; this.beginColumn = parent.beginColumn; } public String toString() { StringBuffer sb = new StringBuffer("Delete["); sb.append("targets="); sb.append(dumpThis(this.targets)); sb.append("]"); return sb.toString(); } public void pickle(DataOutputStream ostream) throws IOException { pickleThis(9, ostream); pickleThis(this.targets, ostream); } public Object accept(VisitorIF visitor) throws Exception { return visitor.visitDelete(this); } public void traverse(VisitorIF visitor) throws Exception { if (targets != null) { for (int i = 0; i < targets.length; i++) { if (targets[i] != null) targets[i].accept(visitor); } } } } --- NEW FILE: Dict.java --- // Autogenerated AST node package org.python.parser.ast; import org.python.parser.SimpleNode; import java.io.DataOutputStream; import java.io.IOException; public class Dict extends exprType { public exprType[] keys; public exprType[] values; public Dict(exprType[] keys, exprType[] values) { this.keys = keys; this.values = values; } public Dict(exprType[] keys, exprType[] values, SimpleNode parent) { this(keys, values); this.beginLine = parent.beginLine; this.beginColumn = parent.beginColumn; } public String toString() { StringBuffer sb = new StringBuffer("Dict["); sb.append("keys="); sb.append(dumpThis(this.keys)); sb.append(", "); sb.append("values="); sb.append(dumpThis(this.values)); sb.append("]"); return sb.toString(); } public void pickle(DataOutputStream ostream) throws IOException { pickleThis(32, ostream); pickleThis(this.keys, ostream); pickleThis(this.values, ostream); } public Object accept(VisitorIF visitor) throws Exception { return visitor.visitDict(this); } public void traverse(VisitorIF visitor) throws Exception { if (keys != null) { for (int i = 0; i < keys.length; i++) { if (keys[i] != null) keys[i].accept(visitor); } } if (values != null) { for (int i = 0; i < values.length; i++) { if (values[i] != null) values[i].accept(visitor); } } } } --- NEW FILE: Ellipsis.java --- // Autogenerated AST node package org.python.parser.ast; import org.python.parser.SimpleNode; import java.io.DataOutputStream; import java.io.IOException; public class Ellipsis extends sliceType { public Ellipsis() { } public Ellipsis(SimpleNode parent) { this(); this.beginLine = parent.beginLine; this.beginColumn = parent.beginColumn; } public String toString() { StringBuffer sb = new StringBuffer("Ellipsis["); sb.append("]"); return sb.toString(); } public void pickle(DataOutputStream ostream) throws IOException { pickleThis(44, ostream); } public Object accept(VisitorIF visitor) throws Exception { return visitor.visitEllipsis(this); } public void traverse(VisitorIF visitor) throws Exception { } } --- NEW FILE: Exec.java --- // Autogenerated AST node package org.python.parser.ast; import org.python.parser.SimpleNode; import java.io.DataOutputStream; import java.io.IOException; public class Exec extends stmtType { public exprType body; public exprType globals; public exprType locals; public Exec(exprType body, exprType globals, exprType locals) { this.body = body; this.globals = globals; this.locals = locals; } public Exec(exprType body, exprType globals, exprType locals, SimpleNode parent) { this(body, globals, locals); this.beginLine = parent.beginLine; this.beginColumn = parent.beginColumn; } public String toString() { StringBuffer sb = new StringBuffer("Exec["); sb.append("body="); sb.append(dumpThis(this.body)); sb.append(", "); sb.append("globals="); sb.append(dumpThis(this.globals)); sb.append(", "); sb.append("locals="); sb.append(dumpThis(this.locals)); sb.append("]"); return sb.toString(); } public void pickle(DataOutputStream ostream) throws IOException { pickleThis(22, ostream); pickleThis(this.body, ostream); pickleThis(this.globals, ostream); pickleThis(this.locals, ostream); } public Object accept(VisitorIF visitor) throws Exception { return visitor.visitExec(this); } public void traverse(VisitorIF visitor) throws Exception { if (body != null) body.accept(visitor); if (globals != null) globals.accept(visitor); if (locals != null) locals.accept(visitor); } } --- NEW FILE: Expr.java --- // Autogenerated AST node package org.python.parser.ast; import org.python.parser.SimpleNode; import java.io.DataOutputStream; import java.io.IOException; public class Expr extends stmtType { public exprType value; public Expr(exprType value) { this.value = value; } public Expr(exprType value, SimpleNode parent) { this(value); this.beginLine = parent.beginLine; this.beginColumn = parent.beginColumn; } public String toString() { StringBuffer sb = new StringBuffer("Expr["); sb.append("value="); sb.append(dumpThis(this.value)); sb.append("]"); return sb.toString(); } public void pickle(DataOutputStream ostream) throws IOException { pickleThis(24, ostream); pickleThis(this.value, ostream); } public Object accept(VisitorIF visitor) throws Exception { return visitor.visitExpr(this); } public void traverse(VisitorIF visitor) throws Exception { if (value != null) value.accept(visitor); } } --- NEW FILE: Expression.java --- // Autogenerated AST node package org.python.parser.ast; import org.python.parser.SimpleNode; import java.io.DataOutputStream; import java.io.IOException; public class Expression extends modType { public exprType body; public Expression(exprType body) { this.body = body; } public Expression(exprType body, SimpleNode parent) { this(body); this.beginLine = parent.beginLine; this.beginColumn = parent.beginColumn; } public String toString() { StringBuffer sb = new StringBuffer("Expression["); sb.append("body="); sb.append(dumpThis(this.body)); sb.append("]"); return sb.toString(); } public void pickle(DataOutputStream ostream) throws IOException { pickleThis(3, ostream); pickleThis(this.body, ostream); } public Object accept(VisitorIF visitor) throws Exception { return visitor.visitExpression(this); } public void traverse(VisitorIF visitor) throws Exception { if (body != null) body.accept(visitor); } } --- NEW FILE: ExtSlice.java --- // Autogenerated AST node package org.python.parser.ast; import org.python.parser.SimpleNode; import java.io.DataOutputStream; import java.io.IOException; public class ExtSlice extends sliceType { public sliceType[] dims; public ExtSlice(sliceType[] dims) { this.dims = dims; } public ExtSlice(sliceType[] dims, SimpleNode parent) { this(dims); this.beginLine = parent.beginLine; this.beginColumn = parent.beginColumn; } public String toString() { StringBuffer sb = new StringBuffer("ExtSlice["); sb.append("dims="); sb.append(dumpThis(this.dims)); sb.append("]"); return sb.toString(); } public void pickle(DataOutputStream ostream) throws IOException { pickleThis(46, ostream); pickleThis(this.dims, ostream); } public Object accept(VisitorIF visitor) throws Exception { return visitor.visitExtSlice(this); } public void traverse(VisitorIF visitor) throws Exception { if (dims != null) { for (int i = 0; i < dims.length; i++) { if (dims[i] != null) dims[i].accept(visitor); } } } } --- NEW FILE: For.java --- // Autogenerated AST node package org.python.parser.ast; import org.python.parser.SimpleNode; import java.io.DataOutputStream; import java.io.IOException; public class For extends stmtType { public exprType target; public exprType iter; public stmtType[] body; public stmtType[] orelse; public For(exprType target, exprType iter, stmtType[] body, stmtType[] orelse) { this.target = target; this.iter = iter; this.body = body; this.orelse = orelse; } public For(exprType target, exprType iter, stmtType[] body, stmtType[] orelse, SimpleNode parent) { this(target, iter, body, orelse); this.beginLine = parent.beginLine; this.beginColumn = parent.beginColumn; } public String toString() { StringBuffer sb = new StringBuffer("For["); sb.append("target="); sb.append(dumpThis(this.target)); sb.append(", "); sb.append("iter="); sb.append(dumpThis(this.iter)); sb.append(", "); sb.append("body="); sb.append(dumpThis(this.body)); sb.append(", "); sb.append("orelse="); sb.append(dumpThis(this.orelse)); sb.append("]"); return sb.toString(); } public void pickle(DataOutputStream ostream) throws IOException { pickleThis(13, ostream); pickleThis(this.target, ostream); pickleThis(this.iter, ostream); pickleThis(this.body, ostream); pickleThis(this.orelse, ostream); } public Object accept(VisitorIF visitor) throws Exception { return visitor.visitFor(this); } public void traverse(VisitorIF visitor) throws Exception { if (target != null) target.accept(visitor); if (iter != null) iter.accept(visitor); if (body != null) { for (int i = 0; i < body.length; i++) { if (body[i] != null) body[i].accept(visitor); } } if (orelse != null) { for (int i = 0; i < orelse.length; i++) { if (orelse[i] != null) orelse[i].accept(visitor); } } } } --- NEW FILE: FunctionDef.java --- // Autogenerated AST node package org.python.parser.ast; import org.python.parser.SimpleNode; import java.io.DataOutputStream; import java.io.IOException; public class FunctionDef extends stmtType { public String name; public argumentsType args; public stmtType[] body; public FunctionDef(String name, argumentsType args, stmtType[] body) { this.name = name; this.args = args; this.body = body; } public FunctionDef(String name, argumentsType args, stmtType[] body, SimpleNode parent) { this(name, args, body); this.beginLine = parent.beginLine; this.beginColumn = parent.beginColumn; } public String toString() { StringBuffer sb = new StringBuffer("FunctionDef["); sb.append("name="); sb.append(dumpThis(this.name)); sb.append(", "); sb.append("args="); sb.append(dumpThis(this.args)); sb.append(", "); sb.append("body="); sb.append(dumpThis(this.body)); sb.append("]"); return sb.toString(); } public void pickle(DataOutputStream ostream) throws IOException { pickleThis(5, ostream); pickleThis(this.name, ostream); pickleThis(this.args, ostream); pickleThis(this.body, ostream); } public Object accept(VisitorIF visitor) throws Exception { return visitor.visitFunctionDef(this); } public void traverse(VisitorIF visitor) throws Exception { if (args != null) args.accept(visitor); if (body != null) { for (int i = 0; i < body.length; i++) { if (body[i] != null) body[i].accept(visitor); } } } } --- NEW FILE: Global.java --- // Autogenerated AST node package org.python.parser.ast; import org.python.parser.SimpleNode; import java.io.DataOutputStream; import java.io.IOException; public class Global extends stmtType { public String[] names; public Global(String[] names) { this.names = names; } public Global(String[] names, SimpleNode parent) { this(names); this.beginLine = parent.beginLine; this.beginColumn = parent.beginColumn; } public String toString() { StringBuffer sb = new StringBuffer("Global["); sb.append("names="); sb.append(dumpThis(this.names)); sb.append("]"); return sb.toString(); } public void pickle(DataOutputStream ostream) throws IOException { pickleThis(23, ostream); pickleThis(this.names, ostream); } public Object accept(VisitorIF visitor) throws Exception { return visitor.visitGlobal(this); } public void traverse(VisitorIF visitor) throws Exception { } } --- NEW FILE: If.java --- // Autogenerated AST node package org.python.parser.ast; import org.python.parser.SimpleNode; import java.io.DataOutputStream; import java.io.IOException; public class If extends stmtType { public exprType test; public stmtType[] body; public stmtType[] orelse; public If(exprType test, stmtType[] body, stmtType[] orelse) { this.test = test; this.body = body; this.orelse = orelse; } public If(exprType test, stmtType[] body, stmtType[] orelse, SimpleNode parent) { this(test, body, orelse); this.beginLine = parent.beginLine; this.beginColumn = parent.beginColumn; } public String toString() { StringBuffer sb = new StringBuffer("If["); sb.append("test="); sb.append(dumpThis(this.test)); sb.append(", "); sb.append("body="); sb.append(dumpThis(this.body)); sb.append(", "); sb.append("orelse="); sb.append(dumpThis(this.orelse)); sb.append("]"); return sb.toString(); } public void pickle(DataOutputStream ostream) throws IOException { pickleThis(15, ostream); pickleThis(this.test, ostream); pickleThis(this.body, ostream); pickleThis(this.orelse, ostream); } public Object accept(VisitorIF visitor) throws Exception { return visitor.visitIf(this); } public void traverse(VisitorIF visitor) throws Exception { if (test != null) test.accept(visitor); if (body != null) { for (int i = 0; i < body.length; i++) { if (body[i] != null) body[i].accept(visitor); } } if (orelse != null) { for (int i = 0; i < orelse.length; i++) { if (orelse[i] != null) orelse[i].accept(visitor); } } } } --- NEW FILE: Import.java --- // Autogenerated AST node package org.python.parser.ast; import org.python.parser.SimpleNode; import java.io.DataOutputStream; import java.io.IOException; public class Import extends stmtType { public aliasType[] names; public Import(aliasType[] names) { this.names = names; } public Import(aliasType[] names, SimpleNode parent) { this(names); this.beginLine = parent.beginLine; this.beginColumn = parent.beginColumn; } public String toString() { StringBuffer sb = new StringBuffer("Import["); sb.append("names="); sb.append(dumpThis(this.names)); sb.append("]"); return sb.toString(); } public void pickle(DataOutputStream ostream) throws IOException { pickleThis(20, ostream); pickleThis(this.names, ostream); } public Object accept(VisitorIF visitor) throws Exception { return visitor.visitImport(this); } public void traverse(VisitorIF visitor) throws Exception { if (names != null) { for (int i = 0; i < names.length; i++) { if (names[i] != null) names[i].accept(visitor); } } } } --- NEW FILE: ImportFrom.java --- // Autogenerated AST node package org.python.parser.ast; import org.python.parser.SimpleNode; import java.io.DataOutputStream; import java.io.IOException; public class ImportFrom extends stmtType { public String module; public aliasType[] names; public ImportFrom(String module, aliasType[] names) { this.module = module; this.names = names; } public ImportFrom(String module, aliasType[] names, SimpleNode parent) { this(module, names); this.beginLine = parent.beginLine; this.beginColumn = parent.beginColumn; } public String toString() { StringBuffer sb = new StringBuffer("ImportFrom["); sb.append("module="); sb.append(dumpThis(this.module)); sb.append(", "); sb.append("names="); sb.append(dumpThis(this.names)); sb.append("]"); return sb.toString(); } public void pickle(DataOutputStream ostream) throws IOException { pickleThis(21, ostream); pickleThis(this.module, ostream); pickleThis(this.names, ostream); } public Object accept(VisitorIF visitor) throws Exception { return visitor.visitImportFrom(this); } public void traverse(VisitorIF visitor) throws Exception { if (names != null) { for (int i = 0; i < names.length; i++) { if (names[i] != null) names[i].accept(visitor); } } } } --- NEW FILE: Index.java --- // Autogenerated AST node package org.python.parser.ast; import org.python.parser.SimpleNode; import java.io.DataOutputStream; import java.io.IOException; public class Index extends sliceType { public exprType value; public Index(exprType value) { this.value = value; } public Index(exprType value, SimpleNode parent) { this(value); this.beginLine = parent.beginLine; this.beginColumn = parent.beginColumn; } public String toString() { StringBuffer sb = new StringBuffer("Index["); sb.append("value="); sb.append(dumpThis(this.value)); sb.append("]"); return sb.toString(); } public void pickle(DataOutputStream ostream) throws IOException { pickleThis(47, ostream); pickleThis(this.value, ostream); } public Object accept(VisitorIF visitor) throws Exception { return visitor.visitIndex(this); } public void traverse(VisitorIF visitor) throws Exception { if (value != null) value.accept(visitor); } } --- NEW FILE: Interactive.java --- // Autogenerated AST node package org.python.parser.ast; import org.python.parser.SimpleNode; import java.io.DataOutputStream; import java.io.IOException; public class Interactive extends modType { public stmtType body; public Interactive(stmtType body) { this.body = body; } public Interactive(stmtType body, SimpleNode parent) { this(body); this.beginLine = parent.beginLine; this.beginColumn = parent.beginColumn; } public String toString() { StringBuffer sb = new StringBuffer("Interactive["); sb.append("body="); sb.append(dumpThis(this.body)); sb.append("]"); return sb.toString(); } public void pickle(DataOutputStream ostream) throws IOException { pickleThis(2, ostream); pickleThis(this.body, ostream); } public Object accept(VisitorIF visitor) throws Exception { return visitor.visitInteractive(this); } public void traverse(VisitorIF visitor) throws Exception { if (body != null) body.accept(visitor); } } --- NEW FILE: Lambda.java --- // Autogenerated AST node package org.python.parser.ast; import org.python.parser.SimpleNode; import java.io.DataOutputStream; import java.io.IOException; public class Lambda extends exprType { public argumentsType args; public exprType body; public Lambda(argumentsType args, exprType body) { this.args = args; this.body = body; } public Lambda(argumentsType args, exprType body, SimpleNode parent) { this(args, body); this.beginLine = parent.beginLine; this.beginColumn = parent.beginColumn; } public String toString() { StringBuffer sb = new StringBuffer("Lambda["); sb.append("args="); sb.append(dumpThis(this.args)); sb.append(", "); sb.append("body="); sb.append(dumpThis(this.body)); sb.append("]"); return sb.toString(); } public void pickle(DataOutputStream ostream) throws IOException { pickleThis(31, ostream); pickleThis(this.args, ostream); pickleThis(this.body, ostream); } public Object accept(VisitorIF visitor) throws Exception { return visitor.visitLambda(this); } public void traverse(VisitorIF visitor) throws Exception { if (args != null) args.accept(visitor); if (body != null) body.accept(visitor); } } --- NEW FILE: List.java --- // Autogenerated AST node package org.python.parser.ast; import org.python.parser.SimpleNode; import java.io.DataOutputStream; import java.io.IOException; public class List extends exprType implements expr_contextType { public exprType[] elts; public int ctx; public List(exprType[] elts, int ctx) { this.elts = elts; this.ctx = ctx; } public List(exprType[] elts, int ctx, SimpleNode parent) { this(elts, ctx); this.beginLine = parent.beginLine; this.beginColumn = parent.beginColumn; } public String toString() { StringBuffer sb = new StringBuffer("List["); sb.append("elts="); sb.append(dumpThis(this.elts)); sb.append(", "); sb.append("ctx="); sb.append(dumpThis(this.ctx, expr_contextType.expr_contextTypeNames)); sb.append("]"); return sb.toString(); } public void pickle(DataOutputStream ostream) throws IOException { pickleThis(42, ostream); pickleThis(this.elts, ostream); pickleThis(this.ctx, ostream); } public Object accept(VisitorIF visitor) throws Exception { return visitor.visitList(this); } public void traverse(VisitorIF visitor) throws Exception { if (elts != null) { for (int i = 0; i < elts.length; i++) { if (elts[i] != null) elts[i].accept(visitor); } } } } --- NEW FILE: ListComp.java --- // Autogenerated AST node package org.python.parser.ast; import org.python.parser.SimpleNode; import java.io.DataOutputStream; import java.io.IOException; public class ListComp extends exprType { public exprType target; public listcompType[] generators; public ListComp(exprType target, listcompType[] generators) { this.target = target; this.generators = generators; } public ListComp(exprType target, listcompType[] generators, SimpleNode parent) { this(target, generators); this.beginLine = parent.beginLine; this.beginColumn = parent.beginColumn; } public String toString() { StringBuffer sb = new StringBuffer("ListComp["); sb.append("target="); sb.append(dumpThis(this.target)); sb.append(", "); sb.append("generators="); sb.append(dumpThis(this.generators)); sb.append("]"); return sb.toString(); } public void pickle(DataOutputStream ostream) throws IOException { pickleThis(33, ostream); pickleThis(this.target, ostream); pickleThis(this.generators, ostream); } public Object accept(VisitorIF visitor) throws Exception { return visitor.visitListComp(this); } public void traverse(VisitorIF visitor) throws Exception { if (target != null) target.accept(visitor); if (generators != null) { for (int i = 0; i < generators.length; i++) { if (generators[i] != null) generators[i].accept(visitor); } } } } --- NEW FILE: Module.java --- // Autogenerated AST node package org.python.parser.ast; import org.python.parser.SimpleNode; import java.io.DataOutputStream; import java.io.IOException; public class Module extends modType { public stmtType[] body; public Module(stmtType[] body) { this.body = body; } public Module(stmtType[] body, SimpleNode parent) { this(body); this.beginLine = parent.beginLine; this.beginColumn = parent.beginColumn; } public String toString() { StringBuffer sb = new StringBuffer("Module["); sb.append("body="); sb.append(dumpThis(this.body)); sb.append("]"); return sb.toString(); } public void pickle(DataOutputStream ostream) throws IOException { pickleThis(1, ostream); pickleThis(this.body, ostream); } public Object accept(VisitorIF visitor) throws Exception { return visitor.visitModule(this); } public void traverse(VisitorIF visitor) throws Exception { if (body != null) { for (int i = 0; i < body.length; i++) { if (body[i] != null) body[i].accept(visitor); } } } } --- NEW FILE: Name.java --- // Autogenerated AST node package org.python.parser.ast; import org.python.parser.SimpleNode; import java.io.DataOutputStream; import java.io.IOException; public class Name extends exprType implements expr_contextType { public String id; public int ctx; public Name(String id, int ctx) { this.id = id; this.ctx = ctx; } public Name(String id, int ctx, SimpleNode parent) { this(id, ctx); this.beginLine = parent.beginLine; this.beginColumn = parent.beginColumn; } public String toString() { StringBuffer sb = new StringBuffer("Name["); sb.append("id="); sb.append(dumpThis(this.id)); sb.append(", "); sb.append("ctx="); sb.append(dumpThis(this.ctx, expr_contextType.expr_contextTypeNames)); sb.append("]"); return sb.toString(); } public void pickle(DataOutputStream ostream) throws IOException { pickleThis(41, ostream); pickleThis(this.id, ostream); pickleThis(this.ctx, ostream); } public Object accept(VisitorIF visitor) throws Exception { return visitor.visitName(this); } public void traverse(VisitorIF visitor) throws Exception { } } --- NEW FILE: Num.java --- // Autogenerated AST node package org.python.parser.ast; import org.python.parser.SimpleNode; import java.io.DataOutputStream; import java.io.IOException; public class Num extends exprType { public org.python.core.PyObject n; public Num(org.python.core.PyObject n) { this.n = n; } public Num(org.python.core.PyObject n, SimpleNode parent) { this(n); this.beginLine = parent.beginLine; this.beginColumn = parent.beginColumn; } public String toString() { StringBuffer sb = new StringBuffer("Num["); sb.append("n="); sb.append(dumpThis(this.n)); sb.append("]"); return sb.toString(); } public void pickle(DataOutputStream ostream) throws IOException { pickleThis(37, ostream); pickleThis(this.n, ostream); } public Object accept(VisitorIF visitor) throws Exception { return visitor.visitNum(this); } public void traverse(VisitorIF visitor) throws Exception { } } --- NEW FILE: Pass.java --- // Autogenerated AST node package org.python.parser.ast; import org.python.parser.SimpleNode; import java.io.DataOutputStream; import java.io.IOException; public class Pass extends stmtType { public Pass() { } public Pass(SimpleNode parent) { this(); this.beginLine = parent.beginLine; this.beginColumn = parent.beginColumn; } public String toString() { StringBuffer sb = new StringBuffer("Pass["); sb.append("]"); return sb.toString(); } public void pickle(DataOutputStream ostream) throws IOException { pickleThis(25, ostream); } public Object accept(VisitorIF visitor) throws Exception { return visitor.visitPass(this); } public void traverse(VisitorIF visitor) throws Exception { } } --- NEW FILE: Print.java --- // Autogenerated AST node package org.python.parser.ast; import org.python.parser.SimpleNode; import java.io.DataOutputStream; import java.io.IOException; public class Print extends stmtType { public exprType dest; public exprType[] value; public boolean nl; public Print(exprType dest, exprType[] value, boolean nl) { this.dest = dest; this.value = value; this.nl = nl; } public Print(exprType dest, exprType[] value, boolean nl, SimpleNode parent) { this(dest, value, nl); this.beginLine = parent.beginLine; this.beginColumn = parent.beginColumn; } public String toString() { StringBuffer sb = new StringBuffer("Print["); sb.append("dest="); sb.append(dumpThis(this.dest)); sb.append(", "); sb.append("value="); sb.append(dumpThis(this.value)); sb.append(", "); sb.append("nl="); sb.append(dumpThis(this.nl)); sb.append("]"); return sb.toString(); } public void pickle(DataOutputStream ostream) throws IOException { pickleThis(12, ostream); pickleThis(this.dest, ostream); pickleThis(this.value, ostream); pickleThis(this.nl, ostream); } public Object accept(VisitorIF visitor) throws Exception { return visitor.visitPrint(this); } public void traverse(VisitorIF visitor) throws Exception { if (dest != null) dest.accept(visitor); if (value != null) { for (int i = 0; i < value.length; i++) { if (value[i] != null) value[i].accept(visitor); } } } } --- NEW FILE: Raise.java --- // Autogenerated AST node package org.python.parser.ast; import org.python.parser.SimpleNode; import java.io.DataOutputStream; import java.io.IOException; public class Raise extends stmtType { public exprType type; public exprType inst; public exprType tback; public Raise(exprType type, exprType inst, exprType tback) { this.type = type; this.inst = inst; this.tback = tback; } public Raise(exprType type, exprType inst, exprType tback, SimpleNode parent) { this(type, inst, tback); this.beginLine = parent.beginLine; this.beginColumn = parent.beginColumn; } public String toString() { StringBuffer sb = new StringBuffer("Raise["); sb.append("type="); sb.append(dumpThis(this.type)); sb.append(", "); sb.append("inst="); sb.append(dumpThis(this.inst)); sb.append(", "); sb.append("tback="); sb.append(dumpThis(this.tback)); sb.append("]"); return sb.toString(); } public void pickle(DataOutputStream ostream) throws IOException { pickleThis(16, ostream); pickleThis(this.type, ostream); pickleThis(this.inst, ostream); pickleThis(this.tback, ostream); } public Object accept(VisitorIF visitor) throws Exception { return visitor.visitRaise(this); } public void traverse(VisitorIF visitor) throws Exception { if (type != null) type.accept(visitor); if (inst != null) inst.accept(visitor); if (tback != null) tback.accept(visitor); } } --- NEW FILE: Repr.java --- // Autogenerated AST node package org.python.parser.ast; import org.python.parser.SimpleNode; import java.io.DataOutputStream; import java.io.IOException; public class Repr extends exprType { public exprType value; public Repr(exprType value) { this.value = value; } public Repr(exprType value, SimpleNode parent) { this(value); this.beginLine = parent.beginLine; this.beginColumn = parent.beginColumn; } public String toString() { StringBuffer sb = new StringBuffer("Repr["); sb.append("value="); sb.append(dumpThis(this.value)); sb.append("]"); return sb.toString(); } public void pickle(DataOutputStream ostream) throws IOException { pickleThis(36, ostream); pickleThis(this.value, ostream); } public Object accept(VisitorIF visitor) throws Exception { return visitor.visitRepr(this); } public void traverse(VisitorIF visitor) throws Exception { if (value != null) value.accept(visitor); } } --- NEW FILE: Return.java --- // Autogenerated AST node package org.python.parser.ast; import org.python.parser.SimpleNode; import java.io.DataOutputStream; import java.io.IOException; public class Return extends stmtType { public exprType value; public Return(exprType value) { this.value = value; } public Return(exprType value, SimpleNode parent) { this(value); this.beginLine = parent.beginLine; this.beginColumn = parent.beginColumn; } public String toString() { StringBuffer sb = new StringBuffer("Return["); sb.append("value="); sb.append(dumpThis(this.value)); sb.append("]"); return sb.toString(); } public void pickle(DataOutputStream ostream) throws IOException { pickleThis(7, ostream); pickleThis(this.value, ostream); } public Object accept(VisitorIF visitor) throws Exception { return visitor.visitReturn(this); } public void traverse(VisitorIF visitor) throws Exception { if (value != null) value.accept(visitor); } } --- NEW FILE: Slice.java --- // Autogenerated AST node package org.python.parser.ast; import org.python.parser.SimpleNode; import java.io.DataOutputStream; import java.io.IOException; public class Slice extends sliceType { public exprType lower; public exprType upper; public exprType step; public Slice(exprType lower, exprType upper, exprType step) { this.lower = lower; this.upper = upper; this.step = step; } public Slice(exprType lower, exprType upper, exprType step, SimpleNode parent) { this(lower, upper, step); this.beginLine = parent.beginLine; this.beginColumn = parent.beginColumn; } public String toString() { StringBuffer sb = new StringBuffer("Slice["); sb.append("lower="); sb.append(dumpThis(this.lower)); sb.append(", "); sb.append("upper="); sb.append(dumpThis(this.upper)); sb.append(", "); sb.append("step="); sb.append(dumpThis(this.step)); sb.append("]"); return sb.toString(); } public void pickle(DataOutputStream ostream) throws IOException { pickleThis(45, ostream); pickleThis(this.lower, ostream); pickleThis(this.upper, ostream); pickleThis(this.step, ostream); } public Object accept(VisitorIF visitor) throws Exception { return visitor.visitSlice(this); } public void traverse(VisitorIF visitor) throws Exception { if (lower != null) lower.accept(visitor); if (upper != null) upper.accept(visitor); if (step != null) step.accept(visitor); } } --- NEW FILE: Str.java --- // Autogenerated AST node package org.python.parser.ast; import org.python.parser.SimpleNode; import java.io.DataOutputStream; import java.io.IOException; public class Str extends exprType { public String s; public Str(String s) { this.s = s; } public Str(String s, SimpleNode parent) { this(s); this.beginLine = parent.beginLine; this.beginColumn = parent.beginColumn; } public String toString() { StringBuffer sb = new StringBuffer("Str["); sb.append("s="); sb.append(dumpThis(this.s)); sb.append("]"); return sb.toString(); } public void pickle(DataOutputStream ostream) throws IOException { pickleThis(38, ostream); pickleThis(this.s, ostream); } public Object accept(VisitorIF visitor) throws Exception { return visitor.visitStr(this); } public void traverse(VisitorIF visitor) throws Exception { } } --- NEW FILE: Subscript.java --- // Autogenerated AST node package org.python.parser.ast; import org.python.parser.SimpleNode; import java.io.DataOutputStream; import java.io.IOException; public class Subscript extends exprType implements expr_contextType { public exprType value; public sliceType slice; public int ctx; public Subscript(exprType value, sliceType slice, int ctx) { this.value = value; this.slice = slice; this.ctx = ctx; } public Subscript(exprType value, sliceType slice, int ctx, SimpleNode parent) { this(value, slice, ctx); this.beginLine = parent.beginLine; this.beginColumn = parent.beginColumn; } public String toString() { StringBuffer sb = new StringBuffer("Subscript["); sb.append("value="); sb.append(dumpThis(this.value)); sb.append(", "); sb.append("slice="); sb.append(dumpThis(this.slice)); sb.append(", "); sb.append("ctx="); sb.append(dumpThis(this.ctx, expr_contextType.expr_contextTypeNames)); sb.append("]"); return sb.toString(); } public void pickle(DataOutputStream ostream) throws IOException { pickleThis(40, ostream); pickleThis(this.value, ostream); pickleThis(this.slice, ostream); pickleThis(this.ctx, ostream); } public Object accept(VisitorIF visitor) throws Exception { return visitor.visitSubscript(this); } public void traverse(VisitorIF visitor) throws Exception { if (value != null) value.accept(visitor); if (slice != null) slice.accept(visitor); } } --- NEW FILE: Suite.java --- // Autogenerated AST node package org.python.parser.ast; import org.python.parser.SimpleNode; import java.io.DataOutputStream; import java.io.IOException; public class Suite extends modType { public stmtType[] body; public Suite(stmtType[] body) { this.body = body; } public Suite(stmtType[] body, SimpleNode parent) { this(body); this.beginLine = parent.beginLine; this.beginColumn = parent.beginColumn; } public String toString() { StringBuffer sb = new StringBuffer("Suite["); sb.append("body="); sb.append(dumpThis(this.body)); sb.append("]"); return sb.toString(); } public void pickle(DataOutputStream ostream) throws IOException { pickleThis(4, ostream); pickleThis(this.body, ostream); } public Object accept(VisitorIF visitor) throws Exception { return visitor.visitSuite(this); } public void traverse(VisitorIF visitor) throws Exception { if (body != null) { for (int i = 0; i < body.length; i++) { if (body[i] != null) body[i].accept(visitor); } } } } --- NEW FILE: TryExcept.java --- // Autogenerated AST node package org.python.parser.ast; import org.python.parser.SimpleNode; import java.io.DataOutputStream; import java.io.IOException; public class TryExcept extends stmtType { public stmtType[] body; public excepthandlerType[] handlers; public stmtType[] orelse; public TryExcept(stmtType[] body, excepthandlerType[] handlers, stmtType[] orelse) { this.body = body; this.handlers = handlers; this.orelse = orelse; } public TryExcept(stmtType[] body, excepthandlerType[] handlers, stmtType[] orelse, SimpleNode parent) { this(body, handlers, orelse); this.beginLine = parent.beginLine; this.beginColumn = parent.beginColumn; } public String toString() { StringBuffer sb = new StringBuffer("TryExcept["); sb.append("body="); sb.append(dumpThis(this.body)); sb.append(", "); sb.append("handlers="); sb.append(dumpThis(this.handlers)); sb.append(", "); sb.append("orels... [truncated message content] |
From: Finn B. <bc...@us...> - 2002-05-30 16:03:16
|
Update of /cvsroot/jython/jython/org/python/parser/ast In directory usw-pr-cvs1:/tmp/cvs-serv11549/ast Log Message: Directory /cvsroot/jython/jython/org/python/parser/ast added to the repository |