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: <fwi...@us...> - 2008-08-20 15:51:12
|
Revision: 5222 http://jython.svn.sourceforge.net/jython/?rev=5222&view=rev Author: fwierzbicki Date: 2008-08-20 15:49:38 +0000 (Wed, 20 Aug 2008) Log Message: ----------- Added Ellipsis and merged with trunk. Modified Paths: -------------- branches/nowalker/Lib/pkgutil.py branches/nowalker/grammar/Python.g branches/nowalker/src/org/python/compiler/Module.java branches/nowalker/src/org/python/core/PyBaseException.java branches/nowalker/src/org/python/core/PyFrame.java branches/nowalker/src/org/python/core/PyObject.java branches/nowalker/src/org/python/core/__builtin__.java branches/nowalker/src/org/python/core/imp.java branches/nowalker/src/org/python/modules/zipimport/zipimporter.java branches/nowalker/src/shell/jython.bat Property Changed: ---------------- branches/nowalker/ Property changes on: branches/nowalker ___________________________________________________________________ Modified: svnmerge-integrated - /trunk/jython:1-5208 + /trunk/jython:1-5221 Modified: branches/nowalker/Lib/pkgutil.py =================================================================== --- branches/nowalker/Lib/pkgutil.py 2008-08-20 15:39:29 UTC (rev 5221) +++ branches/nowalker/Lib/pkgutil.py 2008-08-20 15:49:38 UTC (rev 5222) @@ -22,7 +22,7 @@ # accessed by _imp here def read_jython_code(fullname, file, filename): - data = _imp.unmarshalCode(filename, file, False) + data = _imp.readCode(filename, file, False) return BytecodeLoader.makeCode(fullname + "$py", data, filename) def simplegeneric(func): Modified: branches/nowalker/grammar/Python.g =================================================================== --- branches/nowalker/grammar/Python.g 2008-08-20 15:39:29 UTC (rev 5221) +++ branches/nowalker/grammar/Python.g 2008-08-20 15:49:38 UTC (rev 5222) @@ -117,6 +117,7 @@ import org.python.antlr.ast.Continue; import org.python.antlr.ast.Delete; import org.python.antlr.ast.Dict; +import org.python.antlr.ast.Ellipsis; import org.python.antlr.ast.excepthandlerType; import org.python.antlr.ast.Exec; import org.python.antlr.ast.Expr; @@ -1092,7 +1093,7 @@ $subscript.tree = $sltype; } } - : DOT DOT DOT -> Ellipsis + : d1=DOT DOT DOT -> DOT<Ellipsis>[$d1] | (test[expr_contextType.Load] COLON) => lower=test[expr_contextType.Load] (c1=COLON (upper1=test[expr_contextType.Load])? (sliceop)?)? { $sltype = actions.makeSubscript($lower.tree, $c1, $upper1.tree, $sliceop.tree); } Modified: branches/nowalker/src/org/python/compiler/Module.java =================================================================== --- branches/nowalker/src/org/python/compiler/Module.java 2008-08-20 15:39:29 UTC (rev 5221) +++ branches/nowalker/src/org/python/compiler/Module.java 2008-08-20 15:49:38 UTC (rev 5222) @@ -405,6 +405,29 @@ CodeCompiler compiler = new CodeCompiler(this, printResults); + if (classBody) { + Label label_got_name = new Label(); + int module_tmp = c.getLocal("org/python/core/PyObject"); + + c.aload(1); + c.ldc("__module__"); + c.invokevirtual("org/python/core/PyFrame", "getname_or_null", "(" + $str + ")" + $pyObj); + c.dup(); + c.ifnonnull(label_got_name); + + c.pop(); + c.aload(1); + c.ldc("__name__"); + c.invokevirtual("org/python/core/PyFrame", "getname_or_null", "(" + $str + ")" + $pyObj); + + c.label(label_got_name); + c.astore(module_tmp); + c.aload(1); + c.ldc("__module__"); + c.aload(module_tmp); + c.invokevirtual("org/python/core/PyFrame", "setlocal", "(" + $str + $pyObj + ")V"); + } + Label genswitch = new Label(); if (scope.generator) { c.goto_(genswitch); Modified: branches/nowalker/src/org/python/core/PyBaseException.java =================================================================== --- branches/nowalker/src/org/python/core/PyBaseException.java 2008-08-20 15:39:29 UTC (rev 5221) +++ branches/nowalker/src/org/python/core/PyBaseException.java 2008-08-20 15:49:38 UTC (rev 5222) @@ -166,23 +166,20 @@ } } + @Override public String toString() { - return __repr__().toString(); + return BaseException_toString(); } - - public PyString __repr__() { - return BaseException___repr__(); - } - @ExposedMethod - final PyString BaseException___repr__() { + @ExposedMethod(names = ("__repr__")) + final String BaseException_toString() { PyObject reprSuffix = args.__repr__(); String name = getType().fastGetName(); int lastDot = name.lastIndexOf('.'); if (lastDot != -1) { name = name.substring(lastDot + 1); } - return Py.newString(name + reprSuffix.toString()); + return name + reprSuffix.toString(); } @ExposedSet(name = "args") Modified: branches/nowalker/src/org/python/core/PyFrame.java =================================================================== --- branches/nowalker/src/org/python/core/PyFrame.java 2008-08-20 15:39:29 UTC (rev 5221) +++ branches/nowalker/src/org/python/core/PyFrame.java 2008-08-20 15:49:38 UTC (rev 5222) @@ -282,6 +282,20 @@ throw Py.NameError(String.format(NAME_ERROR_MSG, index)); } + public PyObject getname_or_null(String index) { + PyObject ret; + if (f_locals == null || f_locals == f_globals) { + ret = doGetglobal(index); + } else { + ret = f_locals.__finditem__(index); + if (ret != null) { + return ret; + } + ret = doGetglobal(index); + } + return ret; + } + public PyObject getglobal(String index) { PyObject ret = doGetglobal(index); if (ret != null) { Modified: branches/nowalker/src/org/python/core/PyObject.java =================================================================== --- branches/nowalker/src/org/python/core/PyObject.java 2008-08-20 15:39:29 UTC (rev 5221) +++ branches/nowalker/src/org/python/core/PyObject.java 2008-08-20 15:49:38 UTC (rev 5222) @@ -281,7 +281,7 @@ * * @param arg0 the first argument to the function. * @param arg1 the second argument to the function. -n **/ + **/ public PyObject __call__(PyObject arg0, PyObject arg1) { return __call__(new PyObject[] { arg0, arg1 }, Py.NoKeywords); } Modified: branches/nowalker/src/org/python/core/__builtin__.java =================================================================== --- branches/nowalker/src/org/python/core/__builtin__.java 2008-08-20 15:39:29 UTC (rev 5221) +++ branches/nowalker/src/org/python/core/__builtin__.java 2008-08-20 15:49:38 UTC (rev 5222) @@ -1410,7 +1410,7 @@ @Override public String toString() { - return "<built-in function min>"; + return "<built-in function max>"; } private static PyObject max(PyObject o, PyObject key) { Modified: branches/nowalker/src/org/python/core/imp.java =================================================================== --- branches/nowalker/src/org/python/core/imp.java 2008-08-20 15:39:29 UTC (rev 5221) +++ branches/nowalker/src/org/python/core/imp.java 2008-08-20 15:49:38 UTC (rev 5222) @@ -87,7 +87,7 @@ static PyObject createFromPyClass(String name, InputStream fp, boolean testing, String fileName) { - byte[] data = unmarshalCode(name, fp, testing); + byte[] data = readCode(name, fp, testing); if (testing && data == null) { return null; } @@ -107,8 +107,7 @@ return createFromCode(name, code, fileName); } - public static byte[] unmarshalCode(String name, InputStream fp, - boolean testing) { + public static byte[] readCode(String name, InputStream fp, boolean testing) { byte[] data = readBytes(fp); int n = data.length; Modified: branches/nowalker/src/org/python/modules/zipimport/zipimporter.java =================================================================== --- branches/nowalker/src/org/python/modules/zipimport/zipimporter.java 2008-08-20 15:39:29 UTC (rev 5221) +++ branches/nowalker/src/org/python/modules/zipimport/zipimporter.java 2008-08-20 15:49:38 UTC (rev 5222) @@ -6,6 +6,7 @@ import java.io.InputStream; import java.util.Date; import java.util.Enumeration; +import java.util.EnumSet; import java.util.zip.ZipEntry; import java.util.zip.ZipFile; @@ -51,19 +52,22 @@ /** zip_searchorder defines how we search for a module in the Zip * archive */ - static final int IS_SOURCE = 0; - static final int IS_BYTECODE = 1; - static final int IS_PACKAGE = 2; + static enum EntryType { + IS_SOURCE, IS_BYTECODE, IS_PACKAGE + }; static final SearchOrderEntry[] zip_searchorder = new SearchOrderEntry[] { - new SearchOrderEntry(File.separator + "__init__$py.class", IS_PACKAGE | IS_BYTECODE), - new SearchOrderEntry(File.separator + "__init__.py", IS_PACKAGE | IS_SOURCE), - new SearchOrderEntry("$py.class", IS_BYTECODE), - new SearchOrderEntry(".py", IS_SOURCE), - new SearchOrderEntry("", 0) + new SearchOrderEntry(File.separator + "__init__$py.class", + EnumSet.of(EntryType.IS_PACKAGE, EntryType.IS_BYTECODE)), + new SearchOrderEntry(File.separator + "__init__.py", + EnumSet.of(EntryType.IS_PACKAGE, EntryType.IS_SOURCE)), + new SearchOrderEntry("$py.class", EnumSet.of(EntryType.IS_BYTECODE)), + new SearchOrderEntry(".py", EnumSet.of(EntryType.IS_SOURCE)), }; /** Module information */ - static enum ModuleInfo {ERROR, NOT_FOUND, MODULE, PACKAGE}; + static enum ModuleInfo { + ERROR, NOT_FOUND, MODULE, PACKAGE + }; /** Pathname of the Zip archive */ @ExposedGet @@ -366,7 +370,7 @@ if (tocEntry == null) continue; - if ((entry.type & IS_PACKAGE) == IS_PACKAGE) { + if (entry.type.contains(EntryType.IS_PACKAGE)) { return ModuleInfo.PACKAGE; } return ModuleInfo.MODULE; @@ -399,8 +403,8 @@ continue; } - boolean ispackage = (entry.type & IS_PACKAGE) == IS_PACKAGE; - boolean isbytecode = (entry.type & IS_BYTECODE) == IS_BYTECODE; + boolean ispackage = entry.type.contains(EntryType.IS_PACKAGE); + boolean isbytecode = entry.type.contains(EntryType.IS_BYTECODE); if (isbytecode && isOutdatedBytecode(searchPath, tocEntry)) { continue; @@ -410,7 +414,7 @@ ZipBundle zipBundle = getDataStream(searchPath); byte[] codeBytes; if (isbytecode) { - codeBytes = imp.unmarshalCode(fullname, zipBundle.inputStream, true); + codeBytes = imp.readCode(fullname, zipBundle.inputStream, true); } else { codeBytes = imp.compileSource(fullname, zipBundle.inputStream, pathToEntry); @@ -422,7 +426,6 @@ continue; } - imp.cacheCompiledSource(pathToEntry, null, codeBytes); PyCode code = BytecodeLoader.makeCode(fullname + "$py", codeBytes, pathToEntry); return new ModuleCodeData(code, ispackage, pathToEntry); } @@ -661,9 +664,9 @@ */ protected static class SearchOrderEntry { public String suffix; - public int type; + public EnumSet type; - public SearchOrderEntry(String suffix, int type) { + public SearchOrderEntry(String suffix, EnumSet type) { this.suffix = suffix; this.type = type; } Modified: branches/nowalker/src/shell/jython.bat =================================================================== --- branches/nowalker/src/shell/jython.bat 2008-08-20 15:39:29 UTC (rev 5221) +++ branches/nowalker/src/shell/jython.bat 2008-08-20 15:49:38 UTC (rev 5222) @@ -18,10 +18,10 @@ set _JAVA_CMD=java if not "%JAVA_HOME%" == "" ( - set _JAVA_CMD="%JAVA_HOME%\bin\java" + set _JAVA_CMD="%JAVA_HOME:"=%\bin\java" ) -set _JYTHON_HOME="%JYTHON_HOME%" +set _JYTHON_HOME=%JYTHON_HOME% if not "%JYTHON_HOME%" == "" goto gotHome pushd "%~dp0%\.." set _JYTHON_HOME="%CD%" @@ -32,7 +32,7 @@ rem prefer built version set _CP=%_JYTHON_HOME%\jython.jar for %%j in (%_JYTHON_HOME%\javalib\*.jar) do ( - set _CP=!_CP!;"%%j" + set _CP=!_CP!;"%%j" ) goto run @@ -48,13 +48,103 @@ rem ----- Execute the requested command ---------------------------------------- :run -%_JAVA_CMD% %JAVA_OPTS% -Xss512k -Xbootclasspath/a:%_CP% -Dpython.home=%_JYTHON_HOME% -Dpython.executable="%~f0" -classpath "%CLASSPATH%" org.python.util.jython %JYTHON_OPTS% %* +set _JAVA_STACK=-Xss512k + +rem Escape any quotes. Use _S for ', _D for ", and _U to escape _ itself. +rem We have to escape _ itself, otherwise file names with _S and _D +rem will be converted to to wrong ones, when we un-escape. See JRUBY-2821. +set _ARGS=%* +if not defined _ARGS goto argsDone +set _ARGS=%_ARGS:_=_U% +set _ARGS=%_ARGS:'=_S% +set _ARGS=%_ARGS:"=_D% + +set _ARGS="%_ARGS%" + +:scanArgs +rem split args by spaces into first and rest +for /f "tokens=1,*" %%i in (%_ARGS%) do call :getArg "%%i" "%%j" +goto procArg + +:getArg +rem remove quotes around first arg +for %%i in (%1) do set _CMP=%%~i +set _ARGS=%2 +goto :EOF + +:procArg +if ["%_CMP%"] == [""] ( + set _ARGS= + goto argsDone +) + +REM NOTE: If you'd like to use a parameter with underscore in its name, +REM NOTE: use the quoted value: --do_stuff -> --do_Ustuff + +if ["%_CMP%"] == ["--"] goto argsDone + +if ["%_CMP%"] == ["--jdb"] ( + if "%JAVA_HOME%" == "" ( + set _JAVA_CMD=jdb + ) else ( + set _JAVA_CMD="%_JAVA_HOME:"=%\bin\jdb" + ) + goto :nextArg +) + +if ["%_CMP%"] == ["--verify"] ( + set CLASSPATH=%_CP:"=%;%CLASSPATH:"=% + set _CP= + goto :nextArg +) + +rem now unescape _D, _S and _Q +set _CMP=%_CMP:_D="% +set _CMP=%_CMP:_S='% +set _CMP=%_CMP:_U=_% +set _CMP1=%_CMP:~0,1% +set _CMP2=%_CMP:~0,2% + +rem detect first character is a quote; skip directly to jythonArg +rem this avoids a batch syntax error +if "%_CMP1:"=\\%" == "\\" goto jythonArg + +rem removing quote avoids a batch syntax error +if "%_CMP2:"=\\%" == "-J" goto jvmArg + +:jythonArg +set JYTHON_OPTS=%JYTHON_OPTS% %_CMP% +goto nextArg + +:jvmArg +set _VAL=%_CMP:~2% + +if "%_VAL:~0,4%" == "-Xss" ( + set _JAVA_STACK=%_VAL% + echo %_VAL% + goto nextArg +) + +set _JAVA_OPTS=%_JAVA_OPTS% %_VAL% + +:nextArg +set _CMP= +goto scanArgs + +:argsDone +%_JAVA_CMD% %_JAVA_OPTS% %_JAVA_STACK% -Xbootclasspath/a:%_CP% -Dpython.home=%_JYTHON_HOME% -Dpython.executable="%~f0" -classpath "%CLASSPATH%" org.python.util.jython %JYTHON_OPTS% %_ARGS% set E=%ERRORLEVEL% :cleanup +set _ARGS= +set _CMP= +set _CMP1= +set _CMP2= +set _CP= +set _JAVA_CMD= +set _JAVA_OPTS= +set _JAVA_STACK= set _JYTHON_HOME= -set _JAVA_CMD= -set _CP= :finish exit /b %E% This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2008-08-20 15:37:05
|
Revision: 5220 http://jython.svn.sourceforge.net/jython/?rev=5220&view=rev Author: fwierzbicki Date: 2008-08-20 15:37:02 +0000 (Wed, 20 Aug 2008) Log Message: ----------- repr support. Modified Paths: -------------- branches/nowalker/grammar/Python.g Modified: branches/nowalker/grammar/Python.g =================================================================== --- branches/nowalker/grammar/Python.g 2008-08-20 15:23:14 UTC (rev 5219) +++ branches/nowalker/grammar/Python.g 2008-08-20 15:37:02 UTC (rev 5220) @@ -80,7 +80,6 @@ Expression; Ellipsis; ListComp; - Repr; Target; GeneratorExp; Ifs; @@ -88,7 +87,6 @@ GenFor; GenIf; - ListFor; ListIf; } @@ -139,10 +137,11 @@ import org.python.antlr.ast.Module; import org.python.antlr.ast.Name; import org.python.antlr.ast.Num; +import org.python.antlr.ast.operatorType; import org.python.antlr.ast.Pass; import org.python.antlr.ast.Print; import org.python.antlr.ast.Raise; -import org.python.antlr.ast.operatorType; +import org.python.antlr.ast.Repr; import org.python.antlr.ast.Return; import org.python.antlr.ast.Slice; import org.python.antlr.ast.sliceType; @@ -775,7 +774,7 @@ //test: or_test ['if' or_test 'else' test] | lambdef test[expr_contextType ctype] :o1=or_test[ctype] - ( (IF or_test[expr_contextType.Load] ORELSE) => IF o2=or_test[expr_contextType.Load] ORELSE e=test[expr_contextType.Load] + ( (IF or_test[expr_contextType.Load] ORELSE) => IF o2=or_test[ctype] ORELSE e=test[expr_contextType.Load] -> ^(IF<IfExp>[$IF, (exprType)$o2.tree, (exprType)$o1.tree, (exprType)$e.tree]) | -> or_test ) @@ -1000,7 +999,7 @@ | -> ^(LCURLY<Dict>[$LCURLY, new exprType[0\], new exprType[0\]]) ) RCURLY - | BACKQUOTE testlist[expr_contextType.Load] BACKQUOTE -> ^(Repr BACKQUOTE testlist) + | lb=BACKQUOTE testlist[expr_contextType.Load] rb=BACKQUOTE -> ^(BACKQUOTE<Repr>[$lb, (exprType)$testlist.tree]) | NAME -> ^(PYNODE<Name>[$NAME, $NAME.text, $expr::ctype]) | INT -> ^(PYNODE<Num>[$INT, actions.makeInt($INT)]) | LONGINT -> ^(PYNODE<Num>[$LONGINT, actions.makeInt($LONGINT)]) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2008-08-20 15:23:16
|
Revision: 5219 http://jython.svn.sourceforge.net/jython/?rev=5219&view=rev Author: fwierzbicki Date: 2008-08-20 15:23:14 +0000 (Wed, 20 Aug 2008) Log Message: ----------- Conditional Expression support. Modified Paths: -------------- branches/nowalker/grammar/Python.g Modified: branches/nowalker/grammar/Python.g =================================================================== --- branches/nowalker/grammar/Python.g 2008-08-20 14:39:21 UTC (rev 5218) +++ branches/nowalker/grammar/Python.g 2008-08-20 15:23:14 UTC (rev 5219) @@ -78,10 +78,6 @@ PYNODE; Interactive; Expression; - Test; - Body; - Dict; - IfExp; Ellipsis; ListComp; Repr; @@ -133,6 +129,7 @@ import org.python.antlr.ast.FunctionDef; import org.python.antlr.ast.Global; import org.python.antlr.ast.If; +import org.python.antlr.ast.IfExp; import org.python.antlr.ast.Import; import org.python.antlr.ast.ImportFrom; import org.python.antlr.ast.Index; @@ -778,8 +775,8 @@ //test: or_test ['if' or_test 'else' test] | lambdef test[expr_contextType ctype] :o1=or_test[ctype] - ( (IF or_test[expr_contextType.Load] ORELSE) => IF o2=or_test[ctype] ORELSE test[expr_contextType.Load] - -> ^(IfExp ^(Test $o2) ^(Body $o1) ^(ORELSE test)) + ( (IF or_test[expr_contextType.Load] ORELSE) => IF o2=or_test[expr_contextType.Load] ORELSE e=test[expr_contextType.Load] + -> ^(IF<IfExp>[$IF, (exprType)$o2.tree, (exprType)$o1.tree, (exprType)$e.tree]) | -> or_test ) | lambdef {debug("parsed lambdef");} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2008-08-20 14:39:23
|
Revision: 5218 http://jython.svn.sourceforge.net/jython/?rev=5218&view=rev Author: fwierzbicki Date: 2008-08-20 14:39:21 +0000 (Wed, 20 Aug 2008) Log Message: ----------- Dict support. Modified Paths: -------------- branches/nowalker/grammar/Python.g Modified: branches/nowalker/grammar/Python.g =================================================================== --- branches/nowalker/grammar/Python.g 2008-08-20 14:06:30 UTC (rev 5217) +++ branches/nowalker/grammar/Python.g 2008-08-20 14:39:21 UTC (rev 5218) @@ -122,6 +122,7 @@ import org.python.antlr.ast.Context; import org.python.antlr.ast.Continue; import org.python.antlr.ast.Delete; +import org.python.antlr.ast.Dict; import org.python.antlr.ast.excepthandlerType; import org.python.antlr.ast.Exec; import org.python.antlr.ast.Expr; @@ -997,7 +998,11 @@ | -> ^(LBRACK<org.python.antlr.ast.List>[$LBRACK, new exprType[0\], $expr::ctype]) ) RBRACK - | LCURLY (dictmaker)? RCURLY -> ^(Dict LCURLY ^(Elts dictmaker)?) + | LCURLY + (dictmaker -> ^(LCURLY<Dict>[$LCURLY, actions.makeExprs($dictmaker.keys), actions.makeExprs($dictmaker.values)]) + | -> ^(LCURLY<Dict>[$LCURLY, new exprType[0\], new exprType[0\]]) + ) + RCURLY | BACKQUOTE testlist[expr_contextType.Load] BACKQUOTE -> ^(Repr BACKQUOTE testlist) | NAME -> ^(PYNODE<Name>[$NAME, $NAME.text, $expr::ctype]) | INT -> ^(PYNODE<Num>[$INT, actions.makeInt($INT)]) @@ -1123,15 +1128,18 @@ ; //testlist: test (',' test)* [','] -testlist[expr_contextType ctype] returns [exprType etype] +testlist[expr_contextType ctype] +@init { + exprType etype = null; +} @after { - $testlist.tree = $etype; + $testlist.tree = etype; } : (test[expr_contextType.Load] COMMA) => t+=test[ctype] (options {k=2;}: c1=COMMA t+=test[ctype])* (c2=COMMA)? { - $etype = new Tuple($testlist.start, actions.makeExprs($t), ctype); + etype = new Tuple($testlist.start, actions.makeExprs($t), ctype); } | test[ctype] { - $etype = (exprType)$test.tree; + etype = (exprType)$test.tree; } ; @@ -1139,10 +1147,14 @@ //testlist_safe: test [(',' test)+ [',']] //dictmaker: test ':' test (',' test ':' test)* [','] -dictmaker : test[expr_contextType.Load] COLON test[expr_contextType.Load] - (options {k=2;}:COMMA test[expr_contextType.Load] COLON test[expr_contextType.Load])* (COMMA)? - -> test+ - ; +dictmaker returns [List keys, List values] + : k+=test[expr_contextType.Load] COLON v+=test[expr_contextType.Load] + (options {k=2;}:COMMA k+=test[expr_contextType.Load] COLON v+=test[expr_contextType.Load])* + (COMMA)? { + $keys = $k; + $values= $v; + } + ; //classdef: 'class' NAME ['(' [testlist] ')'] ':' suite classdef @@ -1153,7 +1165,7 @@ $classdef.tree = stype; } :CLASS NAME (LPAREN testlist[expr_contextType.Load]? RPAREN)? COLON suite { - stype = new ClassDef($CLASS, $NAME.getText(), actions.makeBases($testlist.etype), actions.makeStmts($suite.stmts)); + stype = new ClassDef($CLASS, $NAME.getText(), actions.makeBases((exprType)$testlist.tree), actions.makeStmts($suite.stmts)); } ; @@ -1201,7 +1213,7 @@ //list_for: 'for' exprlist 'in' testlist_safe [list_iter] list_for : FOR exprlist[expr_contextType.Load] IN testlist[expr_contextType.Load] (list_iter)? - -> ^(FOR<comprehensionType>[$FOR, $exprlist.etype, $testlist.etype, null]) + -> ^(FOR<comprehensionType>[$FOR, $exprlist.etype, (exprType)$testlist.tree, null]) ; //list_if: 'if' test [list_iter] @@ -1226,7 +1238,7 @@ //yield_expr: 'yield' [testlist] yield_expr : YIELD testlist[expr_contextType.Load]? - -> ^(YIELD<Yield>[$YIELD, $testlist.etype]) + -> ^(YIELD<Yield>[$YIELD, (exprType)$testlist.tree]) ; //XXX: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2008-08-20 14:06:33
|
Revision: 5217 http://jython.svn.sourceforge.net/jython/?rev=5217&view=rev Author: fwierzbicki Date: 2008-08-20 14:06:30 +0000 (Wed, 20 Aug 2008) Log Message: ----------- Fix "del". Modified Paths: -------------- branches/nowalker/grammar/Python.g Modified: branches/nowalker/grammar/Python.g =================================================================== --- branches/nowalker/grammar/Python.g 2008-08-20 12:10:26 UTC (rev 5216) +++ branches/nowalker/grammar/Python.g 2008-08-20 14:06:30 UTC (rev 5217) @@ -547,8 +547,8 @@ //del_stmt: 'del' exprlist -del_stmt : DELETE exprlist2 - -> ^(DELETE<Delete>[$DELETE, actions.makeExprs($exprlist2.etypes)]) +del_stmt : DELETE del_list + -> ^(DELETE<Delete>[$DELETE, actions.makeExprs($del_list.etypes)]) ; //pass_stmt: 'pass' @@ -1115,10 +1115,10 @@ } ; -//XXX: I'm hoping I can get rid of this -- but for now I need an exprlist that does not produce tuples +//XXX: I'm hoping I can get rid of this and merge it back with exprlist -- but for now I need an exprlist that does not produce tuples // at least for del_stmt -exprlist2 returns [List etypes] - : e+=expr[expr_contextType.Load] (options {k=2;}: COMMA e+=expr[expr_contextType.Load])* (COMMA)? +del_list returns [List etypes] + : e+=expr[expr_contextType.Del] (options {k=2;}: COMMA e+=expr[expr_contextType.Del])* (COMMA)? {$etypes = $e;} ; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2008-08-20 12:10:31
|
Revision: 5216 http://jython.svn.sourceforge.net/jython/?rev=5216&view=rev Author: fwierzbicki Date: 2008-08-20 12:10:26 +0000 (Wed, 20 Aug 2008) Log Message: ----------- Much better BoolOp. Modified Paths: -------------- branches/nowalker/grammar/Python.g branches/nowalker/src/org/python/antlr/GrammarActions.java branches/nowalker/src/org/python/antlr/ast/BoolOp.java Modified: branches/nowalker/grammar/Python.g =================================================================== --- branches/nowalker/grammar/Python.g 2008-08-20 06:54:10 UTC (rev 5215) +++ branches/nowalker/grammar/Python.g 2008-08-20 12:10:26 UTC (rev 5216) @@ -776,52 +776,6 @@ //test: or_test ['if' or_test 'else' test] | lambdef test[expr_contextType ctype] -@after { - if ($test.tree instanceof BoolOp) { - BoolOp b = (BoolOp)$test.tree; - List values = new ArrayList(); - - exprType left = (exprType)b.getChild(0); - exprType right = (exprType)b.getChild(1); - - exprType[] e; - if (left.getType() == b.getType() && right.getType() == b.getType()) { - BoolOp leftB = (BoolOp)left; - BoolOp rightB = (BoolOp)right; - int lenL = leftB.values.length; - int lenR = rightB.values.length; - e = new exprType[lenL + lenR]; - System.arraycopy(leftB.values, 0, e, 0, lenL - 1); - System.arraycopy(rightB.values, 0, e, lenL - 1, lenL + lenR); - } else if (left.getType() == b.getType()) { - BoolOp leftB = (BoolOp)left; - e = new exprType[leftB.values.length + 1]; - System.arraycopy(leftB.values, 0, e, 0, leftB.values.length); - e[e.length - 1] = right; - } else if (right.getType() == b.getType()) { - BoolOp rightB = (BoolOp)right; - e = new exprType[rightB.values.length + 1]; - System.arraycopy(rightB.values, 0, e, 0, rightB.values.length); - e[e.length - 1] = left; - } else { - e = new exprType[2]; - e[0] = left; - e[1] = right; - } - b.values = e; - switch (b.getType()) { - case AND: - b.op = boolopType.And; - break; - case OR: - b.op = boolopType.Or; - break; - default: - b.op = boolopType.UNDEFINED; - } - } -} - :o1=or_test[ctype] ( (IF or_test[expr_contextType.Load] ORELSE) => IF o2=or_test[ctype] ORELSE test[expr_contextType.Load] -> ^(IfExp ^(Test $o2) ^(Body $o1) ^(ORELSE test)) @@ -831,12 +785,32 @@ ; //or_test: and_test ('or' and_test)* -or_test[expr_contextType ctype] : and_test[ctype] (OR<BoolOp>^ and_test[ctype])* - ; +or_test[expr_contextType ctype] +@after { + if ($or != null) { + $or_test.tree = actions.makeBoolOp($left.tree, boolopType.Or, $right); + } +} + : left=and_test[ctype] + ( (or=OR right+=and_test[ctype] + )+ + | -> $left + ) + ; //and_test: not_test ('and' not_test)* -and_test[expr_contextType ctype] : not_test[ctype] (AND<BoolOp>^ not_test[ctype])* - ; +and_test[expr_contextType ctype] +@after { + if ($and != null) { + $and_test.tree = actions.makeBoolOp($left.tree, boolopType.And, $right); + } +} + : left=not_test[ctype] + ( (and=AND right+=not_test[ctype] + )+ + | + ) -> $left + ; //not_test: 'not' not_test | comparison not_test[expr_contextType ctype] returns [exprType etype] @@ -850,7 +824,6 @@ ; //comparison: expr (comp_op expr)* -//comp_op: '<'|'>'|'=='|'>='|'<='|'<>'|'!='|'in'|'not' 'in'|'is'|'is' 'not' comparison[expr_contextType ctype] @init { List cmps = new ArrayList(); Modified: branches/nowalker/src/org/python/antlr/GrammarActions.java =================================================================== --- branches/nowalker/src/org/python/antlr/GrammarActions.java 2008-08-20 06:54:10 UTC (rev 5215) +++ branches/nowalker/src/org/python/antlr/GrammarActions.java 2008-08-20 12:10:26 UTC (rev 5216) @@ -724,4 +724,11 @@ } return new cmpopType[0]; } + + BoolOp makeBoolOp(PythonTree left, boolopType op, List right) { + List values = new ArrayList(); + values.add(left); + values.addAll(right); + return new BoolOp(left, op, makeExprs(values)); + } } Modified: branches/nowalker/src/org/python/antlr/ast/BoolOp.java =================================================================== --- branches/nowalker/src/org/python/antlr/ast/BoolOp.java 2008-08-20 06:54:10 UTC (rev 5215) +++ branches/nowalker/src/org/python/antlr/ast/BoolOp.java 2008-08-20 12:10:26 UTC (rev 5216) @@ -12,10 +12,6 @@ public static final String[] _fields = new String[] {"op","values"}; - public BoolOp(Token token) { - super(token); - } - public BoolOp(Token token, boolopType op, exprType[] values) { super(token); this.op = op; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <zy...@us...> - 2008-08-20 06:54:13
|
Revision: 5215 http://jython.svn.sourceforge.net/jython/?rev=5215&view=rev Author: zyasoft Date: 2008-08-20 06:54:10 +0000 (Wed, 20 Aug 2008) Log Message: ----------- A class definition needs to have __module__ set in frame locals, so that it is accessible by a metaclass, if defined. Fixes test_advice in zope.interfaces Modified Paths: -------------- trunk/jython/src/org/python/compiler/Module.java trunk/jython/src/org/python/core/PyFrame.java Modified: trunk/jython/src/org/python/compiler/Module.java =================================================================== --- trunk/jython/src/org/python/compiler/Module.java 2008-08-20 05:26:20 UTC (rev 5214) +++ trunk/jython/src/org/python/compiler/Module.java 2008-08-20 06:54:10 UTC (rev 5215) @@ -405,6 +405,29 @@ CodeCompiler compiler = new CodeCompiler(this, printResults); + if (classBody) { + Label label_got_name = new Label(); + int module_tmp = c.getLocal("org/python/core/PyObject"); + + c.aload(1); + c.ldc("__module__"); + c.invokevirtual("org/python/core/PyFrame", "getname_or_null", "(" + $str + ")" + $pyObj); + c.dup(); + c.ifnonnull(label_got_name); + + c.pop(); + c.aload(1); + c.ldc("__name__"); + c.invokevirtual("org/python/core/PyFrame", "getname_or_null", "(" + $str + ")" + $pyObj); + + c.label(label_got_name); + c.astore(module_tmp); + c.aload(1); + c.ldc("__module__"); + c.aload(module_tmp); + c.invokevirtual("org/python/core/PyFrame", "setlocal", "(" + $str + $pyObj + ")V"); + } + Label genswitch = new Label(); if (scope.generator) { c.goto_(genswitch); Modified: trunk/jython/src/org/python/core/PyFrame.java =================================================================== --- trunk/jython/src/org/python/core/PyFrame.java 2008-08-20 05:26:20 UTC (rev 5214) +++ trunk/jython/src/org/python/core/PyFrame.java 2008-08-20 06:54:10 UTC (rev 5215) @@ -282,6 +282,20 @@ throw Py.NameError(String.format(NAME_ERROR_MSG, index)); } + public PyObject getname_or_null(String index) { + PyObject ret; + if (f_locals == null || f_locals == f_globals) { + ret = doGetglobal(index); + } else { + ret = f_locals.__finditem__(index); + if (ret != null) { + return ret; + } + ret = doGetglobal(index); + } + return ret; + } + public PyObject getglobal(String index) { PyObject ret = doGetglobal(index); if (ret != null) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nr...@us...> - 2008-08-20 05:26:22
|
Revision: 5214 http://jython.svn.sourceforge.net/jython/?rev=5214&view=rev Author: nriley Date: 2008-08-20 05:26:20 +0000 (Wed, 20 Aug 2008) Log Message: ----------- Turned out those quotes were useful after all. Modified Paths: -------------- trunk/jython/src/shell/jython.bat Modified: trunk/jython/src/shell/jython.bat =================================================================== --- trunk/jython/src/shell/jython.bat 2008-08-20 04:33:02 UTC (rev 5213) +++ trunk/jython/src/shell/jython.bat 2008-08-20 05:26:20 UTC (rev 5214) @@ -24,7 +24,7 @@ set _JYTHON_HOME=%JYTHON_HOME% if not "%JYTHON_HOME%" == "" goto gotHome pushd "%~dp0%\.." -set _JYTHON_HOME=%CD% +set _JYTHON_HOME="%CD%" popd :gotHome This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nr...@us...> - 2008-08-20 04:33:04
|
Revision: 5213 http://jython.svn.sourceforge.net/jython/?rev=5213&view=rev Author: nriley Date: 2008-08-20 04:33:02 +0000 (Wed, 20 Aug 2008) Log Message: ----------- Run Jython regrtest (on Windows) with bytecode verification; support -J, --jdb, -- on Windows too. Modified Paths: -------------- trunk/jython/src/shell/jython.bat Modified: trunk/jython/src/shell/jython.bat =================================================================== --- trunk/jython/src/shell/jython.bat 2008-08-20 00:28:55 UTC (rev 5212) +++ trunk/jython/src/shell/jython.bat 2008-08-20 04:33:02 UTC (rev 5213) @@ -18,13 +18,13 @@ set _JAVA_CMD=java if not "%JAVA_HOME%" == "" ( - set _JAVA_CMD="%JAVA_HOME%\bin\java" + set _JAVA_CMD="%JAVA_HOME:"=%\bin\java" ) -set _JYTHON_HOME="%JYTHON_HOME%" +set _JYTHON_HOME=%JYTHON_HOME% if not "%JYTHON_HOME%" == "" goto gotHome pushd "%~dp0%\.." -set _JYTHON_HOME="%CD%" +set _JYTHON_HOME=%CD% popd :gotHome @@ -32,7 +32,7 @@ rem prefer built version set _CP=%_JYTHON_HOME%\jython.jar for %%j in (%_JYTHON_HOME%\javalib\*.jar) do ( - set _CP=!_CP!;"%%j" + set _CP=!_CP!;"%%j" ) goto run @@ -48,13 +48,103 @@ rem ----- Execute the requested command ---------------------------------------- :run -%_JAVA_CMD% %JAVA_OPTS% -Xss512k -Xbootclasspath/a:%_CP% -Dpython.home=%_JYTHON_HOME% -Dpython.executable="%~f0" -classpath "%CLASSPATH%" org.python.util.jython %JYTHON_OPTS% %* +set _JAVA_STACK=-Xss512k + +rem Escape any quotes. Use _S for ', _D for ", and _U to escape _ itself. +rem We have to escape _ itself, otherwise file names with _S and _D +rem will be converted to to wrong ones, when we un-escape. See JRUBY-2821. +set _ARGS=%* +if not defined _ARGS goto argsDone +set _ARGS=%_ARGS:_=_U% +set _ARGS=%_ARGS:'=_S% +set _ARGS=%_ARGS:"=_D% + +set _ARGS="%_ARGS%" + +:scanArgs +rem split args by spaces into first and rest +for /f "tokens=1,*" %%i in (%_ARGS%) do call :getArg "%%i" "%%j" +goto procArg + +:getArg +rem remove quotes around first arg +for %%i in (%1) do set _CMP=%%~i +set _ARGS=%2 +goto :EOF + +:procArg +if ["%_CMP%"] == [""] ( + set _ARGS= + goto argsDone +) + +REM NOTE: If you'd like to use a parameter with underscore in its name, +REM NOTE: use the quoted value: --do_stuff -> --do_Ustuff + +if ["%_CMP%"] == ["--"] goto argsDone + +if ["%_CMP%"] == ["--jdb"] ( + if "%JAVA_HOME%" == "" ( + set _JAVA_CMD=jdb + ) else ( + set _JAVA_CMD="%_JAVA_HOME:"=%\bin\jdb" + ) + goto :nextArg +) + +if ["%_CMP%"] == ["--verify"] ( + set CLASSPATH=%_CP:"=%;%CLASSPATH:"=% + set _CP= + goto :nextArg +) + +rem now unescape _D, _S and _Q +set _CMP=%_CMP:_D="% +set _CMP=%_CMP:_S='% +set _CMP=%_CMP:_U=_% +set _CMP1=%_CMP:~0,1% +set _CMP2=%_CMP:~0,2% + +rem detect first character is a quote; skip directly to jythonArg +rem this avoids a batch syntax error +if "%_CMP1:"=\\%" == "\\" goto jythonArg + +rem removing quote avoids a batch syntax error +if "%_CMP2:"=\\%" == "-J" goto jvmArg + +:jythonArg +set JYTHON_OPTS=%JYTHON_OPTS% %_CMP% +goto nextArg + +:jvmArg +set _VAL=%_CMP:~2% + +if "%_VAL:~0,4%" == "-Xss" ( + set _JAVA_STACK=%_VAL% + echo %_VAL% + goto nextArg +) + +set _JAVA_OPTS=%_JAVA_OPTS% %_VAL% + +:nextArg +set _CMP= +goto scanArgs + +:argsDone +%_JAVA_CMD% %_JAVA_OPTS% %_JAVA_STACK% -Xbootclasspath/a:%_CP% -Dpython.home=%_JYTHON_HOME% -Dpython.executable="%~f0" -classpath "%CLASSPATH%" org.python.util.jython %JYTHON_OPTS% %_ARGS% set E=%ERRORLEVEL% :cleanup +set _ARGS= +set _CMP= +set _CMP1= +set _CMP2= +set _CP= +set _JAVA_CMD= +set _JAVA_OPTS= +set _JAVA_STACK= set _JYTHON_HOME= -set _JAVA_CMD= -set _CP= :finish exit /b %E% This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2008-08-20 00:28:58
|
Revision: 5212 http://jython.svn.sourceforge.net/jython/?rev=5212&view=rev Author: pjenvey Date: 2008-08-20 00:28:55 +0000 (Wed, 20 Aug 2008) Log Message: ----------- o rename unmarshalCode -> readCode, as it doesn't relate to Python's marshal o zipimport shouldn't cacheCompiledSource (it's just been silently failing), and use java enums Modified Paths: -------------- trunk/jython/Lib/pkgutil.py trunk/jython/src/org/python/core/imp.java trunk/jython/src/org/python/modules/zipimport/zipimporter.java Modified: trunk/jython/Lib/pkgutil.py =================================================================== --- trunk/jython/Lib/pkgutil.py 2008-08-19 23:34:29 UTC (rev 5211) +++ trunk/jython/Lib/pkgutil.py 2008-08-20 00:28:55 UTC (rev 5212) @@ -22,7 +22,7 @@ # accessed by _imp here def read_jython_code(fullname, file, filename): - data = _imp.unmarshalCode(filename, file, False) + data = _imp.readCode(filename, file, False) return BytecodeLoader.makeCode(fullname + "$py", data, filename) def simplegeneric(func): Modified: trunk/jython/src/org/python/core/imp.java =================================================================== --- trunk/jython/src/org/python/core/imp.java 2008-08-19 23:34:29 UTC (rev 5211) +++ trunk/jython/src/org/python/core/imp.java 2008-08-20 00:28:55 UTC (rev 5212) @@ -87,7 +87,7 @@ static PyObject createFromPyClass(String name, InputStream fp, boolean testing, String fileName) { - byte[] data = unmarshalCode(name, fp, testing); + byte[] data = readCode(name, fp, testing); if (testing && data == null) { return null; } @@ -107,8 +107,7 @@ return createFromCode(name, code, fileName); } - public static byte[] unmarshalCode(String name, InputStream fp, - boolean testing) { + public static byte[] readCode(String name, InputStream fp, boolean testing) { byte[] data = readBytes(fp); int n = data.length; Modified: trunk/jython/src/org/python/modules/zipimport/zipimporter.java =================================================================== --- trunk/jython/src/org/python/modules/zipimport/zipimporter.java 2008-08-19 23:34:29 UTC (rev 5211) +++ trunk/jython/src/org/python/modules/zipimport/zipimporter.java 2008-08-20 00:28:55 UTC (rev 5212) @@ -6,6 +6,7 @@ import java.io.InputStream; import java.util.Date; import java.util.Enumeration; +import java.util.EnumSet; import java.util.zip.ZipEntry; import java.util.zip.ZipFile; @@ -51,19 +52,22 @@ /** zip_searchorder defines how we search for a module in the Zip * archive */ - static final int IS_SOURCE = 0; - static final int IS_BYTECODE = 1; - static final int IS_PACKAGE = 2; + static enum EntryType { + IS_SOURCE, IS_BYTECODE, IS_PACKAGE + }; static final SearchOrderEntry[] zip_searchorder = new SearchOrderEntry[] { - new SearchOrderEntry(File.separator + "__init__$py.class", IS_PACKAGE | IS_BYTECODE), - new SearchOrderEntry(File.separator + "__init__.py", IS_PACKAGE | IS_SOURCE), - new SearchOrderEntry("$py.class", IS_BYTECODE), - new SearchOrderEntry(".py", IS_SOURCE), - new SearchOrderEntry("", 0) + new SearchOrderEntry(File.separator + "__init__$py.class", + EnumSet.of(EntryType.IS_PACKAGE, EntryType.IS_BYTECODE)), + new SearchOrderEntry(File.separator + "__init__.py", + EnumSet.of(EntryType.IS_PACKAGE, EntryType.IS_SOURCE)), + new SearchOrderEntry("$py.class", EnumSet.of(EntryType.IS_BYTECODE)), + new SearchOrderEntry(".py", EnumSet.of(EntryType.IS_SOURCE)), }; /** Module information */ - static enum ModuleInfo {ERROR, NOT_FOUND, MODULE, PACKAGE}; + static enum ModuleInfo { + ERROR, NOT_FOUND, MODULE, PACKAGE + }; /** Pathname of the Zip archive */ @ExposedGet @@ -366,7 +370,7 @@ if (tocEntry == null) continue; - if ((entry.type & IS_PACKAGE) == IS_PACKAGE) { + if (entry.type.contains(EntryType.IS_PACKAGE)) { return ModuleInfo.PACKAGE; } return ModuleInfo.MODULE; @@ -399,8 +403,8 @@ continue; } - boolean ispackage = (entry.type & IS_PACKAGE) == IS_PACKAGE; - boolean isbytecode = (entry.type & IS_BYTECODE) == IS_BYTECODE; + boolean ispackage = entry.type.contains(EntryType.IS_PACKAGE); + boolean isbytecode = entry.type.contains(EntryType.IS_BYTECODE); if (isbytecode && isOutdatedBytecode(searchPath, tocEntry)) { continue; @@ -410,7 +414,7 @@ ZipBundle zipBundle = getDataStream(searchPath); byte[] codeBytes; if (isbytecode) { - codeBytes = imp.unmarshalCode(fullname, zipBundle.inputStream, true); + codeBytes = imp.readCode(fullname, zipBundle.inputStream, true); } else { codeBytes = imp.compileSource(fullname, zipBundle.inputStream, pathToEntry); @@ -422,7 +426,6 @@ continue; } - imp.cacheCompiledSource(pathToEntry, null, codeBytes); PyCode code = BytecodeLoader.makeCode(fullname + "$py", codeBytes, pathToEntry); return new ModuleCodeData(code, ispackage, pathToEntry); } @@ -661,9 +664,9 @@ */ protected static class SearchOrderEntry { public String suffix; - public int type; + public EnumSet type; - public SearchOrderEntry(String suffix, int type) { + public SearchOrderEntry(String suffix, EnumSet type) { this.suffix = suffix; this.type = type; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2008-08-19 23:34:37
|
Revision: 5211 http://jython.svn.sourceforge.net/jython/?rev=5211&view=rev Author: pjenvey Date: 2008-08-19 23:34:29 +0000 (Tue, 19 Aug 2008) Log Message: ----------- small cleanup Modified Paths: -------------- trunk/jython/src/org/python/core/PyBaseException.java trunk/jython/src/org/python/core/PyObject.java trunk/jython/src/org/python/core/__builtin__.java Modified: trunk/jython/src/org/python/core/PyBaseException.java =================================================================== --- trunk/jython/src/org/python/core/PyBaseException.java 2008-08-19 21:43:06 UTC (rev 5210) +++ trunk/jython/src/org/python/core/PyBaseException.java 2008-08-19 23:34:29 UTC (rev 5211) @@ -166,23 +166,20 @@ } } + @Override public String toString() { - return __repr__().toString(); + return BaseException_toString(); } - - public PyString __repr__() { - return BaseException___repr__(); - } - @ExposedMethod - final PyString BaseException___repr__() { + @ExposedMethod(names = ("__repr__")) + final String BaseException_toString() { PyObject reprSuffix = args.__repr__(); String name = getType().fastGetName(); int lastDot = name.lastIndexOf('.'); if (lastDot != -1) { name = name.substring(lastDot + 1); } - return Py.newString(name + reprSuffix.toString()); + return name + reprSuffix.toString(); } @ExposedSet(name = "args") Modified: trunk/jython/src/org/python/core/PyObject.java =================================================================== --- trunk/jython/src/org/python/core/PyObject.java 2008-08-19 21:43:06 UTC (rev 5210) +++ trunk/jython/src/org/python/core/PyObject.java 2008-08-19 23:34:29 UTC (rev 5211) @@ -281,7 +281,7 @@ * * @param arg0 the first argument to the function. * @param arg1 the second argument to the function. -n **/ + **/ public PyObject __call__(PyObject arg0, PyObject arg1) { return __call__(new PyObject[] { arg0, arg1 }, Py.NoKeywords); } Modified: trunk/jython/src/org/python/core/__builtin__.java =================================================================== --- trunk/jython/src/org/python/core/__builtin__.java 2008-08-19 21:43:06 UTC (rev 5210) +++ trunk/jython/src/org/python/core/__builtin__.java 2008-08-19 23:34:29 UTC (rev 5211) @@ -1410,7 +1410,7 @@ @Override public String toString() { - return "<built-in function min>"; + return "<built-in function max>"; } private static PyObject max(PyObject o, PyObject key) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2008-08-19 21:43:09
|
Revision: 5210 http://jython.svn.sourceforge.net/jython/?rev=5210&view=rev Author: fwierzbicki Date: 2008-08-19 21:43:06 +0000 (Tue, 19 Aug 2008) Log Message: ----------- Work to date on the one pass grammar. Not ready for others to look at really. If you really want to try it note that you need to comment out parts of site.py and os.py to get things to work. They *almost* parse and compile, but not quite, and they are basic dependencies for Jython to run. Modified Paths: -------------- branches/nowalker/build.xml branches/nowalker/grammar/Python.g branches/nowalker/src/org/python/antlr/ExpressionParser.java branches/nowalker/src/org/python/antlr/GrammarActions.java branches/nowalker/src/org/python/antlr/InteractiveParser.java branches/nowalker/src/org/python/antlr/ModuleParser.java branches/nowalker/src/org/python/antlr/ast/BinOp.java branches/nowalker/src/org/python/antlr/ast/BoolOp.java branches/nowalker/src/org/python/util/jython.java branches/nowalker/tests/java/org/python/antlr/PythonTreeTester.java Removed Paths: ------------- branches/nowalker/grammar/PythonWalker.g Modified: branches/nowalker/build.xml =================================================================== --- branches/nowalker/build.xml 2008-08-19 21:17:36 UTC (rev 5209) +++ branches/nowalker/build.xml 2008-08-19 21:43:06 UTC (rev 5210) @@ -434,7 +434,6 @@ <arg value="-lib"/> <arg path="${work.dir}/build/gensrc/org/python/antlr"/> <arg file="${jython.base.dir}/grammar/Python.g"/> - <arg file="${jython.base.dir}/grammar/PythonWalker.g"/> <arg file="${jython.base.dir}/grammar/PythonPartial.g"/> <classpath refid="main.classpath"/> </java> Modified: branches/nowalker/grammar/Python.g =================================================================== --- branches/nowalker/grammar/Python.g 2008-08-19 21:17:36 UTC (rev 5209) +++ branches/nowalker/grammar/Python.g 2008-08-19 21:43:06 UTC (rev 5210) @@ -75,74 +75,26 @@ INDENT; DEDENT; - Module; + PYNODE; Interactive; Expression; - NameTok; Test; - Msg; - Level; Body; - Bases; - Arguments; - Args; - Arg; - Keyword; - StarArgs; - KWArgs; - Assign; - AugAssign; - Tuple; - List; Dict; IfExp; - TryExcept; - TryFinally; - ExceptHandler; - StrTok; - NumTok; - IsNot; - NotIn; - Type; - Inst; - Tback; - Globals; - Locals; Ellipsis; ListComp; Repr; - Subscript; - SubscriptList; - Index; Target; - Value; - Lower; - Upper; - Step; - UAdd; - USub; - Invert; - Alias; - Asname; - Decorators; GeneratorExp; Ifs; Elts; - Call; - Dest; - Values; - Newline; - FpList; - StepOp; - UpperOp; - GenFor; GenIf; ListFor; ListIf; - Parens; - Brackets; + } @header { @@ -152,29 +104,68 @@ import org.python.antlr.ParseException; import org.python.antlr.PythonTree; +import org.python.antlr.ast.aliasType; import org.python.antlr.ast.argumentsType; +import org.python.antlr.ast.Assert; +import org.python.antlr.ast.Assign; import org.python.antlr.ast.Attribute; +import org.python.antlr.ast.AugAssign; +import org.python.antlr.ast.BinOp; +import org.python.antlr.ast.BoolOp; +import org.python.antlr.ast.boolopType; import org.python.antlr.ast.Break; +import org.python.antlr.ast.Call; +import org.python.antlr.ast.ClassDef; +import org.python.antlr.ast.cmpopType; +import org.python.antlr.ast.Compare; +import org.python.antlr.ast.comprehensionType; import org.python.antlr.ast.Context; import org.python.antlr.ast.Continue; +import org.python.antlr.ast.Delete; +import org.python.antlr.ast.excepthandlerType; +import org.python.antlr.ast.Exec; import org.python.antlr.ast.Expr; import org.python.antlr.ast.exprType; import org.python.antlr.ast.expr_contextType; +import org.python.antlr.ast.ExtSlice; +import org.python.antlr.ast.For; import org.python.antlr.ast.FunctionDef; +import org.python.antlr.ast.Global; +import org.python.antlr.ast.If; +import org.python.antlr.ast.Import; +import org.python.antlr.ast.ImportFrom; +import org.python.antlr.ast.Index; +import org.python.antlr.ast.keywordType; +import org.python.antlr.ast.Lambda; import org.python.antlr.ast.modType; import org.python.antlr.ast.Module; import org.python.antlr.ast.Name; import org.python.antlr.ast.Num; import org.python.antlr.ast.Pass; import org.python.antlr.ast.Print; +import org.python.antlr.ast.Raise; +import org.python.antlr.ast.operatorType; import org.python.antlr.ast.Return; +import org.python.antlr.ast.Slice; +import org.python.antlr.ast.sliceType; import org.python.antlr.ast.stmtType; import org.python.antlr.ast.Str; +import org.python.antlr.ast.Subscript; +import org.python.antlr.ast.TryExcept; +import org.python.antlr.ast.TryFinally; +import org.python.antlr.ast.Tuple; +import org.python.antlr.ast.unaryopType; +import org.python.antlr.ast.UnaryOp; +import org.python.antlr.ast.While; +import org.python.antlr.ast.With; +import org.python.antlr.ast.Yield; import org.python.core.Py; import org.python.core.PyString; import org.python.core.PyUnicode; import java.math.BigInteger; +import java.util.Iterator; +import java.util.ListIterator; } @members { @@ -297,17 +288,21 @@ ; //file_input: (NEWLINE | stmt)* ENDMARKER -file_input : (NEWLINE | stmt)* EOF - -> ^(Module stmt*) - ; +file_input + : (NEWLINE | s+=stmt)+ -> ^(PYNODE<Module>[$file_input.start, actions.makeStmts($s)]) + | -> ^(PYNODE<Module>[$file_input.start, new stmtType[0\]]) + ; //eval_input: testlist NEWLINE* ENDMARKER eval_input : LEADING_WS? (NEWLINE)* testlist[expr_contextType.Load] (NEWLINE)* EOF -> ^(Expression testlist) ; //not in CPython's Grammar file -dotted_attr - : NAME (DOT^ attr)* +dotted_attr returns [exprType etype] + : n1=NAME + ( (DOT n2+=dotted_attr)+ { $etype = actions.makeDottedAttr($n1, $n2); } + | { $etype = new Name($NAME, $NAME.text, expr_contextType.Load); } + ) ; //attr is here for Java compatibility. A Java foo.getIf() can be called from Jython as foo.if @@ -349,62 +344,94 @@ ; //decorator: '@' dotted_name [ '(' [arglist] ')' ] NEWLINE -decorator: AT dotted_attr - ( (LPAREN arglist? RPAREN) -> ^(AT dotted_attr ^(Call ^(Args arglist)?)) - | -> ^(AT dotted_attr) - ) NEWLINE - ; +decorator returns [exprType etype] +@after { + $decorator.tree = $etype; +} + : AT dotted_attr + //XXX: ignoring the arglist and Call generation right now. + ( LPAREN (arglist + {$etype = new Call($LPAREN, $dotted_attr.etype, actions.makeExprs($arglist.args), + actions.makeKeywords($arglist.keywords), $arglist.starargs, $arglist.kwargs);} + | {$etype = $dotted_attr.etype;} + ) + RPAREN + // ^(Decorator dotted_attr ^(CallTok ^(Args arglist)?)) + | { $etype = $dotted_attr.etype; } + ) NEWLINE + ; //decorators: decorator+ -decorators: decorator+ - ; +decorators returns [List etypes] + : d+=decorator+ {$etypes = $d;} + ; //funcdef: [decorators] 'def' NAME parameters ':' suite funcdef : decorators? DEF NAME parameters COLON suite - -> ^(DEF NAME parameters ^(Body suite) ^(Decorators decorators?)) + -> ^(DEF<FunctionDef>[$DEF, $NAME.text, $parameters.args, actions.makeStmts($suite.stmts), + actions.makeExprs($decorators.etypes)]) ; //parameters: '(' [varargslist] ')' -parameters : LPAREN - (varargslist -> ^(Arguments varargslist) - | -> ^(Arguments) - ) - RPAREN - ; +parameters returns [argumentsType args] + : LPAREN + (varargslist {$args = $varargslist.args;} + | {$args = new argumentsType($parameters.start, new exprType[0], null, null, new exprType[0]);} + ) + RPAREN + ; //not in CPython's Grammar file -defparameter : fpdef (ASSIGN test[expr_contextType.Load])? {debug("parsed defparameter");} - ; +defparameter[List defaults] returns [exprType etype] +@after { + $defparameter.tree = $etype; +} + : fpdef[expr_contextType.Param] (ASSIGN test[expr_contextType.Load])? { + $etype = (exprType)$fpdef.tree; + if ($ASSIGN != null) { + defaults.add($test.tree); + } else if (!defaults.isEmpty()) { + throw new ParseException( + "non-default argument follows default argument", + $fpdef.tree); + } + } +; //varargslist: ((fpdef ['=' test] ',')* // ('*' NAME [',' '**' NAME] | '**' NAME) | // fpdef ['=' test] (',' fpdef ['=' test])* [',']) -varargslist : defparameter (options {greedy=true;}:COMMA defparameter)* - (COMMA - ( STAR starargs=NAME (COMMA DOUBLESTAR kwargs=NAME)? - | DOUBLESTAR kwargs=NAME - )? - )? {debug("parsed varargslist");} - -> ^(Args defparameter+) ^(StarArgs $starargs)? ^(KWArgs $kwargs)? - | STAR starargs=NAME (COMMA DOUBLESTAR kwargs=NAME)?{debug("parsed varargslist STARARGS");} - -> ^(StarArgs $starargs) ^(KWArgs $kwargs)? - | DOUBLESTAR kwargs=NAME {debug("parsed varargslist KWS");} - -> ^(KWArgs $kwargs) - ; +varargslist returns [argumentsType args] +@init { + List defaults = new ArrayList(); +} + : d+=defparameter[defaults] (options {greedy=true;}:COMMA d+=defparameter[defaults])* + (COMMA + ( STAR starargs=NAME (COMMA DOUBLESTAR kwargs=NAME)? + | DOUBLESTAR kwargs=NAME + )? + )? + {$args = actions.makeArgumentsType($varargslist.start, $d, $starargs, $kwargs, defaults);} + | STAR starargs=NAME (COMMA DOUBLESTAR kwargs=NAME)?{debug("parsed varargslist STARARGS");} + {$args = actions.makeArgumentsType($varargslist.start, $d, $starargs, $kwargs, defaults);} + | DOUBLESTAR kwargs=NAME {debug("parsed varargslist KWS");} + {$args = actions.makeArgumentsType($varargslist.start, $d, null, $kwargs, defaults);} + ; //fpdef: NAME | '(' fplist ')' -fpdef : NAME {debug("parsed fpdef NAME");} - | (LPAREN fpdef COMMA) => LPAREN fplist RPAREN - -> ^(FpList fplist) +fpdef[expr_contextType ctype] : NAME + -> ^(PYNODE<Name>[$NAME, $NAME.text, ctype]) + | (LPAREN fpdef[expr_contextType.Load] COMMA) => LPAREN fplist RPAREN + -> fplist | LPAREN fplist RPAREN - -> fplist + -> ^(LPAREN<Tuple>[$fplist.start, actions.makeExprs($fplist.etypes), expr_contextType.Store]) ; //fplist: fpdef (',' fpdef)* [','] -fplist : fpdef (options {greedy=true;}:COMMA fpdef)* (COMMA)? - {debug("parsed fplist");} - -> fpdef+ - ; +fplist returns [List etypes] + : f+=fpdef[expr_contextType.Store] (options {greedy=true;}:COMMA f+=fpdef[expr_contextType.Store])* (COMMA)? + {$etypes = $f;} + ; //stmt: simple_stmt | compound_stmt stmt : simple_stmt @@ -430,111 +457,103 @@ //expr_stmt: testlist (augassign (yield_expr|testlist) | // ('=' (yield_expr|testlist))*) -expr_stmt : lhs=testlist[expr_contextType.Store] - ( (augassign yield_expr -> ^(augassign $lhs yield_expr)) - | (augassign rhs=testlist[expr_contextType.Load] -> ^(augassign $lhs $rhs)) - | ((assigns) {debug("matched assigns");} -> ^(Assign ^(Target $lhs) assigns)) - | -> $lhs - ) - ; - -//not in CPython's Grammar file -assigns - @after { - PythonTree pt = ((PythonTree)$assigns.tree); - int children = pt.getChildCount(); - PythonTree child; - if (children == 1) { - child = pt; - pt.token = new CommonToken(Value, "Value"); - } else { - child = (PythonTree)pt.getChild(children - 1); - child.token = new CommonToken(Value, "Value"); - } - child.token = new CommonToken(Value, "Value"); - PythonTree targ = (PythonTree)child.getChild(0); - if (targ instanceof Context) { - ((Context)targ).setContext(expr_contextType.Load); - } +expr_stmt +@init { + stmtType stype = null; } - : assign_testlist+ - | assign_yield+ - ; +@after { + if (stype != null) { + $expr_stmt.tree = stype; + } +} -//not in CPython's Grammar file -assign_testlist - : ASSIGN testlist[expr_contextType.Store] -> ^(Target testlist) - ; - -//not in CPython's Grammar file -assign_yield - : ASSIGN yield_expr -> ^(Value yield_expr) + : + ((testlist[expr_contextType.Load] augassign) => lhs=testlist[expr_contextType.AugStore] + ( (aay=augassign y1=yield_expr {stype = new AugAssign($lhs.tree, (exprType)$lhs.tree, $aay.op, (exprType)$y1.tree);}) + | (aat=augassign rhs=testlist[expr_contextType.Load] {stype = new AugAssign($lhs.tree, (exprType)$lhs.tree, $aat.op, (exprType)$rhs.tree);}) + ) + |(testlist[expr_contextType.Load] ASSIGN) => lhs=testlist[expr_contextType.Store] + ( + | ((at=ASSIGN t+=testlist[expr_contextType.Store])+ -> ^(PYNODE<Assign>[$at, actions.makeAssignTargets((exprType)$lhs.tree, $t), actions.makeAssignValue($t)])) + | ((ay=ASSIGN y2+=yield_expr)+ -> ^(PYNODE<Assign>[$ay, actions.makeAssignTargets((exprType)$lhs.tree, $y2), actions.makeAssignValue($y2)])) + ) + | lhs=testlist[expr_contextType.Load] -> PYNODE<Expr>[$lhs.start, (exprType)$lhs.tree] + ) ; //augassign: ('+=' | '-=' | '*=' | '/=' | '%=' | '&=' | '|=' | '^=' | // '<<=' | '>>=' | '**=' | '//=') -augassign : PLUSEQUAL - | MINUSEQUAL - | STAREQUAL - | SLASHEQUAL - | PERCENTEQUAL - | AMPEREQUAL - | VBAREQUAL - | CIRCUMFLEXEQUAL - | LEFTSHIFTEQUAL - | RIGHTSHIFTEQUAL - | DOUBLESTAREQUAL - | DOUBLESLASHEQUAL - ; +augassign returns [operatorType op] + : PLUSEQUAL {$op = operatorType.Add;} + | MINUSEQUAL {$op = operatorType.Sub;} + | STAREQUAL {$op = operatorType.Mult;} + | SLASHEQUAL {$op = operatorType.Div;} + | PERCENTEQUAL {$op = operatorType.Mod;} + | AMPEREQUAL {$op = operatorType.BitAnd;} + | VBAREQUAL {$op = operatorType.BitOr;} + | CIRCUMFLEXEQUAL {$op = operatorType.BitXor;} + | LEFTSHIFTEQUAL {$op = operatorType.LShift;} + | RIGHTSHIFTEQUAL {$op = operatorType.RShift;} + | DOUBLESTAREQUAL {$op = operatorType.Pow;} + | DOUBLESLASHEQUAL {$op = operatorType.FloorDiv;} + ; //print_stmt: 'print' ( [ test (',' test)* [','] ] | // '>>' test [ (',' test)+ [','] ] ) -print_stmt : PRINT - ( t1=printlist -> {$t1.newline}? ^(PRINT ^(Values $t1) ^(Newline)) - -> ^(PRINT ^(Values $t1)) - | RIGHTSHIFT t2=printlist2 -> {$t2.newline}? ^(PRINT ^(Dest RIGHTSHIFT) ^(Values $t2) ^(Newline)) - -> ^(PRINT ^(Dest RIGHTSHIFT) ^(Values $t2)) - | -> ^(PRINT ^(Newline)) +print_stmt : PRINT + ( t1=printlist + -> ^(PRINT<Print>[$PRINT, null, actions.makeExprs($t1.elts), $t1.newline]) + | RIGHTSHIFT t2=printlist2 + -> ^(PRINT<Print>[$PRINT, (exprType)$t2.elts.get(0), actions.makeExprs($t2.elts, 1), $t2.newline]) + | + -> ^(PRINT<Print>[$PRINT, null, new exprType[0\], false]) ) ; //not in CPython's Grammar file -printlist returns [boolean newline] - : (test[expr_contextType.Load] COMMA) => test[expr_contextType.Load] (options {k=2;}: COMMA test[expr_contextType.Load])* (trailcomma=COMMA)? - { if ($trailcomma == null) { - $newline = true; +printlist returns [boolean newline, List elts] + : (test[expr_contextType.Load] COMMA) => + t+=test[expr_contextType.Load] (options {k=2;}: COMMA t+=test[expr_contextType.Load])* (trailcomma=COMMA)? + { $elts=$t; + if ($trailcomma == null) { + $newline = true; } else { - $newline = false; + $newline = false; } } - -> ^(Elts test+) - | test[expr_contextType.Load] {$newline = true;} - -> ^(Elts test) + | t+=test[expr_contextType.Load] { + $elts=$t; + $newline = true; + } ; +//XXX: would be nice if printlist and printlist2 could be merged. //not in CPython's Grammar file -printlist2 returns [boolean newline] - : (test[expr_contextType.Load] COMMA test[expr_contextType.Load]) => test[expr_contextType.Load] (options {k=2;}: COMMA test[expr_contextType.Load])* (trailcomma=COMMA)? - { if ($trailcomma == null) { - $newline = true; +printlist2 returns [boolean newline, List elts] + : (test[expr_contextType.Load] COMMA test[expr_contextType.Load]) => + t+=test[expr_contextType.Load] (options {k=2;}: COMMA t+=test[expr_contextType.Load])* (trailcomma=COMMA)? + { $elts=$t; + if ($trailcomma == null) { + $newline = true; } else { - $newline = false; + $newline = false; } } - -> ^(Elts test+) - | test[expr_contextType.Load] {$newline = true;} - -> ^(Elts test) + | t+=test[expr_contextType.Load] { + $elts=$t; + $newline = true; + } ; //del_stmt: 'del' exprlist del_stmt : DELETE exprlist2 - -> ^(DELETE exprlist2) + -> ^(DELETE<Delete>[$DELETE, actions.makeExprs($exprlist2.etypes)]) ; //pass_stmt: 'pass' -pass_stmt : PASS - -> ^(PASS) +pass_stmt : PASS + -> ^(PASS<Pass>[$PASS]) ; //flow_stmt: break_stmt | continue_stmt | return_stmt | raise_stmt | yield_stmt @@ -556,17 +575,19 @@ ; //return_stmt: 'return' [testlist] -return_stmt : RETURN (testlist[expr_contextType.Load])? - -> ^(RETURN ^(Value testlist)?) +return_stmt : RETURN + (testlist[expr_contextType.Load] -> ^(RETURN<Return>[$RETURN, (exprType)$testlist.tree]) + | -> ^(RETURN<Return>[$RETURN, null]) + ) ; //yield_stmt: yield_expr -yield_stmt : yield_expr +yield_stmt : yield_expr -> ^(PYNODE<Expr>[$yield_expr.start, (exprType)$yield_expr.tree]) ; //raise_stmt: 'raise' [test [',' test [',' test]]] raise_stmt: RAISE (t1=test[expr_contextType.Load] (COMMA t2=test[expr_contextType.Load] (COMMA t3=test[expr_contextType.Load])?)?)? - -> ^(RAISE ^(Type $t1)? ^(Inst $t2)? ^(Tback $t3)?) + -> ^(RAISE<Raise>[$RAISE, (exprType)$t1.tree, (exprType)$t2.tree, (exprType)$t3.tree]) ; //import_stmt: import_name | import_from @@ -576,56 +597,82 @@ //import_name: 'import' dotted_as_names import_name : IMPORT dotted_as_names - -> ^(IMPORT dotted_as_names) + -> ^(IMPORT<Import>[$IMPORT, $dotted_as_names.atypes]) ; //import_from: ('from' ('.'* dotted_name | '.'+) // 'import' ('*' | '(' import_as_names ')' | import_as_names)) -import_from: FROM (DOT* dotted_name | DOT+) IMPORT +import_from: FROM (d+=DOT* dotted_name | d+=DOT+) IMPORT (STAR - -> ^(FROM ^(Level DOT*)? ^(Value dotted_name)? ^(IMPORT STAR)) - | import_as_names - -> ^(FROM ^(Level DOT*)? ^(Value dotted_name)? ^(IMPORT import_as_names)) - | LPAREN import_as_names COMMA? RPAREN - -> ^(FROM ^(Level DOT*)? ^(Value dotted_name)? ^(IMPORT import_as_names)) + -> ^(FROM<ImportFrom>[$FROM, actions.makeFromText($d, $dotted_name.text), actions.makeStarAlias($STAR), actions.makeLevel($d)]) + | i1=import_as_names + -> ^(FROM<ImportFrom>[$FROM, actions.makeFromText($d, $dotted_name.text), actions.makeAliases($i1.atypes), actions.makeLevel($d)]) + | LPAREN i2=import_as_names COMMA? RPAREN + -> ^(FROM<ImportFrom>[$FROM, actions.makeFromText($d, $dotted_name.text), actions.makeAliases($i2.atypes), actions.makeLevel($d)]) ) ; //import_as_names: import_as_name (',' import_as_name)* [','] -import_as_names : import_as_name (COMMA! import_as_name)* - ; +import_as_names returns [aliasType[\] atypes] + : n+=import_as_name (COMMA! n+=import_as_name)* { + $atypes = (aliasType[])$n.toArray(new aliasType[$n.size()]); + } + ; //import_as_name: NAME [('as' | NAME) NAME] -import_as_name : name=NAME (AS asname=NAME)? - -> ^(Alias $name ^(Asname $asname)?) - ; +import_as_name returns [aliasType atype] +@after { + $import_as_name.tree = $atype; +} + : name=NAME (AS asname=NAME)? { + $atype = new aliasType($name, $name.text, $asname.text); + } + ; //XXX: when does CPython Grammar match "dotted_name NAME NAME"? //dotted_as_name: dotted_name [('as' | NAME) NAME] -dotted_as_name : dotted_name (AS asname=NAME)? - -> ^(Alias dotted_name ^(Asname NAME)?) - ; +dotted_as_name returns [aliasType atype] +@after { + $dotted_as_name.tree = $atype; +} + : dotted_name (AS NAME)? { + $atype = new aliasType($NAME, $dotted_name.text, $NAME.text); + } + ; + //dotted_as_names: dotted_as_name (',' dotted_as_name)* -dotted_as_names : dotted_as_name (COMMA! dotted_as_name)* - ; +dotted_as_names returns [aliasType[\] atypes] + : d+=dotted_as_name (COMMA! d+=dotted_as_name)* { + $atypes = (aliasType[])$d.toArray(new aliasType[$d.size()]); + } + ; + //dotted_name: NAME ('.' NAME)* dotted_name : NAME (DOT attr)* ; //global_stmt: 'global' NAME (',' NAME)* -global_stmt : GLOBAL NAME (COMMA NAME)* - -> ^(GLOBAL NAME+) +global_stmt : GLOBAL n+=NAME (COMMA n+=NAME)* + -> ^(GLOBAL<Global>[$GLOBAL, actions.makeNames($n)]) ; //exec_stmt: 'exec' expr ['in' test [',' test]] -exec_stmt : EXEC expr[expr_contextType.Load] (IN t1=test[expr_contextType.Load] (COMMA t2=test[expr_contextType.Load])?)? - -> ^(EXEC expr ^(Globals $t1)? ^(Locals $t2)?) - ; +exec_stmt +@init { + stmtType stype = null; +} +@after { + $exec_stmt.tree = stype; +} + : EXEC expr[expr_contextType.Load] (IN t1=test[expr_contextType.Load] (COMMA t2=test[expr_contextType.Load])?)? { + stype = new Exec($expr.start, (exprType)$expr.tree, (exprType)$t1.tree, (exprType)$t2.tree); + } + ; //assert_stmt: 'assert' test [',' test] assert_stmt : ASSERT t1=test[expr_contextType.Load] (COMMA t2=test[expr_contextType.Load])? - -> ^(ASSERT ^(Test $t1) ^(Msg $t2)?) + -> ^(ASSERT<Assert>[$ASSERT, (exprType)$t1.tree, (exprType)$t2.tree]) ; //compound_stmt: if_stmt | while_stmt | for_stmt | try_stmt | funcdef | classdef @@ -639,62 +686,142 @@ ; //if_stmt: 'if' test ':' suite ('elif' test ':' suite)* ['else' ':' suite] -if_stmt: IF test[expr_contextType.Load] COLON ifsuite=suite elif_clause* (ORELSE COLON elsesuite=suite)? - -> ^(IF test $ifsuite elif_clause* ^(ORELSE $elsesuite)?) +if_stmt: IF test[expr_contextType.Load] COLON ifsuite=suite elifs+=elif_clause* (ORELSE COLON elsesuite=suite)? + -> ^(IF<If>[$IF, (exprType)$test.tree, actions.makeStmts($ifsuite.stmts), actions.makeElses($elsesuite.stmts, $elifs)]) ; //not in CPython's Grammar file elif_clause : ELIF test[expr_contextType.Load] COLON suite - -> ^(ELIF test suite) + -> ^(ELIF<If>[$ELIF, (exprType)$test.tree, actions.makeStmts($suite.stmts), new stmtType[0\]]) ; //while_stmt: 'while' test ':' suite ['else' ':' suite] -while_stmt : WHILE test[expr_contextType.Load] COLON s1=suite (ORELSE COLON s2=suite)? - -> ^(WHILE test ^(Body $s1) ^(ORELSE $s2)?) - ; +while_stmt +@init { + stmtType stype = null; +} +@after { + $while_stmt.tree = stype; +} + : WHILE test[expr_contextType.Load] COLON s1=suite (ORELSE COLON s2=suite)? { + stype = actions.makeWhile($WHILE, (exprType)$test.tree, $s1.stmts, $s2.stmts); + } + ; //for_stmt: 'for' exprlist 'in' testlist ':' suite ['else' ':' suite] -for_stmt : FOR exprlist[expr_contextType.Store] IN testlist[expr_contextType.Load] COLON s1=suite (ORELSE COLON s2=suite)? - -> ^(FOR ^(Target exprlist) ^(IN testlist) ^(Body $s1) ^(ORELSE $s2)?) - ; +for_stmt +@init { + stmtType stype = null; +} +@after { + $for_stmt.tree = stype; +} + : FOR exprlist[expr_contextType.Store] IN testlist[expr_contextType.Load] COLON s1=suite (ORELSE COLON s2=suite)? { + stype = actions.makeFor($FOR, $exprlist.etype, (exprType)$testlist.tree, $s1.stmts, $s2.stmts); + } + ; //try_stmt: ('try' ':' suite // ((except_clause ':' suite)+ // ['else' ':' suite] // ['finally' ':' suite] | // 'finally' ':' suite)) -try_stmt : TRY COLON trysuite=suite - ( (except_clause+ (ORELSE COLON elsesuite=suite)? (FINALLY COLON finalsuite=suite)? - -> ^(TryExcept[$TRY] ^(Body $trysuite) except_clause+ ^(ORELSE $elsesuite)? ^(FINALLY $finalsuite)?)) - | (FINALLY COLON finalsuite=suite - -> ^(TryFinally[$TRY] ^(Body $trysuite) ^(FINALLY $finalsuite))) - ) - ; +try_stmt +@init { + stmtType stype = null; +} +@after { + $try_stmt.tree = stype; +} + : TRY COLON trysuite=suite + ( e+=except_clause+ (ORELSE COLON elsesuite=suite)? (FINALLY COLON finalsuite=suite)? { + stype = actions.makeTryExcept($TRY, $trysuite.stmts, $e, $elsesuite.stmts, $finalsuite.stmts); + } + | FINALLY COLON finalsuite=suite { + stype = actions.makeTryFinally($TRY, $trysuite.stmts, $finalsuite.stmts); + } + ) + ; //with_stmt: 'with' test [ with_var ] ':' suite -with_stmt: WITH test[expr_contextType.Load] (with_var)? COLON suite - -> ^(WITH test with_var? ^(Body suite)) - ; +with_stmt +@init { + stmtType stype = null; +} +@after { + $with_stmt.tree = stype; +} + :WITH test[expr_contextType.Load] (with_var)? COLON suite { + stype = new With($WITH, (exprType)$test.tree, $with_var.etype, actions.makeStmts($suite.stmts)); + } + ; //with_var: ('as' | NAME) expr -with_var: (AS | NAME) expr[expr_contextType.Load] - ; +with_var returns [exprType etype] + : (AS | NAME) expr[expr_contextType.Load] { + $etype = (exprType)$expr.tree; + } + ; //except_clause: 'except' [test [',' test]] except_clause : EXCEPT (t1=test[expr_contextType.Load] (COMMA t2=test[expr_contextType.Load])?)? COLON suite - //Note: passing the 'except' keyword on so we can pass the same offset - // as CPython. - -> ^(EXCEPT ^(Type $t1)? ^(Value $t2)? ^(Body suite)) + -> ^(EXCEPT<excepthandlerType>[$EXCEPT, (exprType)$t1.tree, (exprType)$t2.tree, actions.makeStmts($suite.stmts), $EXCEPT.getLine(), $EXCEPT.getCharPositionInLine()]) ; //suite: simple_stmt | NEWLINE INDENT stmt+ DEDENT -suite - : simple_stmt - | NEWLINE! INDENT (stmt)+ DEDENT +suite returns [List stmts] + : ss+=simple_stmt {$stmts = $ss;} + | NEWLINE! INDENT (s+=stmt)+ DEDENT {$stmts = $s;} ; //test: or_test ['if' or_test 'else' test] | lambdef test[expr_contextType ctype] +@after { + if ($test.tree instanceof BoolOp) { + BoolOp b = (BoolOp)$test.tree; + List values = new ArrayList(); + + exprType left = (exprType)b.getChild(0); + exprType right = (exprType)b.getChild(1); + + exprType[] e; + if (left.getType() == b.getType() && right.getType() == b.getType()) { + BoolOp leftB = (BoolOp)left; + BoolOp rightB = (BoolOp)right; + int lenL = leftB.values.length; + int lenR = rightB.values.length; + e = new exprType[lenL + lenR]; + System.arraycopy(leftB.values, 0, e, 0, lenL - 1); + System.arraycopy(rightB.values, 0, e, lenL - 1, lenL + lenR); + } else if (left.getType() == b.getType()) { + BoolOp leftB = (BoolOp)left; + e = new exprType[leftB.values.length + 1]; + System.arraycopy(leftB.values, 0, e, 0, leftB.values.length); + e[e.length - 1] = right; + } else if (right.getType() == b.getType()) { + BoolOp rightB = (BoolOp)right; + e = new exprType[rightB.values.length + 1]; + System.arraycopy(rightB.values, 0, e, 0, rightB.values.length); + e[e.length - 1] = left; + } else { + e = new exprType[2]; + e[0] = left; + e[1] = right; + } + b.values = e; + switch (b.getType()) { + case AND: + b.op = boolopType.And; + break; + case OR: + b.op = boolopType.Or; + break; + default: + b.op = boolopType.UNDEFINED; + } + } +} + :o1=or_test[ctype] ( (IF or_test[expr_contextType.Load] ORELSE) => IF o2=or_test[ctype] ORELSE test[expr_contextType.Load] -> ^(IfExp ^(Test $o2) ^(Body $o1) ^(ORELSE test)) @@ -704,36 +831,58 @@ ; //or_test: and_test ('or' and_test)* -or_test[expr_contextType ctype] : and_test[ctype] (OR^ and_test[ctype])* +or_test[expr_contextType ctype] : and_test[ctype] (OR<BoolOp>^ and_test[ctype])* ; //and_test: not_test ('and' not_test)* -and_test[expr_contextType ctype] : not_test[ctype] (AND^ not_test[ctype])* +and_test[expr_contextType ctype] : not_test[ctype] (AND<BoolOp>^ not_test[ctype])* ; //not_test: 'not' not_test | comparison -not_test[expr_contextType ctype] : NOT^ not_test[ctype] - | comparison[ctype] - ; +not_test[expr_contextType ctype] returns [exprType etype] +@after { + if ($etype != null) { + $not_test.tree = $etype; + } +} + : NOT nt=not_test[ctype] {$etype = new UnaryOp($NOT, unaryopType.Not, (exprType)$nt.tree);} + | comparison[ctype] + ; //comparison: expr (comp_op expr)* -comparison[expr_contextType ctype]: expr[ctype] (comp_op^ expr[ctype])* +//comp_op: '<'|'>'|'=='|'>='|'<='|'<>'|'!='|'in'|'not' 'in'|'is'|'is' 'not' +comparison[expr_contextType ctype] +@init { + List cmps = new ArrayList(); +} +@after { + if (!cmps.isEmpty()) { + $comparison.tree = new Compare($left.tree, (exprType)$left.tree, actions.makeCmpOps(cmps), actions.makeExprs($right)); + } +} + : left=expr[ctype] + ( ( comp_op right+=expr[ctype] {cmps.add($comp_op.op);} + )+ + | -> $left + ) ; //comp_op: '<'|'>'|'=='|'>='|'<='|'<>'|'!='|'in'|'not' 'in'|'is'|'is' 'not' -comp_op : LESS - | GREATER - | EQUAL - | GREATEREQUAL - | LESSEQUAL - | ALT_NOTEQUAL - | NOTEQUAL - | IN - | NOT IN -> NotIn - | IS - | IS NOT -> IsNot - ; +comp_op returns [cmpopType op] + : LESS {$op = cmpopType.Lt;} + | GREATER {$op = cmpopType.Gt;} + | EQUAL {$op = cmpopType.Eq;} + | GREATEREQUAL {$op = cmpopType.GtE;} + | LESSEQUAL {$op = cmpopType.LtE;} + | ALT_NOTEQUAL {$op = cmpopType.NotEq;} + | NOTEQUAL {$op = cmpopType.NotEq;} + | IN {$op = cmpopType.In;} + | NOT IN {$op = cmpopType.NotIn;} + | IS {$op = cmpopType.Is;} + | IS NOT {$op = cmpopType.IsNot;} + ; + //expr: xor_expr ('|' xor_expr)* expr[expr_contextType ect] scope { @@ -742,40 +891,122 @@ @init { $expr::ctype = ect; } - - : xor_expr (VBAR^ xor_expr)* +@after { + if ($expr.tree instanceof BinOp) { + BinOp b = (BinOp)$expr.tree; + b.left = (exprType)b.getChild(0); + b.right = (exprType)b.getChild(1); + switch (b.getType()) { + case PLUS: + b.op = operatorType.Add; + break; + case MINUS: + b.op = operatorType.Sub; + break; + case STAR: + b.op = operatorType.Mult; + break; + case SLASH: + b.op = operatorType.Div; + break; + case PERCENT: + b.op = operatorType.Mod; + break; + case DOUBLESLASH: + b.op = operatorType.FloorDiv; + break; + case AMPER: + b.op = operatorType.BitAnd; + break; + case VBAR: + b.op = operatorType.BitOr; + break; + case CIRCUMFLEX: + b.op = operatorType.BitXor; + break; + case LEFTSHIFT: + b.op = operatorType.LShift; + break; + case RIGHTSHIFT: + b.op = operatorType.RShift; + break; + case DOUBLESTAR: + b.op = operatorType.Pow; + break; + } + } +} + : xor_expr (VBAR<BinOp>^ xor_expr)* ; //xor_expr: and_expr ('^' and_expr)* -xor_expr : and_expr (CIRCUMFLEX^ and_expr)* +xor_expr : and_expr (CIRCUMFLEX<BinOp>^ and_expr)* ; //and_expr: shift_expr ('&' shift_expr)* -and_expr : shift_expr (AMPER^ shift_expr)* +and_expr : shift_expr (AMPER<BinOp>^ shift_expr)* ; //shift_expr: arith_expr (('<<'|'>>') arith_expr)* -shift_expr : arith_expr ((LEFTSHIFT^|RIGHTSHIFT^) arith_expr)* +shift_expr : arith_expr ((LEFTSHIFT<BinOp>^|RIGHTSHIFT<BinOp>^) arith_expr)* ; //arith_expr: term (('+'|'-') term)* -arith_expr: term ((PLUS^|MINUS^) term)* + +arith_expr + :term ((PLUS<BinOp>^|MINUS<BinOp>^) term)* ; //term: factor (('*'|'/'|'%'|'//') factor)* -term : factor ((STAR^ | SLASH^ | PERCENT^ | DOUBLESLASH^ ) factor)* +term : factor ((STAR<BinOp>^ | SLASH<BinOp>^ | PERCENT<BinOp>^ | DOUBLESLASH<BinOp>^ ) factor)* ; //factor: ('+'|'-'|'~') factor | power -factor : PLUS factor -> ^(UAdd PLUS factor) - | MINUS factor -> ^(USub MINUS factor) - | TILDE factor -> ^(Invert TILDE factor) - | power - ; +factor returns [exprType etype] +@after { + $factor.tree = $etype; +} + : PLUS p=factor {$etype = new UnaryOp($PLUS, unaryopType.UAdd, $p.etype);} + | MINUS m=factor {$etype = actions.negate($MINUS, $m.etype);} + | TILDE t=factor {$etype = new UnaryOp($TILDE, unaryopType.Invert, $t.etype);} + | power {$etype = (exprType)$power.tree;} + ; //power: atom trailer* ['**' factor] -power : atom (trailer^)* (options {greedy=true;}:DOUBLESTAR^ factor)? - ; +power returns [exprType etype] +@after { + if ($etype != null) { + $power.tree = $etype; + } +} + : atom (t+=trailer)* (options {greedy=true;}:DOUBLESTAR factor)? { + if ($t != null) { + exprType current = (exprType)$atom.tree; + //for(int i = $t.size() - 1; i > -1; i--) { + for(int i = 0; i < $t.size(); i++) { + Object o = $t.get(i); + if (current instanceof Context) { + ((Context)current).setContext(expr_contextType.Load); + } + //XXX: good place for an interface to avoid all of this instanceof + if (o instanceof Call) { + Call c = (Call)o; + c.func = current; + current = c; + } else if (o instanceof Subscript) { + Subscript c = (Subscript)o; + c.value = current; + current = c; + } else if (o instanceof Attribute) { + Attribute c = (Attribute)o; + c.value = current; + current = c; + } + } + $etype = (exprType)current; + } + } + ; //atom: ('(' [yield_expr|testlist_gexp] ')' | // '[' [listmaker] ']' | @@ -783,87 +1014,152 @@ // '`' testlist1 '`' | // NAME | NUMBER | STRING+) atom : LPAREN - ( yield_expr -> ^(Parens LPAREN yield_expr) - | testlist_gexp {debug("parsed testlist_gexp");} -> ^(Parens LPAREN testlist_gexp) - | -> ^(Tuple) + ( yield_expr -> yield_expr + | testlist_gexp -> testlist_gexp + | -> ^(PYNODE<Tuple>[$LPAREN, new exprType[0\], $expr::ctype]) ) RPAREN | LBRACK - (listmaker -> ^(Brackets LBRACK listmaker) - | -> ^(Brackets LBRACK ^(List)) + (listmaker -> listmaker + | -> ^(LBRACK<org.python.antlr.ast.List>[$LBRACK, new exprType[0\], $expr::ctype]) ) RBRACK | LCURLY (dictmaker)? RCURLY -> ^(Dict LCURLY ^(Elts dictmaker)?) | BACKQUOTE testlist[expr_contextType.Load] BACKQUOTE -> ^(Repr BACKQUOTE testlist) - | NAME -> ^(NameTok NAME) - | INT -> ^(NumTok<Num>[$INT, actions.makeInt($INT)]) - | LONGINT -> ^(NumTok<Num>[$LONGINT, actions.makeInt($LONGINT)]) - | FLOAT -> ^(NumTok<Num>[$FLOAT, actions.makeFloat($FLOAT)]) - | COMPLEX -> ^(NumTok<Num>[$COMPLEX, actions.makeComplex($COMPLEX)]) + | NAME -> ^(PYNODE<Name>[$NAME, $NAME.text, $expr::ctype]) + | INT -> ^(PYNODE<Num>[$INT, actions.makeInt($INT)]) + | LONGINT -> ^(PYNODE<Num>[$LONGINT, actions.makeInt($LONGINT)]) + | FLOAT -> ^(PYNODE<Num>[$FLOAT, actions.makeFloat($FLOAT)]) + | COMPLEX -> ^(PYNODE<Num>[$COMPLEX, actions.makeComplex($COMPLEX)]) | (S+=STRING)+ - -> ^(StrTok<Str>[actions.extractStringToken($S), actions.extractStrings($S)]) + -> ^(PYNODE<Str>[actions.extractStringToken($S), actions.extractStrings($S)]) ; //listmaker: test ( list_for | (',' test)* [','] ) -listmaker : test[expr_contextType.Load] +listmaker returns [exprType etype] +@after { + $listmaker.tree = $etype; +} + : t+=test[expr_contextType.Load] ( list_for -> ^(ListComp test list_for) - | (options {greedy=true;}:COMMA test[expr_contextType.Load])* -> ^(List ^(Elts test+)) + | (options {greedy=true;}:COMMA t+=test[expr_contextType.Load])* { + $etype = new org.python.antlr.ast.List($listmaker.start, actions.makeExprs($t), $expr::ctype); + } ) (COMMA)? ; //testlist_gexp: test ( gen_for | (',' test)* [','] ) testlist_gexp - : test[expr_contextType.Load] ( ((options {k=2;}: c1=COMMA test[expr_contextType.Load])* (c2=COMMA)? -> { $c1 != null || $c2 != null }? ^(Tuple ^(Elts test+)) - -> test - ) - | ( gen_for -> ^(GeneratorExp test gen_for)) - ) + : t+=test[expr_contextType.Load] + ( ((options {k=2;}: c1=COMMA t+=test[expr_contextType.Load])* (c2=COMMA)? + -> { $c1 != null || $c2 != null }? ^(PYNODE<Tuple>[$testlist_gexp.start, actions.makeExprs($t), $expr::ctype]) + -> test + ) + | ( gen_for -> ^(GeneratorExp test gen_for) + ) + ) ; //lambdef: 'lambda' [varargslist] ':' test lambdef: LAMBDA (varargslist)? COLON test[expr_contextType.Load] {debug("parsed lambda");} - -> ^(LAMBDA varargslist? ^(Body test)) + -> ^(LAMBDA<Lambda>[$LAMBDA, $varargslist.args, (exprType)$test.tree]) ; //trailer: '(' [arglist] ')' | '[' subscriptlist ']' | '.' NAME -trailer : LPAREN (arglist)? RPAREN -> ^(Call ^(Args arglist)?) - | LBRACK subscriptlist RBRACK -> ^(SubscriptList subscriptlist) - | DOT^ attr {debug("motched DOT^ NAME");} +trailer : LPAREN (arglist -> ^(LPAREN<Call>[$LPAREN, null, actions.makeExprs($arglist.args), actions.makeKeywords($arglist.keywords), $arglist.starargs, $arglist.kwargs]) + | -> ^(LPAREN<Call>[$LPAREN, null, new exprType[0\], new keywordType[0\], null, null]) + ) + RPAREN + | LBRACK s=subscriptlist RBRACK -> $s + | DOT attr -> ^(DOT<Attribute>[$DOT, null, $attr.text, $expr::ctype]) ; //subscriptlist: subscript (',' subscript)* [','] -subscriptlist : subscript (options {greedy=true;}:c1=COMMA subscript)* (c2=COMMA)? - -> { $c1 != null || $c2 != null }? ^(Tuple ^(Elts subscript+)) - -> subscript - ; +//FIXME: tuples not always created when commas are present. +subscriptlist returns [exprType etype] +@after { + $subscriptlist.tree = $etype; +} + : sub+=subscript (options {greedy=true;}:COMMA sub+=subscript)* (COMMA)? { + sliceType s; + List sltypes = $sub; + if (sltypes.size() == 0) { + s = null; + } else if (sltypes.size() == 1){ + s = (sliceType)sltypes.get(0); + } else { + sliceType[] st; + //FIXME: here I am using ClassCastException to decide if sltypes is populated with Index + // only. Clearly this is not the best way to do this but it's late. Somebody do + // something better please :) -- (hopefully a note to self) + try { + Iterator iter = sltypes.iterator(); + List etypes = new ArrayList(); + while (iter.hasNext()) { + Index i = (Index)iter.next(); + etypes.add(i.value); + } + exprType[] es = (exprType[])etypes.toArray(new exprType[etypes.size()]); + exprType t = new Tuple($subscriptlist.start, es, expr_contextType.Load); + s = new Index($subscriptlist.start, t); + } catch (ClassCastException cc) { + st = (sliceType[])sltypes.toArray(new sliceType[sltypes.size()]); + s = new ExtSlice($subscriptlist.start, st); + } + } + $etype = new Subscript($subscriptlist.start, null, s, $expr::ctype); + } + ; //subscript: '.' '.' '.' | test | [test] ':' [test] [sliceop] -subscript : DOT DOT DOT -> Ellipsis - | (test[expr_contextType.Load] COLON) => t1=test[expr_contextType.Load] (COLON (t2=test[expr_contextType.Load])? (sliceop)?)? -> ^(Subscript ^(Lower $t1) ^(Upper COLON ^(UpperOp $t2)?)? sliceop?) - | (COLON) => COLON (test[expr_contextType.Load])? (sliceop)? -> ^(Subscript ^(Upper COLON ^(UpperOp test)?)? sliceop?) - | test[expr_contextType.Load] -> ^(Index test) - ; +subscript returns [sliceType sltype] +@after { + if ($sltype != null) { + $subscript.tree = $sltype; + } +} + : DOT DOT DOT -> Ellipsis + | (test[expr_contextType.Load] COLON) => lower=test[expr_contextType.Load] (c1=COLON (upper1=test[expr_contextType.Load])? (sliceop)?)? { + $sltype = actions.makeSubscript($lower.tree, $c1, $upper1.tree, $sliceop.tree); + } + | (COLON) => c2=COLON (upper2=test[expr_contextType.Load])? (sliceop)? { + $sltype = actions.makeSubscript(null, $c2, $upper2.tree, $sliceop.tree); + } + | test[expr_contextType.Load] -> ^(PYNODE<Index>[$test.start, (exprType)$test.tree]) + ; //sliceop: ':' [test] -sliceop : COLON (test[expr_contextType.Load])? -> ^(Step COLON ^(StepOp test)?) +sliceop : COLON (test[expr_contextType.Load])? -> test ; //exprlist: expr (',' expr)* [','] -exprlist[expr_contextType ctype]: (expr[expr_contextType.Load] COMMA) => expr[ctype] (options {k=2;}: COMMA expr[ctype])* (COMMA)? -> ^(Tuple ^(Elts expr+)) - | expr[ctype] - ; +exprlist[expr_contextType ctype] returns [exprType etype] + : (expr[expr_contextType.Load] COMMA) => e+=expr[ctype] (options {k=2;}: COMMA e+=expr[ctype])* (COMMA)? { + $etype = new Tuple($exprlist.start, actions.makeExprs($e), ctype); + } + | expr[ctype] { + $etype = (exprType)$expr.tree; + } + ; //XXX: I'm hoping I can get rid of this -- but for now I need an exprlist that does not produce tuples // at least for del_stmt -exprlist2 : expr[expr_contextType.Load] (options {k=2;}: COMMA expr[expr_contextType.Load])* (COMMA)? - -> expr+ - ; +exprlist2 returns [List etypes] + : e+=expr[expr_contextType.Load] (options {k=2;}: COMMA e+=expr[expr_contextType.Load])* (COMMA)? + {$etypes = $e;} + ; //testlist: test (',' test)* [','] -testlist[expr_contextType ctype] - : test[ctype] (options {k=2;}: c1=COMMA test[ctype])* (c2=COMMA)? - -> { $c1 != null || $c2 != null }? ^(Tuple ^(Elts test+)) - -> test +testlist[expr_contextType ctype] returns [exprType etype] +@after { + $testlist.tree = $etype; +} + : (test[expr_contextType.Load] COMMA) => t+=test[ctype] (options {k=2;}: c1=COMMA t+=test[ctype])* (c2=COMMA)? { + $etype = new Tuple($testlist.start, actions.makeExprs($t), ctype); + } + | test[ctype] { + $etype = (exprType)$test.tree; + } ; //XXX: @@ -876,46 +1172,54 @@ ; //classdef: 'class' NAME ['(' [testlist] ')'] ':' suite -classdef: CLASS NAME (LPAREN testlist[expr_contextType.Load]? RPAREN)? COLON suite - -> ^(CLASS NAME ^(Bases testlist)? ^(Body suite)) +classdef +@init { + stmtType stype = null; +} +@after { + $classdef.tree = stype; +} + :CLASS NAME (LPAREN testlist[expr_contextType.Load]? RPAREN)? COLON suite { + stype = new ClassDef($CLASS, $NAME.getText(), actions.makeBases($testlist.etype), actions.makeStmts($suite.stmts)); + } ; //arglist: (argument ',')* (argument [',']| '*' test [',' '**' test] | '**' test) -arglist : a1=argument[true] (COMMA a2+=argument[false])* - ( COMMA - ( STAR starargs=test[expr_contextType.Load] (COMMA DOUBLESTAR kwargs=test[expr_contextType.Load])? - | DOUBLESTAR kwargs=test[expr_contextType.Load] - )? - )? { if ($a2 != null) { - if ($a1.tree.getType() == GenFor) { - actions.errorGenExpNotSoleArg($a1.tree); - } - for (int i=0;i<$a2.size();i++) { - if (((PythonTree)$a2.get(i)).getType() == GenFor) { - actions.errorGenExpNotSoleArg(((argument_return)$a2.get(i)).tree); - } - } - } - } - -> ^(Args argument+) ^(StarArgs $starargs)? ^(KWArgs $kwargs)? - | STAR starargs=test[expr_contextType.Load] (COMMA DOUBLESTAR kwargs=test[expr_contextType.Load])? - -> ^(StarArgs $starargs) ^(KWArgs $kwargs)? - | DOUBLESTAR kwargs=test[expr_contextType.Load] - -> ^(KWArgs $kwargs) +arglist returns [List args, List keywords, exprType starargs, exprType kwargs] +@init { + List arguments = new ArrayList(); + List kws = new ArrayList(); +} + : argument[arguments, kws] (COMMA argument[arguments, kws])* + ( COMMA + ( STAR s=test[expr_contextType.Load] (COMMA DOUBLESTAR k=test[expr_contextType.Load])? + | DOUBLESTAR k=test[expr_contextType.Load] + )? + )? { + $args=arguments; + $keywords=kws; + $starargs=(exprType)$s.tree; + $kwargs=(exprType)$k.tree; + } + | STAR s=test[expr_contextType.Load] (COMMA DOUBLESTAR k=test[expr_contextType.Load])? { + $starargs=(exprType)$s.tree; + $kwargs=(exprType)$k.tree; + } + | DOUBLESTAR k=test[expr_contextType.Load] { + $kwargs=(exprType)$k.tree; + } ; //argument: test [gen_for] | test '=' test # Really [keyword '='] test -argument[boolean first] +argument[List arguments, List kws] : t1=test[expr_contextType.Load] - ( (ASSIGN t2=test[expr_contextType.Load]) -> ^(Keyword ^(Arg $t1) ^(Value $t2)?) - | gen_for { if (!first) { - actions.errorGenExpNotSoleArg($gen_for.tree); - } - } - -> ^(GenFor $t1 gen_for) - | -> ^(Arg $t1) - ) - ; + ( (ASSIGN t2=test[expr_contextType.Load]) { + $kws.add(new exprType[]{(exprType)$t1.tree, (exprType)$t2.tree}); + } + | gen_for //FIXME + | {$arguments.add($t1.tree);} + ) + ; //list_iter: list_for | list_if list_iter : list_for @@ -924,7 +1228,7 @@ //list_for: 'for' exprlist 'in' testlist_safe [list_iter] list_for : FOR exprlist[expr_contextType.Load] IN testlist[expr_contextType.Load] (list_iter)? - -> ^(ListFor ^(Target exprlist) ^(IN testlist) ^(Ifs list_iter)?) + -> ^(FOR<comprehensionType>[$FOR, $exprlist.etype, $testlist.etype, null]) ; //list_if: 'if' test [list_iter] @@ -949,7 +1253,7 @@ //yield_expr: 'yield' [testlist] yield_expr : YIELD testlist[expr_contextType.Load]? - -> ^(YIELD ^(Value testlist)?) + -> ^(YIELD<Yield>[$YIELD, $testlist.etype]) ; //XXX: Deleted: branches/nowalker/grammar/PythonWalker.g =================================================================== --- branches/nowalker/grammar/PythonWalker.g 2008-08-19 21:17:36 UTC (rev 5209) +++ branches/nowalker/grammar/PythonWalker.g 2008-08-19 21:43:06 UTC (rev 5210) @@ -1,1286 +0,0 @@ -/* -Copyright (c) 2007-2008 Frank Wierzbicki -Licensed to PSF under a Contributor Agreement. -*/ -tree grammar PythonWalker; - -options { - tokenVocab=Python; - ASTLabelType=PythonTree; -} - -@header { -package org.python.antlr; - -import org.python.core.Py; -import org.python.core.PyObject; -import org.python.core.PyString; -import org.python.antlr.ParseException; -import org.python.antlr.ast.aliasType; -import org.python.antlr.ast.argumentsType; -import org.python.antlr.ast.boolopType; -import org.python.antlr.ast.comprehensionType; -import org.python.antlr.ast.cmpopType; -import org.python.antlr.ast.excepthandlerType; -import org.python.antlr.ast.exprType; -import org.python.antlr.ast.expr_contextType; -import org.python.antlr.ast.keywordType; -import org.python.antlr.ast.modType; -import org.python.antlr.ast.operatorType; -import org.python.antlr.ast.sliceType; -import org.python.antlr.ast.stmtType; -import org.python.antlr.ast.unaryopType; -import org.python.antlr.ast.Assert; -import org.python.antlr.ast.Assign; -import org.python.antlr.ast.Attribute; -import org.python.antlr.ast.AugAssign; -import org.python.antlr.ast.BinOp; -import org.python.antlr.ast.BoolOp; -import org.python.antlr.ast.Break; -import org.python.antlr.ast.Call; -import org.python.antlr.ast.ClassDef; -import org.python.antlr.ast.Compare; -import org.python.antlr.ast.Continue; -import org.python.antlr.ast.Delete; -import org.python.antlr.ast.Dict; -import org.python.antlr.ast.Ellipsis; -import org.python.antlr.ast.ErrorStmt; -import org.python.antlr.ast.Exec; -import org.python.antlr.ast.Expr; -import org.python.antlr.ast.Expression; -import org.python.antlr.ast.ExtSlice; -import org.python.antlr.ast.For; -import org.python.antlr.ast.FunctionDef; -import org.python.antlr.ast.GeneratorExp; -import org.python.antlr.ast.Global; -import org.python.antlr.ast.If; -import org.python.antlr.ast.IfExp; -import org.python.antlr.ast.Index; -import org.python.antlr.ast.Import; -import org.python.antlr.ast.ImportFrom; -import org.python.antlr.ast.Interactive; -import org.python.antlr.ast.Lambda; -import org.python.antlr.ast.ListComp; -import org.python.antlr.ast.Module; -import org.python.antlr.ast.Name; -import org.python.antlr.ast.Num; -import org.python.antlr.ast.Slice; -import org.python.antlr.ast.Subscript; -import org.python.antlr.ast.TryExcept; -import org.python.antlr.ast.TryFinally; -import org.python.antlr.ast.Tuple; -import org.python.antlr.ast.Pass; -import org.python.antlr.ast.Print; -import org.python.antlr.ast.Raise; -import org.python.antlr.ast.Repr; -import org.python.antlr.ast.Return; -import org.python.antlr.ast.Str; -import org.python.antlr.ast.UnaryOp; -import org.python.antlr.ast.With; -import org.python.antlr.ast.While; -import org.python.antlr.ast.Yield; -import java.math.BigInteger; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashMap; -import java.util.Iterator; -import java.util.ListIterator; -import java.util.Map; -import java.util.Set; -} -@members { - boolean debugOn = false; - private ErrorHandler errorHandler; - private GrammarActions actions = new GrammarActions(); - - public void setErrorHandler(ErrorHandler eh) { - this.errorHandler = eh; - actions.setErrorHandler(eh); - } - - public void debug(String message) { - if (debugOn) { - System.out.println(message); - } - } - - protected void mismatch(IntStream input, int ttype, BitSet follow) throws RecognitionException { - throw new MismatchedTokenException(ttype, input); - } - - protected void mismatch(IntStream input, RecognitionException e, BitSet follow) throws RecognitionException { - throw e; - } - - String name = "Test"; - - //XXX: Not sure I need any below... - String filename = "test.py"; - boolean linenumbers = true; - boolean setFile = true; - boolean printResults = false; - //CompilerFlags cflags = Py.getCompilerFlags(); - -} - -@rulecatch { -catch (RecognitionException re) { - errorHandler.reportError(this, re); - errorHandler.recover(this, input,re); -} -} - - -expression returns [modType mod] - : ^(Expression test[expr_contextType.Load]) { $mod = actions.makeExpression($Expression, $test.etype); } - ; - -interactive returns [modType mod] - : ^(Interactive stmts?) { $mod = actions.makeInteractive($Interactive, $stmts.stypes); } - ; - -module returns [modType mod] - : ^(Module - ( stmts {$mod = actions.makeMod($Module, $stmts.stypes); } - | {$mod = actions.makeMod($Module, null);} - ) - ) - ; - -funcdef - : ^(DEF NAME ^(Arguments varargslist?) ^(Body stmts) ^(Decorators decorators?)) { - $stmts::statements.add(actions.makeFunctionDef($DEF, $NAME, $varargslist.args, $stmts.stypes, $decorators.etypes)); - } - ; - -varargslist returns [argumentsType args] -@init { - List params = new ArrayList(); - List defaults = new ArrayList(); -} - : ^(Args defparameter[params, defaults]+) (^(StarArgs sname=NAME))? (^(KWArgs kname=NAME))? { - $args = actions.makeArgumentsType($Args, params, $sname, $kname, defaults); - } - | ^(StarArgs sname=NAME) (^(KWArgs kname=NAME))? { - $args = actions.makeArgumentsType($StarArgs,params, $sname, $kname, defaults); - } - | ^(KWArgs NAME) { - $args = actions.makeArgumentsType($KWArgs, params, null, $NAME, defaults); - } - ; - -defparameter[List params, List defaults] - : fpdef[expr_contextType.Param, null] (ASSIGN test[expr_contextType.Load])? { - params.add($fpdef.etype); - if ($ASSIGN != null) { - defaults.add($test.etype); - } else if (!defaults.isEmpty()) { - throw new ParseException( - "non-default argument follows default argument", - $fpdef.start); - } - } - ; - -fpdef [expr_contextType ctype, List nms] returns [exprType etype] - : NAME { - exprType e = new Name($NAME, $NAME.text, ctype); - actions.checkAssign(e); - if (nms == null) { - $etype = e; - } else { - nms.add(e); - } - } - | ^(FpList fplist) { - exprType[] e = (exprType[])$fplist.etypes.toArray(new exprType[$fplist.etypes.size()]); - Tuple t = new Tuple($fplist.start, e, expr_contextType.Store); - if (nms == null) { - $etype = t; - } else { - nms.add(t); - } - } - ; - -fplist returns [List etypes] -@init { - List nms = new ArrayList(); -} - : fpdef[expr_contextType.Store, nms]+ { - $etypes = nms; - } - ; - -decorators returns [List etypes] -@init { - List decs = new ArrayList(); -} - : decorator[decs]+ { - $etypes = decs; - } - ; - -decorator [List decs] - : ^(AT dotted_attr (^(Call (^(Args arglist))?))?) { - if ($Call == null) { - decs.add($dotted_attr.etype); - } else { - exprType c; - if ($Args == null) { - c = actions.makeCall($Call, $dotted_attr.etype); - } else { - c = actions.makeCall($Call, $dotted_attr.etype, $arglist.args, $arglist.keywords, $arglist.starargs, $arglist.kwargs); - } - c.setCharStopIndex($Call.getCharStopIndex()); - decs.add(c); - } - } - ; - -dotted_attr returns [exprType etype, PythonTree marker] - : attr { - $etype = new Name($attr.start, $attr.text, expr_contextType.Load); - $marker = $attr.start; - debug("matched NAME in dotted_attr");} - | ^(DOT n1=dotted_attr n2=dotted_attr) { - $etype = new Attribute($n1.marker, $n1.etype, $n2.text, expr_contextType.Load); - $marker = $n1.marker; - } - ; - -//attr is here for Java compatibility. A Java foo.getIf() can be called from Jython as foo.if -// so we need to support any keyword as an attribute. -attr - : NAME - | AND - | AS - | ASSERT - | BREAK - | CLASS - | CONTINUE - | DEF - | DELETE - | ELIF - | EXCEPT - | EXEC - | FINALLY - | FROM - | FOR - | GLOBAL - | IF - | IMPORT - | IN - | IS - | LAMBDA - | NOT - | OR - | ORELSE - | PASS - | PRINT - | RAISE - | RETURN - | TRY - | WHILE - | WITH - | YIELD - ; - -stmts returns [List stypes] -scope { - List statements; -} -@init { - $stmts::statements = new ArrayList(); -} - : stmt+ { - debug("Matched stmts"); - $stypes = $stmts::statements; - } - | INDENT stmt+ DEDENT { - debug("Matched stmts"); - $stypes = $stmts::statements; - } - ; - -stmt //combines simple_stmt and compound_stmt from Python.g - : expr_stmt - | print_stmt - | del_stmt - | pass_stmt - | flow_stmt - | import_stmt - | global_stmt - | exec_stmt - | assert_stmt - | if_stmt - | while_stmt - | for_stmt - | try_stmt - | with_stmt - | funcdef - | classdef - ; - -expr_stmt - : test[expr_contextType.Load] { - debug("matched expr_stmt:test " + $test.etype); - $stmts::statements.add(new Expr($test.marker, $test.etype)); - } - | ^(augassign targ=test[expr_contextType.AugStore] value=test[expr_contextType.Load]) { - actions.checkAssign($targ.etype); - AugAssign a = new AugAssign($targ.marker, $targ.etype, $augassign.op, $value.etype); - $stmts::statements.add(a); - } - | ^(Assign targets ^(Value value=test[expr_contextType.Load])) { - debug("Matched Assign"); - exprType[] e = new exprType[$targets.etypes.size()]; - for(int i=0;i<$targets.etypes.size();i++) { - e[i] = (exprType)$targets.etypes.get(i); - } - debug("exprs: " + e.length); - Assign a = new Assign($Assign, e, $value.etype); - $stmts::statements.add(a); - } - ; - -call_expr returns [exprType etype, PythonTree marker] - : ^(Call (^(Args arglist))? test[expr_contextType.Load]) { - exprType c; - if ($Args == null) { - c = actions.makeCall($test.marker, $test.etype); - } else { - c = actions.makeCall($test.marker, $test.etype, $arglist.args, $arglist.keywords, $arglist.starargs, $arglist.kwargs); - } - c.setCharStopIndex($Call.getCharStopIndex()); - $etype = c; - } - ; - -targets returns [List etypes] -@init { - List targs = new ArrayList(); -} - : target[targs]+ { - $etypes = targs; - } - ; - -target[List etypes] - : ^(Target atom[expr_contextType.Store]) { - actions.checkAssign($atom.etype); - etypes.add($atom.etype); - } - ; - -augassign returns [operatorType op] - : PLUSEQUAL {$op = operatorType.Add;} - | MINUSEQUAL {$op = operatorType.Sub;} - | STAREQUAL {$op = operatorType.Mult;} - | SLASHEQUAL {$op = operatorType.Div;} - | PERCENTEQUAL {$op = operatorType.Mod;} - | AMPEREQUAL {$op = operatorType.BitAnd;} - | VBAREQUAL {$op = operatorType.BitOr;} - | CIRCUMFLEXEQUAL {$op = operatorType.BitXor;} - | LEFTSHIFTEQUAL {$op = operatorType.LShift;} - | RIGHTSHIFTEQUAL {$op = operatorType.RShift;} - | DOUBLESTAREQUAL {$op = operatorType.Pow;} - | DOUBLESLASHEQUAL {$op = operatorType.FloorDiv;} - ; - -binop returns [operatorType op] - : PLUS {$op = operatorType.Add;} - | MINUS {$op = operatorType.Sub;} - | STAR {$op = operatorType.Mult;} - | SLASH {$op = operatorType.Div;} - | PERCENT {$op = operatorType.Mod;} - | AMPER {$op = operatorType.BitAnd;} - | VBAR {$op = operato... [truncated message content] |
From: <fwi...@us...> - 2008-08-19 21:17:39
|
Revision: 5209 http://jython.svn.sourceforge.net/jython/?rev=5209&view=rev Author: fwierzbicki Date: 2008-08-19 21:17:36 +0000 (Tue, 19 Aug 2008) Log Message: ----------- Create branch to combine Python.g and PythonWalker.g Added Paths: ----------- branches/nowalker/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2008-08-19 21:14:33
|
Revision: 5208 http://jython.svn.sourceforge.net/jython/?rev=5208&view=rev Author: fwierzbicki Date: 2008-08-19 21:14:32 +0000 (Tue, 19 Aug 2008) Log Message: ----------- branch now closed Removed Paths: ------------- branches/asm/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2008-08-19 21:14:11
|
Revision: 5207 http://jython.svn.sourceforge.net/jython/?rev=5207&view=rev Author: fwierzbicki Date: 2008-08-19 21:14:10 +0000 (Tue, 19 Aug 2008) Log Message: ----------- remove asm branch tracking Property Changed: ---------------- trunk/jython/ Property changes on: trunk/jython ___________________________________________________________________ Deleted: svnmerge-integrated - /branches/asm:1-5205 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2008-08-19 21:07:03
|
Revision: 5206 http://jython.svn.sourceforge.net/jython/?rev=5206&view=rev Author: fwierzbicki Date: 2008-08-19 21:06:39 +0000 (Tue, 19 Aug 2008) Log Message: ----------- Merged revisions 4386,4388-4390,4392,4403,4405,4408,4418,4424-4425,4434,4466,4474,4490,4493,4496,4499-4501,4504,4523-4524,4548-4549,4577-4579,4581-4582,4585-4589,4599-4600,4603-4605,4607-4608,4613,4628,4640,4642-4643,4648,4652-4662,4665,4667,4672,4676,4678-4680,4682,4684,4693-4695,4704-4706,4708-4712,4714-4715,4720,4729,4732-4735,4740-4751,4753-4758,4761-4765,4767-4772,4774,4777-4779,4781-4802,4806-4810,4821-4843,4845-4850,4852-4853,4855-4857,4859,4863-4870,4876-4885,4887-4897,4901-4914,4916-4919,4922,4924-4925,4928,4930,4932-4937,4939-4945,4947,4949-4952,4959,4961,4963,4965,4967-4971,4973-4974,4980,4982-5100,5102-5117,5119-5166,5168-5197 via svnmerge from https://jython.svn.sourceforge.net/svnroot/jython/branches/asm ........ r4386 | fwierzbicki | 2008-05-08 14:55:44 -0400 (Thu, 08 May 2008) | 2 lines Recreate asmified old compiler. ........ r4388 | fwierzbicki | 2008-05-10 13:19:27 -0400 (Sat, 10 May 2008) | 3 lines Hand merged changes in trunk to copiler code. Removed Attribute support -- needs to be replaced by either ASM Attributes or Annotations. ........ r4389 | fwierzbicki | 2008-05-12 13:48:35 -0400 (Mon, 12 May 2008) | 4 lines Reworked Code.java back towards old API (so methods like code.dup() are back so it is not necessary to use code.visitInsn(DUP). This makes it easier to read the code and to compare with the old code base. ........ r4390 | fwierzbicki | 2008-05-12 22:00:02 -0400 (Mon, 12 May 2008) | 2 lines Converted everything over to antlr from javacc. ........ r4392 | fwierzbicki | 2008-05-13 15:38:04 -0400 (Tue, 13 May 2008) | 3 lines Moved more code to older style Code.java methods (still based on ASM). Added Visitor and ParseException. ........ r4403 | fwierzbicki | 2008-05-15 12:39:30 -0400 (Thu, 15 May 2008) | 2 lines Enough compiler and parser tweaking to keep site.py from exploding. ........ r4405 | fwierzbicki | 2008-05-15 15:18:26 -0400 (Thu, 15 May 2008) | 2 lines Fix for "from mod import *" and start of setline support. ........ r4408 | fwierzbicki | 2008-05-15 19:29:22 -0400 (Thu, 15 May 2008) | 2 lines Temporary fix for line number problems causing NPEs. ........ r4418 | fwierzbicki | 2008-05-17 12:20:34 -0400 (Sat, 17 May 2008) | 2 lines Remove old parser. ........ r4424 | fwierzbicki | 2008-05-20 13:39:32 -0400 (Tue, 20 May 2008) | 4 lines Added a shell script to run Jython. This was adapted from a script from the JRuby project. I also included the same suport for The Java Interactive Profiler (JIP) that JRuby includes. See http://jiprof.sourceforge.net/ ........ r4425 | fwierzbicki | 2008-05-20 13:50:01 -0400 (Tue, 20 May 2008) | 2 lines Alter profile.properties for Jython. ........ r4434 | pjenvey | 2008-05-20 17:11:36 -0400 (Tue, 20 May 2008) | 1 line missed one part of the PyMethod constructor signature change in r4400, from trunk ........ r4466 | fwierzbicki | 2008-05-27 22:05:18 -0400 (Tue, 27 May 2008) | 12 lines Now that things are close to working, time to completely destroy things again. Switched to pulling in 2.5 Python libraries. Took first baby step by attempting to support def f(): yield which is not valid 2.3 syntax. (This is actually what motivated this -- I was about to "fix" the grammar to disallow this when I accidentally noticed that it was valid 2.5 syntax. ........ r4474 | fwierzbicki | 2008-05-29 15:34:22 -0400 (Thu, 29 May 2008) | 2 lines First stab at decorator support. ........ r4490 | fwierzbicki | 2008-05-30 11:19:42 -0400 (Fri, 30 May 2008) | 15 lines Begin experimenting with a partial parser -- that is a recognizer that will be able to tell if a string of code from an interactive session is a true syntax error, or if it is part of a potentially valid string of code. For example, in the interactive session: >>> s = """ ... hello Is the start of a valid string, and should be recognized as a valid partial parse. On the other hand >>> print , Is still a syntax error. ........ r4493 | nriley | 2008-06-01 15:50:00 -0400 (Sun, 01 Jun 2008) | 1 line add ImportWarning; update exceptions class doc to 2.5 ........ r4496 | fwierzbicki | 2008-06-01 20:11:03 -0400 (Sun, 01 Jun 2008) | 2 lines Need to see exception print outs. ........ r4499 | fwierzbicki | 2008-06-01 21:03:08 -0400 (Sun, 01 Jun 2008) | 2 lines Switched to 2.4 CPython lib. ........ r4500 | nriley | 2008-06-01 21:59:37 -0400 (Sun, 01 Jun 2008) | 1 line startswith/endswith on str/unicode, passes test_str from 2.5 ........ r4501 | nriley | 2008-06-01 22:34:18 -0400 (Sun, 01 Jun 2008) | 1 line TypeError rather than NotImplemented for wrong type on str.__mul__, fixes test_mul ........ r4504 | nriley | 2008-06-01 23:55:14 -0400 (Sun, 01 Jun 2008) | 1 line r4500 broke http://pylonshq.com/pasties/827, reverting ........ r4523 | fwierzbicki | 2008-06-03 02:39:41 -0400 (Tue, 03 Jun 2008) | 6 lines Most of this change is generated -- the real code changes are in Python.g, PythonWalker.g, and asdl_antlr.py. Moving to antlr 3.1 style of AST production. Changed the Num processing only so far. ........ r4524 | fwierzbicki | 2008-06-03 10:47:46 -0400 (Tue, 03 Jun 2008) | 6 lines Moved Str processing from PythonWalker.g to Python.g. Made Unicode and Str hold PyUnicode and PyString objects instead of java.lang.String objects. This will help compatibility with CPython AST -- though *may* hurt performance more investigation will be needed. Certainly the way CodeCompiler is working will need adjustment if this strategy is the way to go. ........ r4548 | nriley | 2008-06-06 16:48:42 -0400 (Fri, 06 Jun 2008) | 1 line sync sre opcodes with Python 2.4; implement SRE_OP_GROUPREF_EXISTS ........ r4549 | nriley | 2008-06-06 17:12:40 -0400 (Fri, 06 Jun 2008) | 1 line fix comment typo ........ r4577 | nriley | 2008-06-08 22:14:13 -0400 (Sun, 08 Jun 2008) | 1 line Jython-specific test_cmd_line ........ r4578 | fwierzbicki | 2008-06-08 22:34:43 -0400 (Sun, 08 Jun 2008) | 2 lines Generator Expressions. ........ r4579 | nriley | 2008-06-08 22:39:10 -0400 (Sun, 08 Jun 2008) | 1 line fix regrtest ant target dependencies so it works from clean ........ r4581 | fwierzbicki | 2008-06-08 22:58:09 -0400 (Sun, 08 Jun 2008) | 3 lines Better name for comprehension local var (comp instead of lc -- originally stolen from the list comprehension code). ........ r4582 | nriley | 2008-06-08 23:09:46 -0400 (Sun, 08 Jun 2008) | 1 line cookielib works now ........ r4585 | fwierzbicki | 2008-06-09 09:06:46 -0400 (Mon, 09 Jun 2008) | 2 lines Conditional Expression ........ r4586 | fwierzbicki | 2008-06-09 10:10:41 -0400 (Mon, 09 Jun 2008) | 3 lines switch to _(1_1) style names for the temporaries of gen expressions, so that vars with unlikely but possible names like __gen1_1 do not get clobbered. ........ r4587 | nriley | 2008-06-09 17:19:49 -0400 (Mon, 09 Jun 2008) | 1 line provenance of test_cmd_line ........ r4588 | fwierzbicki | 2008-06-09 22:29:18 -0400 (Mon, 09 Jun 2008) | 2 lines Remove unnecessary vars. ........ r4589 | fwierzbicki | 2008-06-10 07:40:31 -0400 (Tue, 10 Jun 2008) | 2 lines Remove comment that I no longer believe :) ........ r4599 | fwierzbicki | 2008-06-11 17:26:33 -0400 (Wed, 11 Jun 2008) | 6 lines Make ParseException the only exception that comes out of the antlr parsing. Unfortunately I haven't figured out how to remove "throws RecognitionException" from the generated code, so some references remain. Also renamed PythonGrammer -> ModuleParser, and some other related refactorings. ........ r4600 | fwierzbicki | 2008-06-11 17:40:36 -0400 (Wed, 11 Jun 2008) | 2 lines More descriptive name antlr.java -> ParserFacade.java ........ r4603 | fwierzbicki | 2008-06-11 21:34:06 -0400 (Wed, 11 Jun 2008) | 4 lines Added a null guard for lexing errors (they have no token) and added an experimental getOffset() method on ParseException which intends to get the char position from the start of the file where the error occured. ........ r4604 | fwierzbicki | 2008-06-11 21:38:05 -0400 (Wed, 11 Jun 2008) | 2 lines Crap, left in debugging. Removed. ........ r4605 | fwierzbicki | 2008-06-11 22:14:26 -0400 (Wed, 11 Jun 2008) | 2 lines Fix offset for lexer errors. ........ r4607 | fwierzbicki | 2008-06-12 11:27:35 -0400 (Thu, 12 Jun 2008) | 2 lines oops, wrong directory position. ........ r4608 | fwierzbicki | 2008-06-12 17:08:38 -0400 (Thu, 12 Jun 2008) | 5 lines pep 263. There is some roughness remaining, especially a strange problem around utf-8 that I need to look into (I ended up letting Jython go with its default in the case of a utf-8 encoding specified for now). ........ r4613 | fwierzbicki | 2008-06-13 13:33:31 -0400 (Fri, 13 Jun 2008) | 4 lines Add a token source for partial parsing (for now -- can probably become a subclass of PythonTokenSource once the kinks are out). Unterminated triple strings now pass. ........ r4628 | zyasoft | 2008-06-14 19:23:52 -0400 (Sat, 14 Jun 2008) | 1 line Added visitWith to support the with-statement. Changed ClassFile so that it does frame analysis with COMPUTE_FRAMES (used by Java 6, seems OK with Java 5 - and prevents code from being compiled that would fail bytecode verifier. Generally that would be a good thing. Fixed threading.Lock.__enter__ so it returns the lock object, not just do an acquire. ........ r4640 | zyasoft | 2008-06-15 01:13:59 -0400 (Sun, 15 Jun 2008) | 1 line Changed Code.ldc such that for large string constants (>32767 char), it splits into chunked ldcsand assembles with a StringBuilder ........ r4642 | nriley | 2008-06-15 17:45:22 -0400 (Sun, 15 Jun 2008) | 1 line jna-posix from http://svn.codehaus.org/jruby-contrib/trunk/jna-posix r179 ........ r4643 | nriley | 2008-06-15 18:04:11 -0400 (Sun, 15 Jun 2008) | 1 line os.stat, chmod, getegid, geteuid, getgid, getlogin, getpgrp, getpid, getppid, getuid, setpgrp, setsid via jna-posix ........ r4648 | nriley | 2008-06-16 01:23:39 -0400 (Mon, 16 Jun 2008) | 1 line enable test_posix ........ r4652 | fwierzbicki | 2008-06-16 15:23:38 -0400 (Mon, 16 Jun 2008) | 3 lines Extrated PythonTreeAdaptor from the *Parser classes, some work to improve offsets. ........ r4653 | zyasoft | 2008-06-16 15:51:12 -0400 (Mon, 16 Jun 2008) | 1 line Now supports coroutines. At this point, I have only done limited testing, especially with respect to exceptions. ........ r4654 | fwierzbicki | 2008-06-16 16:35:50 -0400 (Mon, 16 Jun 2008) | 2 lines More offset work for IDE support. ........ r4655 | zyasoft | 2008-06-16 18:54:40 -0400 (Mon, 16 Jun 2008) | 1 line Reordered public members of PyGenerator so that dir will have the same order as CPython ........ r4656 | fwierzbicki | 2008-06-16 19:11:25 -0400 (Mon, 16 Jun 2008) | 2 lines Move some imaginary tokens to concrete tokens. ........ r4657 | zyasoft | 2008-06-16 20:21:52 -0400 (Mon, 16 Jun 2008) | 1 line Added support of __future__.with_statement; this includes aligning PyTableCode with __future__.py as of 2.5. Does not yet support interactive future import of the with_statement, however ........ r4658 | fwierzbicki | 2008-06-16 20:26:20 -0400 (Mon, 16 Jun 2008) | 3 lines pass statement turned to concrete token. Also preparing to absorb more of PythonWalker.g into Python.g. ........ r4659 | pjenvey | 2008-06-16 20:42:38 -0400 (Mon, 16 Jun 2008) | 1 line we want the absolute path here ........ r4660 | fwierzbicki | 2008-06-16 22:34:20 -0400 (Mon, 16 Jun 2008) | 3 lines parameter passing that I am not using yet. Will be crucial for a one pass parse. ........ r4661 | fwierzbicki | 2008-06-16 22:47:21 -0400 (Mon, 16 Jun 2008) | 2 lines break and continue only newed in Python.g ........ r4662 | fwierzbicki | 2008-06-17 11:12:43 -0400 (Tue, 17 Jun 2008) | 2 lines Slowly adding more needed params to Python.g from PythonWalker.g. ........ r4665 | fwierzbicki | 2008-06-18 10:59:31 -0400 (Wed, 18 Jun 2008) | 3 lines Introduce an ENDMARK imaginary token to handle unfinished but partially valid statements. ........ r4667 | fwierzbicki | 2008-06-18 16:21:10 -0400 (Wed, 18 Jun 2008) | 2 lines Incremental improvement on interactive mode. ........ r4672 | fwierzbicki | 2008-06-18 21:26:41 -0400 (Wed, 18 Jun 2008) | 3 lines Fix PythonPartialTester. Added some info to toStringTree output of PythonTree. ........ r4676 | fwierzbicki | 2008-06-19 11:30:05 -0400 (Thu, 19 Jun 2008) | 3 lines Added an ImaginaryToken type so that the char positions of INDENT and DEDENT can be easily tracked. ........ r4678 | fwierzbicki | 2008-06-19 13:58:08 -0400 (Thu, 19 Jun 2008) | 2 lines Replace many imaginary tokens with concrete tokens. ........ r4679 | fwierzbicki | 2008-06-19 18:31:55 -0400 (Thu, 19 Jun 2008) | 2 lines whitespace ........ r4680 | fwierzbicki | 2008-06-19 19:50:49 -0400 (Thu, 19 Jun 2008) | 2 lines Update comments and rule positions compared to CPython's Grammar/Grammar ........ r4682 | pjenvey | 2008-06-19 20:07:46 -0400 (Thu, 19 Jun 2008) | 1 line fix whitespace ........ r4684 | pjenvey | 2008-06-19 20:50:11 -0400 (Thu, 19 Jun 2008) | 4 lines compile inplace operations to a PyObject._ixx wrapper (which uses _binop_rule, like _xxx), instead of __ixx__ for #1873148 ........ r4693 | pjenvey | 2008-06-20 01:45:14 -0400 (Fri, 20 Jun 2008) | 5 lines o fix builtin inplace methods to work as MethodType.BINARY o add missing inplace functions to operator module o fix CPython specific usage of __iadd__ in lists_tests to operator.__iadd__ for #1873148 ........ r4694 | pjenvey | 2008-06-20 02:01:14 -0400 (Fri, 20 Jun 2008) | 3 lines make deriveds inplace ops work like binary ops for #1873148 ........ r4695 | zyasoft | 2008-06-20 02:21:29 -0400 (Fri, 20 Jun 2008) | 1 line Updated most builtins to 2.5; intern, object do not yet conform. Float conversion is richer in Java than it is in Python for hex (Java supports floating point hex values, test_float). Derived longs are failing (test_longconversion). cmp might be fixed by Leo Soto. Remaining issues are probably due to partial parse problems. Added contextlib, functools. The latter uses a pure-Python implementation, so it does not look like a native type for some of the tests in test_functools; TBD. ........ r4704 | fwierzbicki | 2008-06-20 13:32:49 -0400 (Fri, 20 Jun 2008) | 3 lines Cleared up some bad behavior in Python.g (was reporting and recovering from missing tokens). ........ r4705 | fwierzbicki | 2008-06-20 13:35:59 -0400 (Fri, 20 Jun 2008) | 2 lines Switch debugging off. ........ r4706 | fwierzbicki | 2008-06-20 14:33:18 -0400 (Fri, 20 Jun 2008) | 2 lines Repaired partial strings. Partial lists, dicts, etc *sometimes* work. ........ r4708 | fwierzbicki | 2008-06-20 15:58:27 -0400 (Fri, 20 Jun 2008) | 2 lines Pretty good nested [,(,{ support for interactive mode. ........ r4709 | zyasoft | 2008-06-20 21:16:24 -0400 (Fri, 20 Jun 2008) | 1 line Added wsgiref from 2.5 ........ r4710 | fwierzbicki | 2008-06-21 08:20:13 -0400 (Sat, 21 Jun 2008) | 2 lines whitespace. ........ r4711 | fwierzbicki | 2008-06-21 08:39:06 -0400 (Sat, 21 Jun 2008) | 2 lines Now simple tests of the interactive mode are working well. ........ r4712 | pjenvey | 2008-06-21 19:42:05 -0400 (Sat, 21 Jun 2008) | 1 line always re-generate .class until APIVersion is fixed ........ r4714 | nriley | 2008-06-22 22:38:45 -0400 (Sun, 22 Jun 2008) | 1 line os.isatty, file.isatty support ........ r4715 | fwierzbicki | 2008-06-23 11:57:31 -0400 (Mon, 23 Jun 2008) | 2 lines Fix for one line compound statements in interactive mode. ........ r4720 | fwierzbicki | 2008-06-23 15:28:04 -0400 (Mon, 23 Jun 2008) | 2 lines return None for getfilesystemencoding for now. ........ r4729 | pjenvey | 2008-06-23 18:06:02 -0400 (Mon, 23 Jun 2008) | 7 lines merge trunk/jython@4725:branches/pep352@4725 to branches/asm branches/pep352 failures: test_coercion test_deque test_doctest test_exceptions test_extcall test_generators test_pickletools new asm failures: test_coercion test_deque test_pickletools test_wsgiref ........ r4732 | fwierzbicki | 2008-06-23 19:41:21 -0400 (Mon, 23 Jun 2008) | 2 lines moving to 2.5 Lib. Also small fix for encoding check. ........ r4733 | pjenvey | 2008-06-23 20:31:42 -0400 (Mon, 23 Jun 2008) | 3 lines from: http://svn.python.org/projects/python/branches/release25-maint/Lib/test/test_exceptions.py@52486 ........ r4734 | pjenvey | 2008-06-23 20:45:53 -0400 (Mon, 23 Jun 2008) | 3 lines o 2.5 EnvironmentError needs a custom __reduce__ o disable failing testInfiniteRecursion ........ r4735 | fwierzbicki | 2008-06-23 21:14:18 -0400 (Mon, 23 Jun 2008) | 2 lines better order for suite subrule. ........ r4740 | pjenvey | 2008-06-23 22:07:21 -0400 (Mon, 23 Jun 2008) | 3 lines from: http://svn.python.org/projects/python/branches/release25-maint/Lib/test/test_support.py@60337 ........ r4741 | fwierzbicki | 2008-06-23 22:10:11 -0400 (Mon, 23 Jun 2008) | 4 lines Realized that CPython forces an extra newline for *all* compound statments (including statments like "class Foo:pass"). Greatly simplified the grammar. ........ r4742 | pjenvey | 2008-06-23 22:14:19 -0400 (Mon, 23 Jun 2008) | 1 line merge Jython specific changes back into 2.5 test_support ........ r4743 | fwierzbicki | 2008-06-23 22:36:57 -0400 (Mon, 23 Jun 2008) | 2 lines Fix exploding newlines on interactive prompt. ........ r4744 | pjenvey | 2008-06-23 22:43:05 -0400 (Mon, 23 Jun 2008) | 1 line re-enable setdict, fixed by pep352 ........ r4745 | pjenvey | 2008-06-24 03:01:10 -0400 (Tue, 24 Jun 2008) | 3 lines from: http://svn.python.org/projects/python/branches/release25-maint/Lib/test/test_optparse.py@50791 ........ r4746 | pjenvey | 2008-06-24 03:03:33 -0400 (Tue, 24 Jun 2008) | 1 line allow imports outside of test ........ r4747 | pjenvey | 2008-06-24 03:04:43 -0400 (Tue, 24 Jun 2008) | 1 line don't assume __builtins__ and skip a CPython specific test ........ r4748 | fwierzbicki | 2008-06-24 09:59:06 -0400 (Tue, 24 Jun 2008) | 2 lines Finally - the threshold for a version change has been hit. Yay! ........ r4749 | zyasoft | 2008-06-24 11:45:48 -0400 (Tue, 24 Jun 2008) | 1 line Use CPythonLib's re.py, not our own ........ r4750 | fwierzbicki | 2008-06-24 12:46:35 -0400 (Tue, 24 Jun 2008) | 2 lines Support longs regardless of radix. ........ r4751 | fwierzbicki | 2008-06-24 13:10:39 -0400 (Tue, 24 Jun 2008) | 3 lines move the Jython specific test_array out of the way so we can test against the CPython test_array ........ r4753 | pjenvey | 2008-06-24 17:31:29 -0400 (Tue, 24 Jun 2008) | 1 line disable test_asynchat for now, re #1064 ........ r4754 | pjenvey | 2008-06-24 17:31:42 -0400 (Tue, 24 Jun 2008) | 1 line small cleanup ........ r4755 | pjenvey | 2008-06-24 19:12:17 -0400 (Tue, 24 Jun 2008) | 3 lines from: http://svn.python.org/projects/python/branches/release25-maint/Lib/test/test_logging.py@54275 ........ r4756 | pjenvey | 2008-06-24 19:13:31 -0400 (Tue, 24 Jun 2008) | 1 line re-integrate r4098:4167 ........ r4757 | pjenvey | 2008-06-24 19:57:42 -0400 (Tue, 24 Jun 2008) | 2 lines from: http://svn.python.org/projects/python/branches/release25-maint/Lib/doctest.py@59174 ........ r4758 | pjenvey | 2008-06-24 20:11:28 -0400 (Tue, 24 Jun 2008) | 5 lines o bring in decimal (test_decimal passes). also hashlib and platform which don't quite work yet o Jython changes for doctest, though test_doctest still fails. bring in trace for test_doctest ........ r4761 | fwierzbicki | 2008-06-25 13:22:09 -0400 (Wed, 25 Jun 2008) | 3 lines removed special handling of RecognitionException, since errors are always of type ParseException now anyway. ........ r4762 | fwierzbicki | 2008-06-25 13:51:08 -0400 (Wed, 25 Jun 2008) | 3 lines Created a flag so that external tools can use Python.g with Antlr's default error handling. ........ r4763 | fwierzbicki | 2008-06-25 14:10:21 -0400 (Wed, 25 Jun 2008) | 4 lines antlrErrorHandling needs to be public to be used by external tools. Looking at the nice error messages that are coming out makes me wonder if I might want to rethink my error handling mechanism. ........ r4764 | pjenvey | 2008-06-25 15:03:08 -0400 (Wed, 25 Jun 2008) | 1 line reapply compiled name as <module> from r4321 ........ r4765 | pjenvey | 2008-06-25 15:05:09 -0400 (Wed, 25 Jun 2008) | 2 lines from: http://svn.python.org/projects/python/branches/release25-maint/Lib/inspect.py@56297 ........ r4767 | pjenvey | 2008-06-25 15:45:51 -0400 (Wed, 25 Jun 2008) | 1 line re-integrate r4053 ........ r4768 | pjenvey | 2008-06-25 15:49:17 -0400 (Wed, 25 Jun 2008) | 3 lines o fix string exceptions which I broke in r4754 o kill OverflowWarning and the custom warnings.py that we no longer need ........ r4769 | pjenvey | 2008-06-25 16:12:14 -0400 (Wed, 25 Jun 2008) | 1 line match messages to CPython 2.5 ........ r4770 | pjenvey | 2008-06-25 16:27:31 -0400 (Wed, 25 Jun 2008) | 1 line small cleanup to unpackSequence ........ r4771 | pjenvey | 2008-06-25 16:46:49 -0400 (Wed, 25 Jun 2008) | 2 lines from: http://svn.python.org/projects/python/branches/release25-maint/Lib/test/regrtest.py@54228 ........ r4772 | pjenvey | 2008-06-25 16:48:27 -0400 (Wed, 25 Jun 2008) | 2 lines re-integrate jython specifics: mostly just -e support and java platform test defines ........ r4774 | fwierzbicki | 2008-06-25 19:08:30 -0400 (Wed, 25 Jun 2008) | 2 lines Can't live without -m. ........ r4777 | pjenvey | 2008-06-25 20:12:35 -0400 (Wed, 25 Jun 2008) | 4 lines skip a number of tests we won't pass anytime soon. mark most of the cjkencodings tests and xml_etree as perm failures for now. re-enable test_unicode as it's close to passing ........ r4778 | pjenvey | 2008-06-25 20:12:50 -0400 (Wed, 25 Jun 2008) | 1 line test_uuid passes ........ r4779 | nriley | 2008-06-25 21:16:20 -0400 (Wed, 25 Jun 2008) | 1 line Return permission denied for files opened for reading. ........ r4781 | nriley | 2008-06-25 21:47:39 -0400 (Wed, 25 Jun 2008) | 1 line Match CPython behavior, hiding banner/prompt if stdin is not interactive and showing prompt if file argument is a tty; remove related workaround from test_cmd_line. ........ r4782 | fwierzbicki | 2008-06-26 13:11:56 -0400 (Thu, 26 Jun 2008) | 2 lines hexoct is passing. ........ r4783 | fwierzbicki | 2008-06-26 13:15:03 -0400 (Thu, 26 Jun 2008) | 3 lines Corner case for fplist fixed. def foo((x)) should be treated the same as def foo(x). ........ r4784 | fwierzbicki | 2008-06-26 16:11:35 -0400 (Thu, 26 Jun 2008) | 2 lines genexp should be sole argument if no parens. First half of fix. ........ r4785 | zyasoft | 2008-06-26 18:43:05 -0400 (Thu, 26 Jun 2008) | 1 line Removed old Jython-specific tests in favor of CPythonLib versions (except that test_urllib.py has a dependency on fileno being int, so changed accordingly). Cleaned up SRE engine code such that it more closely follows _sre.c. Removed optimization of Unicode charset in sre_compile since for UCS-4 for CPython, it doesn't appear to use this optimization anyway. ........ r4786 | zyasoft | 2008-06-26 20:44:30 -0400 (Thu, 26 Jun 2008) | 1 line re.sub, re.subn now coerce to the right type (unicode/str), based on the spec provided by test_re.test_bug_1140 ........ r4787 | zyasoft | 2008-06-26 20:50:25 -0400 (Thu, 26 Jun 2008) | 1 line Removed obsolete test, superseded by 2.5 coercion rules for emptry strings on re.sub ........ r4788 | pjenvey | 2008-06-26 21:14:25 -0400 (Thu, 26 Jun 2008) | 2 lines from: http://svn.python.org/projects/python/branches/release25-maint/Lib/test/test_urllib2_localnet.py@55806 ........ r4789 | pjenvey | 2008-06-26 21:15:47 -0400 (Thu, 26 Jun 2008) | 1 line explicitly close the server socket instead of relying on GC ........ r4790 | zyasoft | 2008-06-26 21:26:29 -0400 (Thu, 26 Jun 2008) | 1 line test_re now passes completely. This was done by commenting inapplicable tests re recursion limits, since we are not going to implement a non-recursive variant, as well as adding the unimplemented typecodes for PyArray. Too bad that there's a lot more to do to get array working as well! ........ r4791 | pjenvey | 2008-06-26 21:30:12 -0400 (Thu, 26 Jun 2008) | 2 lines upgrade socket._fileobject to 2.5's ........ r4792 | pjenvey | 2008-06-26 22:39:20 -0400 (Thu, 26 Jun 2008) | 2 lines from: http://svn.python.org/projects/python/branches/release25-maint/Lib/test/test_hashlib.py@39316 ........ r4793 | pjenvey | 2008-06-26 22:52:59 -0400 (Thu, 26 Jun 2008) | 3 lines add _hashlib with support for everything but sha224, via java.security.MessageDigest. supersedes our md5 module ........ r4794 | pjenvey | 2008-06-26 23:04:45 -0400 (Thu, 26 Jun 2008) | 2 lines from: http://svn.python.org/projects/python/branches/release25-maint/Lib/test/test_hmac.py@58870 ........ r4795 | zyasoft | 2008-06-26 23:14:37 -0400 (Thu, 26 Jun 2008) | 1 line Added stack_size to thread, threading since it's available since 1.4, but only as a hint to the JVM. test_re was not added in the prev commit. test_threading's test of foreign threads doesn't make sense for Jython, or so I decree ........ r4796 | pjenvey | 2008-06-26 23:25:09 -0400 (Thu, 26 Jun 2008) | 3 lines optimize _hashlib.HASH to take advantage of MessageDigest.clone which is supported for all of our hashing types ........ r4797 | pjenvey | 2008-06-26 23:26:55 -0400 (Thu, 26 Jun 2008) | 3 lines o sha is superceded by hashlib o special case test_hmac to avoid our lack of sha224 support ........ r4798 | zyasoft | 2008-06-26 23:50:14 -0400 (Thu, 26 Jun 2008) | 1 line Fixed test_bigmem to reflect Java realities. Didn't get the commit in last time of commenting out test_foreign_thread, not applicable to Jython ........ r4799 | zyasoft | 2008-06-27 00:17:33 -0400 (Fri, 27 Jun 2008) | 1 line Working too fast here, here's the test_bigmem.py fixes. Also added all methods to threading such that it passes tests in test_contextlib ........ r4800 | pjenvey | 2008-06-27 00:27:32 -0400 (Fri, 27 Jun 2008) | 2 lines from: http://svn.python.org/projects/python/branches/release25-maint/Lib/fileinput.py@42507 ........ r4801 | pjenvey | 2008-06-27 00:28:43 -0400 (Fri, 27 Jun 2008) | 1 line reapply Jython workaround for lack of fstat ........ r4802 | zyasoft | 2008-06-27 00:30:59 -0400 (Fri, 27 Jun 2008) | 1 line Enable testing of stack size changing for java platform ........ r4806 | zyasoft | 2008-06-27 00:50:06 -0400 (Fri, 27 Jun 2008) | 1 line NA'ed test_traceback.test_members since it depends on sys.exc_traceback global var, which is not implemented in Jython (not threadsafe/deprecated since Python 1.5) ........ r4807 | zyasoft | 2008-06-27 01:28:40 -0400 (Fri, 27 Jun 2008) | 1 line binascii.a2b_qp now escapes '= ' to '= '. a2b_uu takes empty strings ........ r4808 | pjenvey | 2008-06-27 01:45:44 -0400 (Fri, 27 Jun 2008) | 1 line unused var ........ r4809 | zyasoft | 2008-06-27 03:24:14 -0400 (Fri, 27 Jun 2008) | 1 line Added to os module: devnull, urandom. Worked around issue in java.io.File#mkdirs when adding directory like x/y/z/. ........ r4810 | fwierzbicki | 2008-06-27 13:47:50 -0400 (Fri, 27 Jun 2008) | 8 lines Cleaned up Call node creation, and now gen expressions are checked from both sides so that: foo(x for x in range(10), 100) foo(100, x for x in range(10)) properly fail. ........ r4821 | zyasoft | 2008-06-30 03:06:55 -0400 (Mon, 30 Jun 2008) | 1 line Rewrote cStringIO to use StringBuffer instead of managing its own buffer (also not StringBuilder) ........ r4822 | zyasoft | 2008-06-30 03:41:08 -0400 (Mon, 30 Jun 2008) | 1 line Fixed cStringIO to support ops for cPickle ........ r4823 | zyasoft | 2008-06-30 04:18:38 -0400 (Mon, 30 Jun 2008) | 1 line Fixed unicode coercion for str.__mod__ with unicode args ........ r4824 | zyasoft | 2008-06-30 04:59:43 -0400 (Mon, 30 Jun 2008) | 1 line Fixed unicode coercion logic for PyString.__mod__. Removed 2.5 contextlib.py in favor of direct from CPythonLib ........ r4825 | zyasoft | 2008-06-30 12:14:30 -0400 (Mon, 30 Jun 2008) | 1 line Change cStringIO to use StringBuilder semantics. Use via thread confinement, or with external locking. Keep it simple, keep it lightweight. ........ r4826 | zyasoft | 2008-06-30 14:08:37 -0400 (Mon, 30 Jun 2008) | 1 line Restored cStringIO.getString ........ r4827 | zyasoft | 2008-07-01 09:52:38 -0400 (Tue, 01 Jul 2008) | 1 line Removed modules and tests exactly duplicated from CPythonLib ........ r4828 | zyasoft | 2008-07-01 11:50:43 -0400 (Tue, 01 Jul 2008) | 1 line Removed modules/tests that are trivially changed with respect to CPythonLib ........ r4829 | zyasoft | 2008-07-01 13:21:43 -0400 (Tue, 01 Jul 2008) | 1 line Removed modules/tests that should be updated to CPythonLib. Incidentally, test_cmath now tests that cmath.log takes a base ........ r4830 | zyasoft | 2008-07-01 16:38:05 -0400 (Tue, 01 Jul 2008) | 1 line test_mailbox has been rewritten since 2.2, the version that was committed ........ r4831 | zyasoft | 2008-07-01 17:12:34 -0400 (Tue, 01 Jul 2008) | 1 line Removed spurious placement of test_bigmem ........ r4832 | leosoto | 2008-07-01 17:30:12 -0400 (Tue, 01 Jul 2008) | 1 line pyBoolean.__tojava__(Object.class) now returns a Boolean instead of an Integer. Also used valueOf static methods instead of constructors. ........ r4833 | zyasoft | 2008-07-01 18:02:55 -0400 (Tue, 01 Jul 2008) | 1 line cStringIO#readline should not insert backslash-n (ambigous reading, but CPython implementation says otherwise) ........ r4834 | leosoto | 2008-07-01 18:24:50 -0400 (Tue, 01 Jul 2008) | 1 line zxJDBC: Added BigInteger support to the PostgreSQLDataHandler ........ r4835 | leosoto | 2008-07-01 19:38:37 -0400 (Tue, 01 Jul 2008) | 1 line zxJDBC: Avoid preparing a statement when executemany() is called with an empty sequence ........ r4836 | leosoto | 2008-07-01 20:33:20 -0400 (Tue, 01 Jul 2008) | 1 line Workaround for issue 1047. At least on my system (jdk 1.6.0_06) it makes pulldom usable ........ r4837 | leosoto | 2008-07-01 23:51:43 -0400 (Tue, 01 Jul 2008) | 1 line Another string interpolation fix, this time when the left operand is an unicode containing non-ascii chars and there are no unicodes on the right argument ........ r4838 | zyasoft | 2008-07-02 01:56:10 -0400 (Wed, 02 Jul 2008) | 1 line cmath.log now takes a base parameter; all functions now test for ValueError to reraise as a TypeError, to be consistent with CPython ........ r4839 | leosoto | 2008-07-02 16:17:29 -0400 (Wed, 02 Jul 2008) | 1 line Updated eclipse configuration to use the antlr3.1b1 JAR instead of 3.0.1 ........ r4840 | leosoto | 2008-07-02 17:09:14 -0400 (Wed, 02 Jul 2008) | 1 line Syncing PyBaseExceptionDerived ........ r4841 | leosoto | 2008-07-02 17:43:16 -0400 (Wed, 02 Jul 2008) | 1 line Fixing Derived#__cmp__ to avoid raise TypeError when __cmp__ has not been overrided and super.__cmp__() returns -2 (see #1031) ........ r4842 | leosoto | 2008-07-02 20:36:50 -0400 (Wed, 02 Jul 2008) | 1 line Enable utf-8 source encoding support (the test_cookielib issue was fixed upstream: http://bugs.python.org/issue3261). Also recognize 'latin-1' as an alias for 'iso8859-1' ........ r4843 | leosoto | 2008-07-02 22:39:07 -0400 (Wed, 02 Jul 2008) | 1 line Limiting the buffer size used for discovering the encoding, to avoid crashing when reading big files (such as django/tests/regressiontests/forms/fields.py), as the default size of BufferedReader was too close to the readlimit set by the mark() call ........ r4845 | fwierzbicki | 2008-07-03 21:13:07 -0400 (Thu, 03 Jul 2008) | 3 lines change token name from ENDMARK to ENDMARKER to better fit with CPython's Grammar/Grammar file. Alse some tabs->spaces. ........ r4846 | fwierzbicki | 2008-07-03 21:49:41 -0400 (Thu, 03 Jul 2008) | 3 lines Introduced ENDMARKER to Python.g -- needed for files that lack a newline. ........ r4847 | fwierzbicki | 2008-07-03 22:01:44 -0400 (Thu, 03 Jul 2008) | 2 lines import test_support. ........ r4848 | fwierzbicki | 2008-07-04 08:21:30 -0400 (Fri, 04 Jul 2008) | 3 lines Removed ENDMARKER from Python.g and applied Leo Soto's patch to add a newline to the end of input that ends w/o a newline. ........ r4849 | fwierzbicki | 2008-07-04 08:33:14 -0400 (Fri, 04 Jul 2008) | 2 lines Formatting and remove unused variable. ........ r4850 | fwierzbicki | 2008-07-04 17:25:24 -0400 (Fri, 04 Jul 2008) | 3 lines Moved the actual emit of the generated newline (for input w/o a newline) to *after* dedents are emitted. ........ r4852 | leosoto | 2008-07-05 20:37:12 -0400 (Sat, 05 Jul 2008) | 20 lines StringFormatter: '%d' and '%f' support for the __int__ and __float__ protocol respectively. The implementation is more convulted than it should be, because we have PyString implementing __float__ and __int__ at the "java level" but not at the "python level". For string formatting, only "python level" __float__ and __int__ must be supported. Also, considering that __int__ can return a PyLong, this case needs special care. Basically formatInteger now can call formatLong if a PyLong is found as the result of calling __int__. Then, as formatLong can also be called from formatInteger, __hex__, __oct__ and __str__ conversions were moved inside formatLong. Finally, test_format_jy was changed to stop checking that we don't support big floats on '%d' (CPython doesn't, but that seems a limitation of the specific implementation and I can't imagine a program that could break on Jython because we *support* it). ........ r4853 | pjenvey | 2008-07-05 21:51:20 -0400 (Sat, 05 Jul 2008) | 1 line always recompile bytecode from zipimporter too ........ r4855 | fwierzbicki | 2008-07-07 05:08:22 -0400 (Mon, 07 Jul 2008) | 3 lines Create a jython-complete.jar to make it easier to put out a 2.5 alpha. ........ r4856 | zyasoft | 2008-07-07 07:22:16 -0400 (Mon, 07 Jul 2008) | 1 line Removed double-checked locking used to init ThreadStateMap; didn't make sense to do any locking here anyway. Moved trycatch emit in visitWith to be where it ahappens (doesn't change output, but makes it easier to follow code). ........ r4857 | pjenvey | 2008-07-07 15:59:32 -0400 (Mon, 07 Jul 2008) | 1 line no need to go through __builtin__ for issubclass ........ r4859 | pjenvey | 2008-07-07 19:21:43 -0400 (Mon, 07 Jul 2008) | 1 line simplify ........ r4863 | pjenvey | 2008-07-07 21:14:55 -0400 (Mon, 07 Jul 2008) | 2 lines from: http://svn.python.org/projects/python/branches/release25-maint/Lib/test/test_enumerate.py@39608 ........ r4864 | pjenvey | 2008-07-07 21:15:40 -0400 (Mon, 07 Jul 2008) | 1 line avoid implementation detail tests ........ r4865 | pjenvey | 2008-07-08 01:20:37 -0400 (Tue, 08 Jul 2008) | 2 lines from: http://svn.python.org/projects/python/branches/release25-maint/Lib/test/test_iter.py@33742 ........ r4866 | pjenvey | 2008-07-08 01:24:17 -0400 (Tue, 08 Jul 2008) | 4 lines o make StopIteration (and the like) a 'sink state' in iter and call-iter, to fix the test_iter test_sinkstate_* tests o workaround test_iter test_unpack_iter GC related issues ........ r4867 | pjenvey | 2008-07-08 01:37:05 -0400 (Tue, 08 Jul 2008) | 5 lines o wrap the fstat usage in is_jython instead of commenting it out o "sync" with: http://svn.python.org/projects/python/branches/release25-maint/Lib/test/test_largefile.py@33923 (no changes; equiv to 2.3's) ........ r4868 | pjenvey | 2008-07-08 02:20:46 -0400 (Tue, 08 Jul 2008) | 4 lines from: http://svn.python.org/projects/python/branches/release25-maint/Lib/test/test_repr.py@58123 http://svn.python.org/projects/python/branches/release25-maint/Lib/test/test_richcmp.py@43274 ........ r4869 | pjenvey | 2008-07-08 03:27:03 -0400 (Tue, 08 Jul 2008) | 4 lines o workaround jython issues in test_richcmp and test_repr o our custom test_operations isn't really necessary and we pass stdlib's. also now pass stdlib's test_long ........ r4870 | fwierzbicki | 2008-07-08 04:59:37 -0400 (Tue, 08 Jul 2008) | 2 lines some tweaks to help the install task. ........ r4876 | pjenvey | 2008-07-08 15:55:47 -0400 (Tue, 08 Jul 2008) | 3 lines always re-generating byte code is more trouble than it's worth right now (breaks the imp module) ........ r4877 | pjenvey | 2008-07-08 16:38:02 -0400 (Tue, 08 Jul 2008) | 5 lines from: http://svn.python.org/projects/python/branches/release25-maint/Lib/test/test_scope.py@50493 http://svn.python.org/projects/python/branches/release25-maint/Lib/test/test_types.py@51140 http://svn.python.org/projects/python/branches/release25-maint/Lib/test/test_zlib.py@62236 ........ r4878 | pjenvey | 2008-07-08 17:05:48 -0400 (Tue, 08 Jul 2008) | 4 lines o allow a length argument to zlib decompressobj flush o workarounds for 2.5 test_scope test_types (which output now matches stdlib's) and test_zlib ........ r4879 | pjenvey | 2008-07-08 20:41:01 -0400 (Tue, 08 Jul 2008) | 3 lines from: http://svn.python.org/projects/python/branches/release25-maint/Lib/platform.py@62855 ........ r4880 | pjenvey | 2008-07-08 20:42:59 -0400 (Tue, 08 Jul 2008) | 1 line s/java.os/os/g ........ r4881 | nriley | 2008-07-08 23:50:19 -0400 (Tue, 08 Jul 2008) | 1 line overriding fillInStackTrace for PyException speeds things up quite a bit ........ r4882 | nriley | 2008-07-10 01:12:05 -0400 (Thu, 10 Jul 2008) | 1 line need bash to test the script, too ........ r4883 | leosoto | 2008-07-10 15:51:37 -0400 (Thu, 10 Jul 2008) | 1 line zxJDBC: Map SQLExceptions to zxJDBC.IntegrityError if the sqlState says the exception was caused by a integrity violation ........ r4884 | pjenvey | 2008-07-10 23:36:29 -0400 (Thu, 10 Jul 2008) | 2 lines from: http://svn.python.org/projects/python/branches/release25-maint/Lib/test/test_support.py@60337 ........ r4885 | pjenvey | 2008-07-10 23:46:09 -0400 (Thu, 10 Jul 2008) | 3 lines add a -j option to regrtest for capturing test output to JUnit XML files (one file per TestCase or module import or doctest) in the specified dir ........ r4887 | fwierzbicki | 2008-07-11 07:52:55 -0400 (Fri, 11 Jul 2008) | 3 lines move "not needed" checks into separate task because all such tasks *are* needed during a full build regardless of up to date status of files. ........ r4888 | zyasoft | 2008-07-11 08:16:28 -0400 (Fri, 11 Jul 2008) | 1 line Begin port of PyPy's _rawffi, which with their pure-Python ctypes wrapper, implements ctypes ........ r4889 | fwierzbicki | 2008-07-11 08:45:41 -0400 (Fri, 11 Jul 2008) | 4 lines added svnant-jars by default for more convenient full-build. Fixed jarjar and jar-complete (so jarjar only recompiles on changes and jar-complete properly depends on jarjar). ........ r4890 | zyasoft | 2008-07-11 10:05:13 -0400 (Fri, 11 Jul 2008) | 1 line From PyPy's test__rawffi, broke out standard ctypes_test code they use (to avoid using their compilation toolchain). Implemented minimum to get test__rawffi.test_short_addition to pass. ........ r4891 | pjenvey | 2008-07-11 15:37:19 -0400 (Fri, 11 Jul 2008) | 1 line test_pep263 passes now ........ r4892 | pjenvey | 2008-07-11 16:10:32 -0400 (Fri, 11 Jul 2008) | 3 lines from: http://svn.python.org/projects/python/branches/release25-maint/Lib/test/string_tests.py@55878 ........ r4893 | pjenvey | 2008-07-11 16:16:53 -0400 (Fri, 11 Jul 2008) | 5 lines o re-integrate workarounds for string_tests o add rsplit fixes #1023 thanks Nimish Telang ........ r4894 | pjenvey | 2008-07-11 20:10:28 -0400 (Fri, 11 Jul 2008) | 2 lines fix unicode(str_subclass) not using its __unicode__ method ........ r4895 | pjenvey | 2008-07-11 20:13:15 -0400 (Fri, 11 Jul 2008) | 3 lines fix some odder 2.5 tests of string count/find/rfind. rewrite join to act like CPython's, mainly so: a.join([b]) is b ........ r4896 | pjenvey | 2008-07-11 20:33:21 -0400 (Fri, 11 Jul 2008) | 1 line fix java exception names being prefixed with <unknown> in Python tracebacks ........ r4897 | pjenvey | 2008-07-11 20:53:44 -0400 (Fri, 11 Jul 2008) | 1 line fake reload(sys), like reload(PyJavaClass). fix ClassCastException in reload ........ r4901 | pjenvey | 2008-07-11 21:28:39 -0400 (Fri, 11 Jul 2008) | 1 line expect test_mhlib to pass on posix and skip elsewhere ........ r4902 | zyasoft | 2008-07-12 05:13:38 -0400 (Sat, 12 Jul 2008) | 1 line Removed tests not appropriate for Jython, test_peepholer, test_profile; added test_strptime, test_csv ........ r4903 | zyasoft | 2008-07-12 06:08:11 -0400 (Sat, 12 Jul 2008) | 1 line Replaced Lib/datetime.py with version from PyPy, http://codespeak.net/svn/pypy/dist/pypy/lib/datetime.py@56484 ........ r4904 | zyasoft | 2008-07-12 09:50:19 -0400 (Sat, 12 Jul 2008) | 1 line Fixed str|string|unicode.replace for PyString or PyUnicode in the basic plane ........ r4905 | zyasoft | 2008-07-12 09:51:06 -0400 (Sat, 12 Jul 2008) | 1 line Removed tests not relevant to Jython around CPython code compilation ........ r4906 | zyasoft | 2008-07-12 10:09:20 -0400 (Sat, 12 Jul 2008) | 1 line Operations on unicode objs in basic plane can only result in basic plane objs (btw, not true of astral) ........ r4907 | zyasoft | 2008-07-12 11:42:09 -0400 (Sat, 12 Jul 2008) | 1 line Added datetime.strptime ........ r4908 | zyasoft | 2008-07-12 11:55:44 -0400 (Sat, 12 Jul 2008) | 1 line datetime.fromtimestamp now rounds seconds,microseconds within 1 microsecond of an integer second to that second ........ r4909 | zyasoft | 2008-07-12 12:50:22 -0400 (Sat, 12 Jul 2008) | 1 line ascii codec will always be in basic plane, so at least optimize setting of that when constructing unicode ........ r4910 | leosoto | 2008-07-12 15:50:43 -0400 (Sat, 12 Jul 2008) | 1 line Now test_strptime pass. This is done by improving the current SimpleDateFormat-backed implementation a bit, and delegating to _strptime.strptime for formats not supported by SimpleDateFormat. ........ r4911 | leosoto | 2008-07-12 15:52:59 -0400 (Sat, 12 Jul 2008) | 1 line Removing a duplicate line on CPythonLib.includes I introduced on r4910 ........ r4912 | pjenvey | 2008-07-12 15:57:48 -0400 (Sat, 12 Jul 2008) | 4 lines o add popen2.cleanup for CPython compat. and to fix test_popen2 o make threading.currentThread() is threading.currentThread() (with the help of a WeakKeyDictionary) to allow _threading_local to work ........ r4913 | pjenvey | 2008-07-12 20:47:08 -0400 (Sat, 12 Jul 2008) | 4 lines max_read_chunk of 10mb kills test_gzip.test_many_append's performance due to repeated 10mb reads. CPython doesn't suffer from this -- maybe its allocator recycles the same 10mb. lowering to 256K speeds test time from 15 to 1 second ........ r4914 | pjenvey | 2008-07-12 22:07:51 -0400 (Sat, 12 Jul 2008) | 1 line add C_EXTENSION because pkgutil references it ........ r4916 | pjenvey | 2008-07-12 23:36:31 -0400 (Sat, 12 Jul 2008) | 2 lines fix to make the 'g' formatter closer to CPython's. fixes test_tokenize ........ r4917 | zyasoft | 2008-07-14 06:47:01 -0400 (Mon, 14 Jul 2008) | 1 line split and rsplit do not need to be UTF-16 aware ........ r4918 | zyasoft | 2008-07-14 06:52:18 -0400 (Mon, 14 Jul 2008) | 3 lines From http://svn.python.org/projects/python/branches/release25-maint/Lib/test/test_str@64946 ........ r4919 | zyasoft | 2008-07-14 07:03:54 -0400 (Mon, 14 Jul 2008) | 1 line Removed inapplicable test due to different algorithm in expandtabs which cannot overflow in Jython ........ r4922 | zyasoft | 2008-07-14 07:44:28 -0400 (Mon, 14 Jul 2008) | 1 line time.struct_time can now take any obj that can be turned into a list and converted into 9 integers ........ r4924 | zyasoft | 2008-07-14 08:11:26 -0400 (Mon, 14 Jul 2008) | 3 lines From http://svn.python.org/projects/python/branches/release25-maint/Lib/uu.py@64946 ........ r4925 | zyasoft | 2008-07-14 08:19:10 -0400 (Mon, 14 Jul 2008) | 2 lines Fixed uu.encode, decode so that it does not rely on refcounting to close files ........ r4928 | zyasoft | 2008-07-14 11:19:01 -0400 (Mon, 14 Jul 2008) | 3 lines ReferenceQueue objs, by their nature, only make sense if transient. So make them so, this enables interoperation with Terracotta. ........ r4930 | pjenvey | 2008-07-14 15:24:49 -0400 (Mon, 14 Jul 2008) | 1 line couple small array fixes ........ r4932 | fwierzbicki | 2008-07-14 15:25:59 -0400 (Mon, 14 Jul 2008) | 2 lines unbreak --memo again :) ........ r4933 | pjenvey | 2008-07-14 15:26:58 -0400 (Mon, 14 Jul 2008) | 3 lines from: http://svn.python.org/projects/python/branches/release25-maint/Lib/distutils@64955 ........ r4934 | fwierzbicki | 2008-07-14 15:27:40 -0400 (Mon, 14 Jul 2008) | 3 lines generate newlines before the dedents again. Although the reverse was solving some problems, it was creating more. ........ r4935 | pjenvey | 2008-07-14 15:31:38 -0400 (Mon, 14 Jul 2008) | 3 lines o re-integrate Jython distutils changes o check for $py.class on Jython instead of pyc in test_build_py ........ r4936 | leosoto | 2008-07-14 16:12:27 -0400 (Mon, 14 Jul 2008) | 1 line Allow derived types written in Jython to implement a __tojava__ method. This will allow better integration with java for python types such as decimal.Decimal, datetime.date, etc. ........ r4937 | fwierzbicki | 2008-07-15 11:23:32 -0400 (Tue, 15 Jul 2008) | 4 lines Fixes in build.xml to make full-build work again. Some cleanup like the removal of old parser and old website tasks. Changed README to describe 2.5 alpha release. ........ r4939 | leosoto | 2008-07-15 12:13:50 -0400 (Tue, 15 Jul 2008) | 1 line decimal.py from http://svn.python.org/projects/python/branches/release25-maint/Lib/decimal.py@64967 ........ r4940 | leosoto | 2008-07-15 12:24:18 -0400 (Tue, 15 Jul 2008) | 1 line Implemented decimal.Decimal.__tojava__ to convert decimal instances to java BigDecimal when python -> java conversion is requested ........ r4941 | leosoto | 2008-07-15 13:16:16 -0400 (Tue, 15 Jul 2008) | 1 line Implemented __tojava__ on datetime.time, datetime.date and datetime.datetime. On the current implementation, they can be converted to java.sql.Time, java.sql.Date, java.sql.Timestamp, respectively. All of them can also be converted to java.util.Calendar. Only one caveat: the tzinfo attribute of times and datetimes is currently ignored ........ r4942 | leosoto | 2008-07-15 14:00:57 -0400 (Tue, 15 Jul 2008) | 1 line Removing decimal.py from CPythonLib.includes. I forgot to do that on r4939 ........ r4943 | fwierzbicki | 2008-07-15 14:33:40 -0400 (Tue, 15 Jul 2008) | 2 lines build tweaks + workaround for an NT problem in site.py ........ r4944 | nriley | 2008-07-15 14:42:08 -0400 (Tue, 15 Jul 2008) | 1 line fix for startup problem on Windows - AttributeError was accidentally trapping posixpath abspath failure ........ r4945 | fwierzbicki | 2008-07-15 15:27:53 -0400 (Tue, 15 Jul 2008) | 3 lines already incrementing to 2.5a1 -- sourceforge is caching the old one too hard and I really need to get Windows fixed. ........ r4947 | leosoto | 2008-07-15 17:21:30 -0400 (Tue, 15 Jul 2008) | 18 lines Improvements to the zxJDBC default DataHandler: - Map DATE, TIME and TIMESTAMP columns to datetime.date, datetime.time and datetime.datetime respectively. Factory methods to create instances of datetime.* were added to Py.java. - Map VARCHAR columns to unicode instead of str. - Don't try to guess the precision of NUMERIC columns . - Use Py.True and Py.False instead of Py.One and Py.Zero. Some of this changes may cause backwards-incompatibility, so I've copied the old DataHandler logic into Jython22DataHandler. Then, old code should simply setup this datahandler on its connections if it is not going to be adapted to the new DataHandler default behaviour. ........ r4949 | amak | 2008-07-15 17:33:35 -0400 (Tue, 15 Jul 2008) | 1 line Merging support for IPv6 and UDP <broadcast> ........ r4950 | nriley | 2008-07-15 18:33:04 -0400 (Tue, 15 Jul 2008) | 1 line (Partial) Windows port of Jython launcher script; should work on Windows 2000 and later. ........ r4951 | nriley | 2008-07-15 18:37:38 -0400 (Tue, 15 Jul 2008) | 1 line Oops, left some debugging code in. ........ r4952 | amak | 2008-07-15 18:51:51 -0400 (Tue, 15 Jul 2008) | 1 line Backing out what I thought were simple changes, which appear to have broken the build. ........ r4959 | pjenvey | 2008-07-16 21:23:59 -0400 (Wed, 16 Jul 2008) | 1 line add symlink on posix ........ r4961 | pjenvey | 2008-07-16 23:21:35 -0400 (Wed, 16 Jul 2008) | 5 lines fix the symlink related tests by adding readlink, using _posix.lstat and utilizing _posix symlink stuff in posixpath. also utilize real stat results in posixpath, and re-enable ismount in ntpath since we can support it in posixpath ........ r4963 | pjenvey | 2008-07-17 00:59:53 -0400 (Thu, 17 Jul 2008) | 9 lines o fix PythonPOSIXHandler getEnv/getCurrentWorkingDirectory return signatures o fix posixpath.__all__ o only enable os.symlink/readlink and posixpath friends if the posix factory appears native. pure java support for symlinks is still sketchy -- in particular with dead links -- switching these on enables tests in test_glob, test_posixpath, test_tarfile that utilize dead links and are doomed to failure o allow partial filling of stat results from jna-posix, padding the rest with 0s ........ r4965 | fwierzbicki | 2008-07-17 17:19:56 -0400 (Thu, 17 Jul 2008) | 2 lines added custom toStringTree to each node. ........ r4967 | pjenvey | 2008-07-17 20:28:49 -0400 (Thu, 17 Jul 2008) | 3 lines boost the mark limit even higher for the lenghty lines in pygments.lexers._vimbuiltins ........ r4968 | nriley | 2008-07-18 15:20:39 -0400 (Fri, 18 Jul 2008) | 1 line Work with jython-complete.jar; handle spaces in $JAVA_HOME. ........ r4969 | nriley | 2008-07-18 15:21:37 -0400 (Fri, 18 Jul 2008) | 1 line Actually use JYTHON_OPTS; correct error message and properly delete _JYTHON_HOME. ........ r4970 | nriley | 2008-07-18 16:40:17 -0400 (Fri, 18 Jul 2008) | 1 line Make ant regrtest work on Windows again. ........ r4971 | nriley | 2008-07-18 16:51:00 -0400 (Fri, 18 Jul 2008) | 1 line Conditionalize launcher test; no need for Cygwin test. ........ r4973 | nriley | 2008-07-19 01:54:20 -0400 (Sat, 19 Jul 2008) | 1 line Clean up install targets; allow install to be run without full-build; normalize source directory structure between checked-out and installed versions. ........ r4974 | fwierzbicki | 2008-07-19 18:48:21 -0400 (Sat, 19 Jul 2008) | 4 lines Make PythonTree's toStringTree more easily comparable with ast/astview.py output. This will help with the walkerless Python.g, as it doesn't quite parse ast/astview.py yet. ........ r4980 | pjenvey | 2008-07-21 01:00:49 -0400 (Mon, 21 Jul 2008) | 1 line integrate the sink state conditions ........ r4982 | pjenvey | 2008-07-21 15:11:48 -0400 (Mon, 21 Jul 2008) | 1 line fix exposed __getitem__ possibly returning null ........ r4983 | pjenvey | 2008-07-21 15:45:12 -0400 (Mon, 21 Jul 2008) | 3 lines o fix filter to pass test_builtin.test_filter and test_filter_subclasses o remove the unnecessary __builtin__.tuple ........ r4984 | pjenvey | 2008-07-21 15:48:17 -0400 (Mon, 21 Jul 2008) | 1 line make the failure verbose because test_site_flag occasionally fails on the buildbot mysteriously ........ r4985 | pjenvey | 2008-07-22 21:18:53 -0400 (Tue, 22 Jul 2008) | 4 lines o make Py.makeCharacter consisitent in never returning unicode unless it was asked for o move calculateIndex into PySequence for PyArray o allow PyLong.getLong access for PyArray ........ r4986 | pjenvey | 2008-07-22 21:19:34 -0400 (Tue, 22 Jul 2008) | 2 lines from: http://svn.python.org/projects/python/branches/release25-maint/Lib/test/test_array.py@60839 ........ r4987 | pjenvey | 2008-07-22 21:21:32 -0400 (Tue, 22 Jul 2008) | 1 line many various PyArray fixes for 2.5 test_array ........ r4988 | fwierzbicki | 2008-07-22 21:58:01 -0400 (Tue, 22 Jul 2008) | 4 lines Made Str offsets better match CPython. PythonTree now extends BaseTree (too much of CommonTree was getting changed anyway). astdump.py repaired so that it is a useful testing ground for ast comparisons. ........ r4989 | fwierzbicki | 2008-07-23 14:39:09 -0400 (Wed, 23 Jul 2008) | 2 lines Offset fixes for Try/Catch and Call. ........ r4990 | fwierzbicki | 2008-07-23 15:13:04 -0400 (Wed, 23 Jul 2008) | 6 lines Made except blocks optional in PythonPartial.g since: try: Is a valid partial parse. ........ r4991 | pjenvey | 2008-07-23 16:36:42 -0400 (Wed, 23 Jul 2008) | 2 lines o fix passing chars > 256 to Py.makeCharacter o make struct.error a class and raise struct.errors instead of OverflowErrors ........ r4992 | pjenvey | 2008-07-23 16:55:03 -0400 (Wed, 23 Jul 2008) | 3 lines support the new float.__get/setformat__ classmethods -- they just claim our formats are 'unknown' ........ r4993 | pjenvey | 2008-07-24 03:22:38 -0400 (Thu, 24 Jul 2008) | 2 lines fix a regression from the bug 1140 fix ........ r4994 | pjenvey | 2008-07-24 03:29:54 -0400 (Thu, 24 Jul 2008) | 3 lines add codecs.charmap_build which builds optimized encoding maps now used by the charmap encoder ........ r4995 | fwierzbicki | 2008-07-24 09:51:47 -0400 (Thu, 24 Jul 2008) | 2 lines Make stopCharIndex consistent. ........ r4996 | fwierzbicki | 2008-07-24 12:58:24 -0400 (Thu, 24 Jul 2008) | 2 lines Fix for wrong line numbers in func.co_firstlineno. ........ r4997 | pjenvey | 2008-07-24 19:42:09 -0400 (Thu, 24 Jul 2008) | 1 line cleanup unused var ........ r4998 | nriley | 2008-07-25 02:07:24 -0400 (Fri, 25 Jul 2008) | 1 line Suppress exception truncating /dev/null when opening it for write on Linux and Solaris; should fix test_os. ........ r4999 | fwierzbicki | 2008-07-25 21:27:25 -0400 (Fri, 25 Jul 2008) | 3 lines Re-enabled APIVersion checking in imp.java. Used ASM to read and write APIVersion as an annotation. Incremented APIVersion from 12 to 13. ........ r5000 | fwierzbicki | 2008-07-25 21:34:48 -0400 (Fri, 25 Jul 2008) | 2 lines Small cleanups in imp. ........ r5001 | fwierzbicki | 2008-07-25 21:51:48 -0400 (Fri, 25 Jul 2008) | 2 lines Small cleanup in Py.java -- killing stray System.outs. ........ r5002 | fwierzbicki | 2008-07-25 21:55:04 -0400 (Fri, 25 Jul 2008) | 2 lines Removed stray System.outs. ........ r5003 | fwierzbicki | 2008-07-26 10:41:46 -0400 (Sat, 26 Jul 2008) | 2 lines Changing comment convention back to proper style (start with Returns). ........ r5004 | fwierzbicki | 2008-07-27 09:21:12 -0400 (Sun, 27 Jul 2008) | 2 lines comment out DEBUG.class in the repo. ........ r5005 | fwierzbicki | 2008-07-27 22:41:38 -0400 (Sun, 27 Jul 2008) | 2 lines Better error messages in the face of parser errors (line numbers + char column). ........ r5006 | pjenvey | 2008-07-28 00:56:03 -0400 (Mon, 28 Jul 2008) | 3 lines o add os.link (fixes test_shutil) o fix test_re's test output -- it shouldn't have any now ........ r5007 | pjenvey | 2008-07-28 02:38:44 -0400 (Mon, 28 Jul 2008) | 7 lines PEP 357 (__index__), adds: o PyObject.isIndex - true if int, long or implements __index__ o PyObject.asIndex - like asInt for indexes o also fixed a dispatching to __get/set/delitem__ vs __get/set/delslice__ bug and __get/set/delitem__ indices weren't utilizing __len__ when available (fixes test_userstring) ........ r5008 | pjenvey | 2008-07-28 02:40:09 -0400 (Mon, 28 Jul 2008) | 2 lines deriveds changes for __index__ ........ r5009 | zyasoft | 2008-07-28 07:51:51 -0400 (Mon, 28 Jul 2008) | 3 lines test__rawffi will now skip if it cannot load ctypes_test, a test dynamic library that we do not yet have an ant task to create. ........ r5010 | zyasoft | 2008-07-28 08:13:52 -0400 (Mon, 28 Jul 2008) | 3 lines Replaced test_inspect.py with rewritten version (using unittest!) from 2.5: http://svn.python.org/projects/python/branches/release25-maint/Lib/test/test_inspect.py@65262 ........ r5011 | zyasoft | 2008-07-28 09:33:50 -0400 (Mon, 28 Jul 2008) | 5 lines Excluded test cases that depend on tuple unpacking in the arg specification, since this depends on introspecing bytecode. (Perhaps we should provide a Jython-specific version where appropriate metadata is emitted in the compiled code object?) ........ r5012 | pjenvey | 2008-07-28 15:46:39 -0400 (Mon, 28 Jul 2008) | 5 lines fix stock UserList/test_userlist: o handle __get/set/delslice__ start/stop as null or None in PySlice.indices2 o fix list slice assignments of the same underlying list (always copy first as CPython does) ........ r5013 | pjenvey | 2008-07-28 15:50:43 -0400 (Mon, 28 Jul 2008) | 1 line include UserList ........ r5014 | nriley | 2008-07-28 18:55:35 -0400 (Mon, 28 Jul 2008) | 1 line jna-posix from http://svn.codehaus.org/jruby-contrib/trunk/jna-posix r210 ........ r5015 | nriley | 2008-07-28 18:56:55 -0400 (Mon, 28 Jul 2008) | 1 line pwd, grp; test_posix no longer skipped ........ r5016 | pjenvey | 2008-07-28 19:13:21 -0400 (Mon, 28 Jul 2008) | 1 line fix chdir('/') on windows ........ r5017 | fwierzbicki | 2008-07-28 21:40:32 -0400 (Mon, 28 Jul 2008) | 2 lines IParserHost is no longer used. ........ r5018 | fwierzbicki | 2008-07-29 08:31:46 -0400 (Tue, 29 Jul 2008) | 2 lines Move testing classes out of main code. ........ r5019 | pjenvey | 2008-07-29 16:29:08 -0400 (Tue, 29 Jul 2008) | 4 lines add an InputStream tie-in to TextIOBases, for parsing in universal newlines mode fixes #1082 ........ r5020 | zyasoft | 2008-07-29 18:33:56 -0400 (Tue, 29 Jul 2008) | 5 lines cStringIO.tell needs to return an int for it to be used by __len__ (perhaps that should be relaxed instead?). Found by testing against PyAMF which uses cStringIO as a backing store for its BufferedByteStream objs. ........ r5021 | pjenvey | 2008-07-29 18:40:05 -0400 (Tue, 29 Jul 2008) | 2 lines fix readChunk reading more than CHUNK_SIZE, which'll blow up packReadahead ........ r5022 | zyasoft | 2008-07-30 11:46:31 -0400 (Wed, 30 Jul 2008) | 4 lines Support inf, -inf, nan literals (and any uppercasing). struct.pack("d") ducktypes like CPython and calls __float__. This fixes a number of issues for PyAMF. ........ r5023 | zyasoft | 2008-07-30 15:57:16 -0400 (Wed, 30 Jul 2008) | 3 lines Changed default format for __getformat__/__setformat__ to "IEEE, big-endian", and supported switching back and forth with "unknown". ........ r5024 | pjenvey | 2008-07-30 18:39:24 -0400 (Wed, 30 Jul 2008) | 2 lines add a builtin _functools.partial type ........ r5025 | pjenvey | 2008-07-30 19:00:32 -0400 (Wed, 30 Jul 2008) | 1 line include functools ........ r5026 | fwierzbicki | 2008-07-31 09:10:57 -0400 (Thu, 31 Jul 2008) | 2 lines Switch to Antlr 3.1b2. ........ r5027 ... [truncated message content] |
From: <fwi...@us...> - 2008-08-19 15:07:50
|
Revision: 5205 http://jython.svn.sourceforge.net/jython/?rev=5205&view=rev Author: fwierzbicki Date: 2008-08-19 15:07:48 +0000 (Tue, 19 Aug 2008) Log Message: ----------- Removed merge tracking for "svnmerge" for https://jython.svn.sourceforge.net/svnroot/jython/branches/utf16 Property Changed: ---------------- trunk/jython/ Property changes on: trunk/jython ___________________________________________________________________ Modified: svnmerge-integrated - /branches/asm:1-4384 /branches/utf16:1-4726 + /branches/asm:1-4384 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2008-08-19 14:27:04
|
Revision: 5204 http://jython.svn.sourceforge.net/jython/?rev=5204&view=rev Author: fwierzbicki Date: 2008-08-19 14:27:02 +0000 (Tue, 19 Aug 2008) Log Message: ----------- Initialized merge tracking via "svnmerge" with revisions "1-4384" from https://jython.svn.sourceforge.net/svnroot/jython/branches/asm Property Changed: ---------------- trunk/jython/ Property changes on: trunk/jython ___________________________________________________________________ Modified: svnmerge-integrated - /branches/utf16:1-4726 + /branches/asm:1-4384 /branches/utf16:1-4726 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2008-08-19 14:10:45
|
Revision: 5203 http://jython.svn.sourceforge.net/jython/?rev=5203&view=rev Author: fwierzbicki Date: 2008-08-19 14:10:42 +0000 (Tue, 19 Aug 2008) Log Message: ----------- Creating 2.3 branch, just in case someone someday wants to go back to javacc + old non-asm compiler. Added Paths: ----------- branches/Release_2_3maint/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2008-08-19 14:04:16
|
Revision: 5202 http://jython.svn.sourceforge.net/jython/?rev=5202&view=rev Author: fwierzbicki Date: 2008-08-19 14:04:14 +0000 (Tue, 19 Aug 2008) Log Message: ----------- Big cleanup -- reduced imaginary nodes and return values. Modified Paths: -------------- trunk/sandbox/wierzbicki/backup/Python.g Modified: trunk/sandbox/wierzbicki/backup/Python.g =================================================================== --- trunk/sandbox/wierzbicki/backup/Python.g 2008-08-19 03:41:01 UTC (rev 5201) +++ trunk/sandbox/wierzbicki/backup/Python.g 2008-08-19 14:04:14 UTC (rev 5202) @@ -75,73 +75,31 @@ INDENT; DEDENT; - ModuleTok; + PYNODE; Interactive; Expression; - ExprTok; - NameTok; Test; - Msg; - Level; Body; - Bases; - FunctionDefTok; - ArgumentsTok; - Args; Arg; - Keyword; - StarArgs; - KWArgs; - AssignTok; AugAssign; - TupleTok; - ListTok; Dict; IfExp; - TryExcept; - TryFinally; - ExceptHandler; - StrTok; - NumTok; - Type; - Inst; - Tback; - Globals; - Locals; Ellipsis; ListComp; Repr; - Subscript; Index; Target; - Value; - Lower; - Upper; Step; - UAdd; - USub; - Invert; - Alias; - Asname; - Decorators; GeneratorExp; Ifs; Elts; - CallTok; - Dest; - Values; - Newline; - FpList; StepOp; - UpperOp; GenFor; GenIf; ListFor; ListIf; - Parens; - Brackets; } @@ -337,8 +295,8 @@ //file_input: (NEWLINE | stmt)* ENDMARKER file_input - : (NEWLINE | s+=stmt)+ -> ^(ModuleTok<Module>[$file_input.start, actions.makeStmts($s)]) - | -> ^(ModuleTok<Module>[$file_input.start, new stmtType[0\]]) + : (NEWLINE | s+=stmt)+ -> ^(PYNODE<Module>[$file_input.start, actions.makeStmts($s)]) + | -> ^(PYNODE<Module>[$file_input.start, new stmtType[0\]]) ; //eval_input: testlist NEWLINE* ENDMARKER @@ -468,7 +426,7 @@ //fpdef: NAME | '(' fplist ')' fpdef[expr_contextType ctype] : NAME - -> ^(NameTok<Name>[$NAME, $NAME.text, ctype]) + -> ^(PYNODE<Name>[$NAME, $NAME.text, ctype]) | (LPAREN fpdef[expr_contextType.Load] COMMA) => LPAREN fplist RPAREN -> fplist | LPAREN fplist RPAREN @@ -522,10 +480,10 @@ ) |(testlist[expr_contextType.Load] ASSIGN) => lhs=testlist[expr_contextType.Store] ( - | ((at=ASSIGN t+=testlist[expr_contextType.Store])+ -> ^(AssignTok<Assign>[$at, actions.makeAssignTargets((exprType)$lhs.tree, $t), actions.makeAssignValue($t)])) - | ((ay=ASSIGN y2+=yield_expr)+ -> ^(AssignTok<Assign>[$ay, actions.makeAssignTargets((exprType)$lhs.tree, $y2), actions.makeAssignValue($y2)])) + | ((at=ASSIGN t+=testlist[expr_contextType.Store])+ -> ^(PYNODE<Assign>[$at, actions.makeAssignTargets((exprType)$lhs.tree, $t), actions.makeAssignValue($t)])) + | ((ay=ASSIGN y2+=yield_expr)+ -> ^(PYNODE<Assign>[$ay, actions.makeAssignTargets((exprType)$lhs.tree, $y2), actions.makeAssignValue($y2)])) ) - | lhs=testlist[expr_contextType.Load] -> ExprTok<Expr>[$lhs.start, (exprType)$lhs.tree] + | lhs=testlist[expr_contextType.Load] -> PYNODE<Expr>[$lhs.start, (exprType)$lhs.tree] ) ; @@ -630,7 +588,7 @@ ; //yield_stmt: yield_expr -yield_stmt : yield_expr -> ^(ExprTok<Expr>[$yield_expr.start, (exprType)$yield_expr.tree]) +yield_stmt : yield_expr -> ^(PYNODE<Expr>[$yield_expr.start, (exprType)$yield_expr.tree]) ; //raise_stmt: 'raise' [test [',' test [',' test]]] @@ -706,12 +664,15 @@ ; //exec_stmt: 'exec' expr ['in' test [',' test]] -exec_stmt returns [stmtType stype] +exec_stmt +@init { + stmtType stype = null; +} @after { - $exec_stmt.tree = $stype; + $exec_stmt.tree = stype; } : EXEC expr[expr_contextType.Load] (IN t1=test[expr_contextType.Load] (COMMA t2=test[expr_contextType.Load])?)? { - $stype = new Exec($expr.start, (exprType)$expr.tree, (exprType)$t1.tree, (exprType)$t2.tree); + stype = new Exec($expr.start, (exprType)$expr.tree, (exprType)$t1.tree, (exprType)$t2.tree); } ; @@ -741,22 +702,28 @@ ; //while_stmt: 'while' test ':' suite ['else' ':' suite] -while_stmt returns [stmtType stype] +while_stmt +@init { + stmtType stype = null; +} @after { - $while_stmt.tree = $stype; + $while_stmt.tree = stype; } : WHILE test[expr_contextType.Load] COLON s1=suite (ORELSE COLON s2=suite)? { - $stype = actions.makeWhile($WHILE, (exprType)$test.tree, $s1.stmts, $s2.stmts); + stype = actions.makeWhile($WHILE, (exprType)$test.tree, $s1.stmts, $s2.stmts); } ; //for_stmt: 'for' exprlist 'in' testlist ':' suite ['else' ':' suite] -for_stmt returns [stmtType stype] +for_stmt +@init { + stmtType stype = null; +} @after { - $for_stmt.tree = $stype; + $for_stmt.tree = stype; } : FOR exprlist[expr_contextType.Store] IN testlist[expr_contextType.Load] COLON s1=suite (ORELSE COLON s2=suite)? { - $stype = actions.makeFor($FOR, $exprlist.etype, (exprType)$testlist.tree, $s1.stmts, $s2.stmts); + stype = actions.makeFor($FOR, $exprlist.etype, (exprType)$testlist.tree, $s1.stmts, $s2.stmts); } ; @@ -765,27 +732,33 @@ // ['else' ':' suite] // ['finally' ':' suite] | // 'finally' ':' suite)) -try_stmt returns [stmtType stype] +try_stmt +@init { + stmtType stype = null; +} @after { - $try_stmt.tree = $stype; + $try_stmt.tree = stype; } : TRY COLON trysuite=suite ( e+=except_clause+ (ORELSE COLON elsesuite=suite)? (FINALLY COLON finalsuite=suite)? { - $stype = actions.makeTryExcept($TRY, $trysuite.stmts, $e, $elsesuite.stmts, $finalsuite.stmts); + stype = actions.makeTryExcept($TRY, $trysuite.stmts, $e, $elsesuite.stmts, $finalsuite.stmts); } | FINALLY COLON finalsuite=suite { - $stype = actions.makeTryFinally($TRY, $trysuite.stmts, $finalsuite.stmts); + stype = actions.makeTryFinally($TRY, $trysuite.stmts, $finalsuite.stmts); } ) ; //with_stmt: 'with' test [ with_var ] ':' suite -with_stmt returns [stmtType stype] +with_stmt +@init { + stmtType stype = null; +} @after { - $with_stmt.tree = $stype; + $with_stmt.tree = stype; } :WITH test[expr_contextType.Load] (with_var)? COLON suite { - $stype = new With($WITH, (exprType)$test.tree, $with_var.etype, actions.makeStmts($suite.stmts)); + stype = new With($WITH, (exprType)$test.tree, $with_var.etype, actions.makeStmts($suite.stmts)); } ; @@ -1049,7 +1022,7 @@ atom : LPAREN ( yield_expr -> yield_expr | testlist_gexp -> testlist_gexp - | -> ^(TupleTok<Tuple>[$LPAREN, new exprType[0\], $expr::ctype]) + | -> ^(PYNODE<Tuple>[$LPAREN, new exprType[0\], $expr::ctype]) ) RPAREN | LBRACK @@ -1059,13 +1032,13 @@ RBRACK | LCURLY (dictmaker)? RCURLY -> ^(Dict LCURLY ^(Elts dictmaker)?) | BACKQUOTE testlist[expr_contextType.Load] BACKQUOTE -> ^(Repr BACKQUOTE testlist) - | NAME -> ^(NameTok<Name>[$NAME, $NAME.text, $expr::ctype]) - | INT -> ^(NumTok<Num>[$INT, actions.makeInt($INT)]) - | LONGINT -> ^(NumTok<Num>[$LONGINT, actions.makeInt($LONGINT)]) - | FLOAT -> ^(NumTok<Num>[$FLOAT, actions.makeFloat($FLOAT)]) - | COMPLEX -> ^(NumTok<Num>[$COMPLEX, actions.makeComplex($COMPLEX)]) + | NAME -> ^(PYNODE<Name>[$NAME, $NAME.text, $expr::ctype]) + | INT -> ^(PYNODE<Num>[$INT, actions.makeInt($INT)]) + | LONGINT -> ^(PYNODE<Num>[$LONGINT, actions.makeInt($LONGINT)]) + | FLOAT -> ^(PYNODE<Num>[$FLOAT, actions.makeFloat($FLOAT)]) + | COMPLEX -> ^(PYNODE<Num>[$COMPLEX, actions.makeComplex($COMPLEX)]) | (S+=STRING)+ - -> ^(StrTok<Str>[actions.extractStringToken($S), actions.extractStrings($S)]) + -> ^(PYNODE<Str>[actions.extractStringToken($S), actions.extractStrings($S)]) ; //listmaker: test ( list_for | (',' test)* [','] ) @@ -1085,7 +1058,7 @@ testlist_gexp : t+=test[expr_contextType.Load] ( ((options {k=2;}: c1=COMMA t+=test[expr_contextType.Load])* (c2=COMMA)? - -> { $c1 != null || $c2 != null }? ^(TupleTok<Tuple>[$testlist_gexp.start, actions.makeExprs($t), $expr::ctype]) + -> { $c1 != null || $c2 != null }? ^(PYNODE<Tuple>[$testlist_gexp.start, actions.makeExprs($t), $expr::ctype]) -> test ) | ( gen_for -> ^(GeneratorExp test gen_for) @@ -1158,7 +1131,7 @@ | (COLON) => c2=COLON (upper2=test[expr_contextType.Load])? (sliceop)? { $sltype = actions.makeSubscript(null, $c2, $upper2.tree, $sliceop.tree); } - | test[expr_contextType.Load] -> ^(Subscript<Index>[$test.start, (exprType)$test.tree]) + | test[expr_contextType.Load] -> ^(PYNODE<Index>[$test.start, (exprType)$test.tree]) ; //sliceop: ':' [test] @@ -1205,12 +1178,15 @@ ; //classdef: 'class' NAME ['(' [testlist] ')'] ':' suite -classdef returns [stmtType stype] +classdef +@init { + stmtType stype = null; +} @after { - $classdef.tree = $stype; + $classdef.tree = stype; } :CLASS NAME (LPAREN testlist[expr_contextType.Load]? RPAREN)? COLON suite { - $stype = new ClassDef($CLASS, $NAME.getText(), actions.makeBases($testlist.etype), actions.makeStmts($suite.stmts)); + stype = new ClassDef($CLASS, $NAME.getText(), actions.makeBases($testlist.etype), actions.makeStmts($suite.stmts)); } ; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2008-08-19 03:41:03
|
Revision: 5201 http://jython.svn.sourceforge.net/jython/?rev=5201&view=rev Author: fwierzbicki Date: 2008-08-19 03:41:01 +0000 (Tue, 19 Aug 2008) Log Message: ----------- make augassign work. Modified Paths: -------------- trunk/sandbox/wierzbicki/backup/Python.g Modified: trunk/sandbox/wierzbicki/backup/Python.g =================================================================== --- trunk/sandbox/wierzbicki/backup/Python.g 2008-08-19 03:21:51 UTC (rev 5200) +++ trunk/sandbox/wierzbicki/backup/Python.g 2008-08-19 03:41:01 UTC (rev 5201) @@ -157,6 +157,7 @@ import org.python.antlr.ast.Assert; import org.python.antlr.ast.Assign; import org.python.antlr.ast.Attribute; +import org.python.antlr.ast.AugAssign; import org.python.antlr.ast.BinOp; import org.python.antlr.ast.BoolOp; import org.python.antlr.ast.boolopType; @@ -504,32 +505,46 @@ //expr_stmt: testlist (augassign (yield_expr|testlist) | // ('=' (yield_expr|testlist))*) -expr_stmt : ((testlist[expr_contextType.Load] (ASSIGN|augassign)) => lhs=testlist[expr_contextType.Store] - | lhs=testlist[expr_contextType.Load] - ) - ( (augassign yield_expr -> ^(augassign $lhs yield_expr)) - | (augassign rhs=testlist[expr_contextType.Load] -> ^(augassign $lhs $rhs)) - | ((at=ASSIGN t+=testlist[expr_contextType.Store])+ -> ^(AssignTok<Assign>[$at, actions.makeAssignTargets((exprType)$lhs.tree, $t), actions.makeAssignValue($t)])) - | ((ay=ASSIGN y+=yield_expr)+ -> ^(AssignTok<Assign>[$ay, actions.makeAssignTargets((exprType)$lhs.tree, $y), actions.makeAssignValue($y)])) - | -> ExprTok<Expr>[$lhs.start, (exprType)$lhs.tree] - ) - ; +expr_stmt +@init { + stmtType stype = null; +} +@after { + if (stype != null) { + $expr_stmt.tree = stype; + } +} + : + ((testlist[expr_contextType.Load] augassign) => lhs=testlist[expr_contextType.AugStore] + ( (aay=augassign y1=yield_expr {stype = new AugAssign($lhs.tree, (exprType)$lhs.tree, $aay.op, (exprType)$y1.tree);}) + | (aat=augassign rhs=testlist[expr_contextType.Load] {stype = new AugAssign($lhs.tree, (exprType)$lhs.tree, $aat.op, (exprType)$rhs.tree);}) + ) + |(testlist[expr_contextType.Load] ASSIGN) => lhs=testlist[expr_contextType.Store] + ( + | ((at=ASSIGN t+=testlist[expr_contextType.Store])+ -> ^(AssignTok<Assign>[$at, actions.makeAssignTargets((exprType)$lhs.tree, $t), actions.makeAssignValue($t)])) + | ((ay=ASSIGN y2+=yield_expr)+ -> ^(AssignTok<Assign>[$ay, actions.makeAssignTargets((exprType)$lhs.tree, $y2), actions.makeAssignValue($y2)])) + ) + | lhs=testlist[expr_contextType.Load] -> ExprTok<Expr>[$lhs.start, (exprType)$lhs.tree] + ) + ; + //augassign: ('+=' | '-=' | '*=' | '/=' | '%=' | '&=' | '|=' | '^=' | // '<<=' | '>>=' | '**=' | '//=') -augassign : PLUSEQUAL - | MINUSEQUAL - | STAREQUAL - | SLASHEQUAL - | PERCENTEQUAL - | AMPEREQUAL - | VBAREQUAL - | CIRCUMFLEXEQUAL - | LEFTSHIFTEQUAL - | RIGHTSHIFTEQUAL - | DOUBLESTAREQUAL - | DOUBLESLASHEQUAL - ; +augassign returns [operatorType op] + : PLUSEQUAL {$op = operatorType.Add;} + | MINUSEQUAL {$op = operatorType.Sub;} + | STAREQUAL {$op = operatorType.Mult;} + | SLASHEQUAL {$op = operatorType.Div;} + | PERCENTEQUAL {$op = operatorType.Mod;} + | AMPEREQUAL {$op = operatorType.BitAnd;} + | VBAREQUAL {$op = operatorType.BitOr;} + | CIRCUMFLEXEQUAL {$op = operatorType.BitXor;} + | LEFTSHIFTEQUAL {$op = operatorType.LShift;} + | RIGHTSHIFTEQUAL {$op = operatorType.RShift;} + | DOUBLESTAREQUAL {$op = operatorType.Pow;} + | DOUBLESLASHEQUAL {$op = operatorType.FloorDiv;} + ; //print_stmt: 'print' ( [ test (',' test)* [','] ] | // '>>' test [ (',' test)+ [','] ] ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2008-08-19 03:21:54
|
Revision: 5200 http://jython.svn.sourceforge.net/jython/?rev=5200&view=rev Author: fwierzbicki Date: 2008-08-19 03:21:51 +0000 (Tue, 19 Aug 2008) Log Message: ----------- factor comp_op back out. Modified Paths: -------------- trunk/sandbox/wierzbicki/backup/Python.g Modified: trunk/sandbox/wierzbicki/backup/Python.g =================================================================== --- trunk/sandbox/wierzbicki/backup/Python.g 2008-08-19 03:11:13 UTC (rev 5199) +++ trunk/sandbox/wierzbicki/backup/Python.g 2008-08-19 03:21:51 UTC (rev 5200) @@ -879,35 +879,26 @@ } } : left=expr[ctype] - ( ( LESS right+=expr[ctype] {cmps.add(cmpopType.Lt);} - |GREATER right+=expr[ctype] {cmps.add(cmpopType.Gt);} - |EQUAL right+=expr[ctype] {cmps.add(cmpopType.Eq);} - |GREATEREQUAL right+=expr[ctype] {cmps.add(cmpopType.GtE);} - |LESSEQUAL right+=expr[ctype] {cmps.add(cmpopType.LtE);} - |ALT_NOTEQUAL right+=expr[ctype] {cmps.add(cmpopType.NotEq);} - |NOTEQUAL right+=expr[ctype] {cmps.add(cmpopType.NotEq);} - |IN right+=expr[ctype] {cmps.add(cmpopType.In);} - |IS right+=expr[ctype] {cmps.add(cmpopType.Is);} - |NOT IN right+=expr[ctype] {cmps.add(cmpopType.NotIn);} - |IS NOT right+=expr[ctype] {cmps.add(cmpopType.IsNot);} + ( ( comp_op right+=expr[ctype] {cmps.add($comp_op.op);} )+ | -> $left ) ; //comp_op: '<'|'>'|'=='|'>='|'<='|'<>'|'!='|'in'|'not' 'in'|'is'|'is' 'not' -comp_op : LESS - | GREATER - | EQUAL - | GREATEREQUAL - | LESSEQUAL - | ALT_NOTEQUAL - | NOTEQUAL - | IN -// | NOT IN -> NotIn - | IS -// | IS NOT -> IsNot - ; +comp_op returns [cmpopType op] + : LESS {$op = cmpopType.Lt;} + | GREATER {$op = cmpopType.Gt;} + | EQUAL {$op = cmpopType.Eq;} + | GREATEREQUAL {$op = cmpopType.GtE;} + | LESSEQUAL {$op = cmpopType.LtE;} + | ALT_NOTEQUAL {$op = cmpopType.NotEq;} + | NOTEQUAL {$op = cmpopType.NotEq;} + | IN {$op = cmpopType.In;} + | NOT IN {$op = cmpopType.NotIn;} + | IS {$op = cmpopType.Is;} + | IS NOT {$op = cmpopType.IsNot;} + ; //expr: xor_expr ('|' xor_expr)* This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2008-08-19 03:11:15
|
Revision: 5199 http://jython.svn.sourceforge.net/jython/?rev=5199&view=rev Author: fwierzbicki Date: 2008-08-19 03:11:13 +0000 (Tue, 19 Aug 2008) Log Message: ----------- Compare works better -- grammar is approaching usefullness. Modified Paths: -------------- trunk/sandbox/wierzbicki/backup/Python.g Modified: trunk/sandbox/wierzbicki/backup/Python.g =================================================================== --- trunk/sandbox/wierzbicki/backup/Python.g 2008-08-18 18:07:09 UTC (rev 5198) +++ trunk/sandbox/wierzbicki/backup/Python.g 2008-08-19 03:11:13 UTC (rev 5199) @@ -103,8 +103,6 @@ ExceptHandler; StrTok; NumTok; - IsNot; - NotIn; Type; Inst; Tback; @@ -144,6 +142,7 @@ ListIf; Parens; Brackets; + } @header { @@ -796,49 +795,7 @@ //test: or_test ['if' or_test 'else' test] | lambdef test[expr_contextType ctype] @after { - if ($test.tree instanceof Compare) { - Compare c = (Compare)$test.tree; - //FIXME: Only handling the case of a single comparison. - c.left = (exprType)c.getChild(0); - c.comparators = new exprType[]{(exprType)c.getChild(1)}; - switch (c.getType()) { - case LESS: - c.ops = new cmpopType[]{cmpopType.Lt}; - break; - case GREATER: - c.ops = new cmpopType[]{cmpopType.Gt}; - break; - case EQUAL: - c.ops = new cmpopType[]{cmpopType.Eq}; - break; - case GREATEREQUAL: - c.ops = new cmpopType[]{cmpopType.GtE}; - break; - case LESSEQUAL: - c.ops = new cmpopType[]{cmpopType.LtE}; - break; - case ALT_NOTEQUAL: - c.ops = new cmpopType[]{cmpopType.Eq}; - break; - case NOTEQUAL: - c.ops = new cmpopType[]{cmpopType.NotEq}; - break; - case IN: - c.ops = new cmpopType[]{cmpopType.In}; - break; - case NotIn: - c.ops = new cmpopType[]{cmpopType.NotIn}; - break; - case IS: - c.ops = new cmpopType[]{cmpopType.Is}; - break; - case IsNot: - c.ops = new cmpopType[]{cmpopType.IsNot}; - break; - default: - c.ops = new cmpopType[]{cmpopType.UNDEFINED}; - } - } else if ($test.tree instanceof BoolOp) { + if ($test.tree instanceof BoolOp) { BoolOp b = (BoolOp)$test.tree; List values = new ArrayList(); @@ -911,20 +868,31 @@ ; //comparison: expr (comp_op expr)* -comparison[expr_contextType ctype] //comp_op: '<'|'>'|'=='|'>='|'<='|'<>'|'!='|'in'|'not' 'in'|'is'|'is' 'not' - : expr[ctype] (LESS<Compare>^ expr[ctype] - |GREATER<Compare>^ expr[ctype] - |EQUAL<Compare>^ expr[ctype] - |GREATEREQUAL<Compare>^ expr[ctype] - |LESSEQUAL<Compare>^ expr[ctype] - |ALT_NOTEQUAL<Compare>^ expr[ctype] - |NOTEQUAL<Compare>^ expr[ctype] - |IN<Compare>^ expr[ctype] - //|NotIn<Compare>^ exper[ctype] - |IS<Compare>^ expr[ctype] - //|IsNot<Compare>^ exper[ctype] - )* +comparison[expr_contextType ctype] +@init { + List cmps = new ArrayList(); +} +@after { + if (!cmps.isEmpty()) { + $comparison.tree = new Compare($left.tree, (exprType)$left.tree, actions.makeCmpOps(cmps), actions.makeExprs($right)); + } +} + : left=expr[ctype] + ( ( LESS right+=expr[ctype] {cmps.add(cmpopType.Lt);} + |GREATER right+=expr[ctype] {cmps.add(cmpopType.Gt);} + |EQUAL right+=expr[ctype] {cmps.add(cmpopType.Eq);} + |GREATEREQUAL right+=expr[ctype] {cmps.add(cmpopType.GtE);} + |LESSEQUAL right+=expr[ctype] {cmps.add(cmpopType.LtE);} + |ALT_NOTEQUAL right+=expr[ctype] {cmps.add(cmpopType.NotEq);} + |NOTEQUAL right+=expr[ctype] {cmps.add(cmpopType.NotEq);} + |IN right+=expr[ctype] {cmps.add(cmpopType.In);} + |IS right+=expr[ctype] {cmps.add(cmpopType.Is);} + |NOT IN right+=expr[ctype] {cmps.add(cmpopType.NotIn);} + |IS NOT right+=expr[ctype] {cmps.add(cmpopType.IsNot);} + )+ + | -> $left + ) ; //comp_op: '<'|'>'|'=='|'>='|'<='|'<>'|'!='|'in'|'not' 'in'|'is'|'is' 'not' @@ -936,11 +904,12 @@ | ALT_NOTEQUAL | NOTEQUAL | IN - | NOT IN -> NotIn +// | NOT IN -> NotIn | IS - | IS NOT -> IsNot +// | IS NOT -> IsNot ; + //expr: xor_expr ('|' xor_expr)* expr[expr_contextType ect] scope { @@ -1079,7 +1048,7 @@ RPAREN | LBRACK (listmaker -> listmaker - | -> ^(Brackets LBRACK ^(ListTok)) + | -> ^(LBRACK<org.python.antlr.ast.List>[$LBRACK, new exprType[0\], $expr::ctype]) ) RBRACK | LCURLY (dictmaker)? RCURLY -> ^(Dict LCURLY ^(Elts dictmaker)?) @@ -1129,7 +1098,7 @@ ) RPAREN | LBRACK s=subscriptlist RBRACK -> $s - | DOT attr -> ^(DOT<Attribute>[$DOT, null, $attr.text, expr_contextType.Load]) + | DOT attr -> ^(DOT<Attribute>[$DOT, null, $attr.text, $expr::ctype]) ; //subscriptlist: subscript (',' subscript)* [','] @@ -1177,11 +1146,11 @@ } } : DOT DOT DOT -> Ellipsis - | (test[expr_contextType.Load] COLON) => lower=test[expr_contextType.Load] (c1=COLON (upper=test[expr_contextType.Load])? (sliceop)?)? { - $sltype = actions.makeSubscript($lower.tree, $c1, $upper.tree, $sliceop.tree); + | (test[expr_contextType.Load] COLON) => lower=test[expr_contextType.Load] (c1=COLON (upper1=test[expr_contextType.Load])? (sliceop)?)? { + $sltype = actions.makeSubscript($lower.tree, $c1, $upper1.tree, $sliceop.tree); } - | (COLON) => c2=COLON (test[expr_contextType.Load])? (sliceop)? { - $sltype = actions.makeSubscript(null, $c2, $upper.tree, $sliceop.tree); + | (COLON) => c2=COLON (upper2=test[expr_contextType.Load])? (sliceop)? { + $sltype = actions.makeSubscript(null, $c2, $upper2.tree, $sliceop.tree); } | test[expr_contextType.Load] -> ^(Subscript<Index>[$test.start, (exprType)$test.tree]) ; @@ -1209,6 +1178,9 @@ //testlist: test (',' test)* [','] testlist[expr_contextType ctype] returns [exprType etype] +@after { + $testlist.tree = $etype; +} : (test[expr_contextType.Load] COMMA) => t+=test[ctype] (options {k=2;}: c1=COMMA t+=test[ctype])* (c2=COMMA)? { $etype = new Tuple($testlist.start, actions.makeExprs($t), ctype); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2008-08-18 18:07:14
|
Revision: 5198 http://jython.svn.sourceforge.net/jython/?rev=5198&view=rev Author: fwierzbicki Date: 2008-08-18 18:07:09 +0000 (Mon, 18 Aug 2008) Log Message: ----------- merge with latest + lots of work on trailer rules. Modified Paths: -------------- trunk/sandbox/wierzbicki/backup/Python.g Modified: trunk/sandbox/wierzbicki/backup/Python.g =================================================================== --- trunk/sandbox/wierzbicki/backup/Python.g 2008-08-18 14:46:22 UTC (rev 5197) +++ trunk/sandbox/wierzbicki/backup/Python.g 2008-08-18 18:07:09 UTC (rev 5198) @@ -56,16 +56,13 @@ * REQUIRES ANTLR v3 * * - * Baby step towards an antlr based Jython parser. - * Terence's Lexer is intact pretty much unchanged, the parser has - * been altered to produce an AST - the AST work started from tne newcompiler - * grammar from Jim Baker minus post-2.3 features. The current parsing - * and compiling strategy looks like this: + * Updated the original parser for Python 2.5 features. The parser has been + * altered to produce an AST - the AST work started from tne newcompiler + * grammar from Jim Baker. The current parsing and compiling strategy looks + * like this: * * Python source->Python.g->simple antlr AST->PythonWalker.g-> * decorated AST (org/python/parser/ast/*)->CodeCompiler(ASM)->.class - * - * for a very limited set of functionality. */ grammar Python; @@ -162,6 +159,8 @@ import org.python.antlr.ast.Assign; import org.python.antlr.ast.Attribute; import org.python.antlr.ast.BinOp; +import org.python.antlr.ast.BoolOp; +import org.python.antlr.ast.boolopType; import org.python.antlr.ast.Break; import org.python.antlr.ast.Call; import org.python.antlr.ast.ClassDef; @@ -195,6 +194,7 @@ import org.python.antlr.ast.Raise; import org.python.antlr.ast.operatorType; import org.python.antlr.ast.Return; +import org.python.antlr.ast.Slice; import org.python.antlr.ast.sliceType; import org.python.antlr.ast.stmtType; import org.python.antlr.ast.Str; @@ -202,8 +202,11 @@ import org.python.antlr.ast.TryExcept; import org.python.antlr.ast.TryFinally; import org.python.antlr.ast.Tuple; +import org.python.antlr.ast.unaryopType; +import org.python.antlr.ast.UnaryOp; import org.python.antlr.ast.While; import org.python.antlr.ast.With; +import org.python.antlr.ast.Yield; import org.python.core.Py; import org.python.core.PyString; import org.python.core.PyUnicode; @@ -272,13 +275,17 @@ * 4] */ +//For use in partial parsing. +public boolean eofWhileNested = false; +public boolean partial = false; + +int implicitLineJoiningLevel = 0; +int startPos=-1; + //If you want to use another error recovery mechanisms change this //and the same one in the parser. private ErrorHandler errorHandler; -int implicitLineJoiningLevel = 0; -int startPos=-1; - public void setErrorHandler(ErrorHandler eh) { this.errorHandler = eh; } @@ -297,6 +304,9 @@ state.tokenStartLine = input.getLine(); state.text = null; if ( input.LA(1)==CharStream.EOF ) { + if (implicitLineJoiningLevel > 0) { + eofWhileNested = true; + } return Token.EOF_TOKEN; } try { @@ -320,9 +330,9 @@ } //single_input: NEWLINE | simple_stmt | compound_stmt NEWLINE -single_input : NEWLINE? -> ^(Interactive) - | simple_stmt -> ^(Interactive simple_stmt) - | compound_stmt NEWLINE -> ^(Interactive compound_stmt) +single_input : NEWLINE* EOF -> ^(Interactive) + | simple_stmt NEWLINE* EOF -> ^(Interactive simple_stmt) + | compound_stmt NEWLINE+ EOF -> ^(Interactive compound_stmt) ; //file_input: (NEWLINE | stmt)* ENDMARKER @@ -332,7 +342,7 @@ ; //eval_input: testlist NEWLINE* ENDMARKER -eval_input : (NEWLINE)* testlist[expr_contextType.Load] (NEWLINE)* -> ^(Expression testlist) +eval_input : LEADING_WS? (NEWLINE)* testlist[expr_contextType.Load] (NEWLINE)* EOF -> ^(Expression testlist) ; //not in CPython's Grammar file @@ -606,7 +616,7 @@ ; //yield_stmt: yield_expr -yield_stmt : yield_expr +yield_stmt : yield_expr -> ^(ExprTok<Expr>[$yield_expr.start, (exprType)$yield_expr.tree]) ; //raise_stmt: 'raise' [test [',' test [',' test]]] @@ -631,14 +641,14 @@ -> ^(FROM<ImportFrom>[$FROM, actions.makeFromText($d, $dotted_name.text), actions.makeStarAlias($STAR), actions.makeLevel($d)]) | i1=import_as_names -> ^(FROM<ImportFrom>[$FROM, actions.makeFromText($d, $dotted_name.text), actions.makeAliases($i1.atypes), actions.makeLevel($d)]) - | LPAREN i2=import_as_names RPAREN + | LPAREN i2=import_as_names COMMA? RPAREN -> ^(FROM<ImportFrom>[$FROM, actions.makeFromText($d, $dotted_name.text), actions.makeAliases($i2.atypes), actions.makeLevel($d)]) ) ; //import_as_names: import_as_name (',' import_as_name)* [','] import_as_names returns [aliasType[\] atypes] - : n+=import_as_name (COMMA! n+=import_as_name)* (COMMA!)? { + : n+=import_as_name (COMMA! n+=import_as_name)* { $atypes = (aliasType[])$n.toArray(new aliasType[$n.size()]); } ; @@ -732,7 +742,7 @@ $for_stmt.tree = $stype; } : FOR exprlist[expr_contextType.Store] IN testlist[expr_contextType.Load] COLON s1=suite (ORELSE COLON s2=suite)? { - $stype = actions.makeFor($FOR, $exprlist.etype, (exprType)$testlist.tree, $s2.stmts, $s2.stmts); + $stype = actions.makeFor($FOR, $exprlist.etype, (exprType)$testlist.tree, $s1.stmts, $s2.stmts); } ; @@ -779,42 +789,17 @@ //suite: simple_stmt | NEWLINE INDENT stmt+ DEDENT suite returns [List stmts] - : s+=simple_stmt {$stmts = $s;} + : ss+=simple_stmt {$stmts = $ss;} | NEWLINE! INDENT (s+=stmt)+ DEDENT {$stmts = $s;} ; //test: or_test ['if' or_test 'else' test] | lambdef test[expr_contextType ctype] - :o1=or_test[ctype] - ( (IF or_test[expr_contextType.Load] ORELSE) => IF o2=or_test[ctype] ORELSE test[expr_contextType.Load] - -> ^(IfExp ^(Test $o2) ^(Body $o1) ^(ORELSE test)) - | -> or_test - ) - | lambdef {debug("parsed lambdef");} - ; - -//or_test: and_test ('or' and_test)* -or_test[expr_contextType ctype] : and_test[ctype] (OR^ and_test[ctype])* - ; - -//and_test: not_test ('and' not_test)* -and_test[expr_contextType ctype] : not_test[ctype] (AND^ not_test[ctype])* - ; - -//not_test: 'not' not_test | comparison -not_test[expr_contextType ctype] : NOT^ not_test[ctype] - | comparison[ctype] - ; - -//comparison: expr (comp_op expr)* -comparison[expr_contextType ctype] @after { - if ($comparison.tree instanceof Compare) { - System.out.println("found Compare"); - Compare c = (Compare)$comparison.tree; + if ($test.tree instanceof Compare) { + Compare c = (Compare)$test.tree; //FIXME: Only handling the case of a single comparison. c.left = (exprType)c.getChild(0); - System.out.println("c.left:" + c.left); c.comparators = new exprType[]{(exprType)c.getChild(1)}; switch (c.getType()) { case LESS: @@ -853,8 +838,80 @@ default: c.ops = new cmpopType[]{cmpopType.UNDEFINED}; } + } else if ($test.tree instanceof BoolOp) { + BoolOp b = (BoolOp)$test.tree; + List values = new ArrayList(); + + exprType left = (exprType)b.getChild(0); + exprType right = (exprType)b.getChild(1); + + exprType[] e; + if (left.getType() == b.getType() && right.getType() == b.getType()) { + BoolOp leftB = (BoolOp)left; + BoolOp rightB = (BoolOp)right; + int lenL = leftB.values.length; + int lenR = rightB.values.length; + e = new exprType[lenL + lenR]; + System.arraycopy(leftB.values, 0, e, 0, lenL - 1); + System.arraycopy(rightB.values, 0, e, lenL - 1, lenL + lenR); + } else if (left.getType() == b.getType()) { + BoolOp leftB = (BoolOp)left; + e = new exprType[leftB.values.length + 1]; + System.arraycopy(leftB.values, 0, e, 0, leftB.values.length); + e[e.length - 1] = right; + } else if (right.getType() == b.getType()) { + BoolOp rightB = (BoolOp)right; + e = new exprType[rightB.values.length + 1]; + System.arraycopy(rightB.values, 0, e, 0, rightB.values.length); + e[e.length - 1] = left; + } else { + e = new exprType[2]; + e[0] = left; + e[1] = right; + } + b.values = e; + switch (b.getType()) { + case AND: + b.op = boolopType.And; + break; + case OR: + b.op = boolopType.Or; + break; + default: + b.op = boolopType.UNDEFINED; + } } } + + :o1=or_test[ctype] + ( (IF or_test[expr_contextType.Load] ORELSE) => IF o2=or_test[ctype] ORELSE test[expr_contextType.Load] + -> ^(IfExp ^(Test $o2) ^(Body $o1) ^(ORELSE test)) + | -> or_test + ) + | lambdef {debug("parsed lambdef");} + ; + +//or_test: and_test ('or' and_test)* +or_test[expr_contextType ctype] : and_test[ctype] (OR<BoolOp>^ and_test[ctype])* + ; + +//and_test: not_test ('and' not_test)* +and_test[expr_contextType ctype] : not_test[ctype] (AND<BoolOp>^ not_test[ctype])* + ; + +//not_test: 'not' not_test | comparison +not_test[expr_contextType ctype] returns [exprType etype] +@after { + if ($etype != null) { + $not_test.tree = $etype; + } +} + : NOT nt=not_test[ctype] {$etype = new UnaryOp($NOT, unaryopType.Not, (exprType)$nt.tree);} + | comparison[ctype] + ; + +//comparison: expr (comp_op expr)* +comparison[expr_contextType ctype] //comp_op: '<'|'>'|'=='|'>='|'<='|'<>'|'!='|'in'|'not' 'in'|'is'|'is' 'not' : expr[ctype] (LESS<Compare>^ expr[ctype] |GREATER<Compare>^ expr[ctype] @@ -904,22 +961,52 @@ case MINUS: b.op = operatorType.Sub; break; + case STAR: + b.op = operatorType.Mult; + break; + case SLASH: + b.op = operatorType.Div; + break; + case PERCENT: + b.op = operatorType.Mod; + break; + case DOUBLESLASH: + b.op = operatorType.FloorDiv; + break; + case AMPER: + b.op = operatorType.BitAnd; + break; + case VBAR: + b.op = operatorType.BitOr; + break; + case CIRCUMFLEX: + b.op = operatorType.BitXor; + break; + case LEFTSHIFT: + b.op = operatorType.LShift; + break; + case RIGHTSHIFT: + b.op = operatorType.RShift; + break; + case DOUBLESTAR: + b.op = operatorType.Pow; + break; } } } - : xor_expr (VBAR^ xor_expr)* + : xor_expr (VBAR<BinOp>^ xor_expr)* ; //xor_expr: and_expr ('^' and_expr)* -xor_expr : and_expr (CIRCUMFLEX^ and_expr)* +xor_expr : and_expr (CIRCUMFLEX<BinOp>^ and_expr)* ; //and_expr: shift_expr ('&' shift_expr)* -and_expr : shift_expr (AMPER^ shift_expr)* +and_expr : shift_expr (AMPER<BinOp>^ shift_expr)* ; //shift_expr: arith_expr (('<<'|'>>') arith_expr)* -shift_expr : arith_expr ((LEFTSHIFT^|RIGHTSHIFT^) arith_expr)* +shift_expr : arith_expr ((LEFTSHIFT<BinOp>^|RIGHTSHIFT<BinOp>^) arith_expr)* ; //arith_expr: term (('+'|'-') term)* @@ -929,15 +1016,19 @@ ; //term: factor (('*'|'/'|'%'|'//') factor)* -term : factor ((STAR^ | SLASH^ | PERCENT^ | DOUBLESLASH^ ) factor)* +term : factor ((STAR<BinOp>^ | SLASH<BinOp>^ | PERCENT<BinOp>^ | DOUBLESLASH<BinOp>^ ) factor)* ; //factor: ('+'|'-'|'~') factor | power -factor : PLUS factor -> ^(UAdd PLUS factor) - | MINUS factor -> ^(USub MINUS factor) - | TILDE factor -> ^(Invert TILDE factor) - | power - ; +factor returns [exprType etype] +@after { + $factor.tree = $etype; +} + : PLUS p=factor {$etype = new UnaryOp($PLUS, unaryopType.UAdd, $p.etype);} + | MINUS m=factor {$etype = actions.negate($MINUS, $m.etype);} + | TILDE t=factor {$etype = new UnaryOp($TILDE, unaryopType.Invert, $t.etype);} + | power {$etype = (exprType)$power.tree;} + ; //power: atom trailer* ['**' factor] power returns [exprType etype] @@ -949,8 +1040,12 @@ : atom (t+=trailer)* (options {greedy=true;}:DOUBLESTAR factor)? { if ($t != null) { exprType current = (exprType)$atom.tree; - for(int i = $t.size() - 1; i > -1; i--) { + //for(int i = $t.size() - 1; i > -1; i--) { + for(int i = 0; i < $t.size(); i++) { Object o = $t.get(i); + if (current instanceof Context) { + ((Context)current).setContext(expr_contextType.Load); + } //XXX: good place for an interface to avoid all of this instanceof if (o instanceof Call) { Call c = (Call)o; @@ -960,6 +1055,10 @@ Subscript c = (Subscript)o; c.value = current; current = c; + } else if (o instanceof Attribute) { + Attribute c = (Attribute)o; + c.value = current; + current = c; } } $etype = (exprType)current; @@ -973,7 +1072,7 @@ // '`' testlist1 '`' | // NAME | NUMBER | STRING+) atom : LPAREN - ( yield_expr -> ^(Parens LPAREN yield_expr) + ( yield_expr -> yield_expr | testlist_gexp -> testlist_gexp | -> ^(TupleTok<Tuple>[$LPAREN, new exprType[0\], $expr::ctype]) ) @@ -1030,10 +1129,11 @@ ) RPAREN | LBRACK s=subscriptlist RBRACK -> $s - | DOT^ attr {debug("motched DOT^ NAME");} + | DOT attr -> ^(DOT<Attribute>[$DOT, null, $attr.text, expr_contextType.Load]) ; //subscriptlist: subscript (',' subscript)* [','] +//FIXME: tuples not always created when commas are present. subscriptlist returns [exprType etype] @after { $subscriptlist.tree = $etype; @@ -1070,11 +1170,21 @@ ; //subscript: '.' '.' '.' | test | [test] ':' [test] [sliceop] -subscript : DOT DOT DOT -> Ellipsis - | (test[expr_contextType.Load] COLON) => t1=test[expr_contextType.Load] (COLON (t2=test[expr_contextType.Load])? (sliceop)?)? -> ^(Subscript ^(Lower $t1) ^(Upper COLON ^(UpperOp $t2)?)? sliceop?) - | (COLON) => COLON (test[expr_contextType.Load])? (sliceop)? -> ^(Subscript ^(Upper COLON ^(UpperOp test)?)? sliceop?) - | test[expr_contextType.Load] -> ^(Subscript<Index>[$test.start, (exprType)$test.tree]) - ; +subscript returns [sliceType sltype] +@after { + if ($sltype != null) { + $subscript.tree = $sltype; + } +} + : DOT DOT DOT -> Ellipsis + | (test[expr_contextType.Load] COLON) => lower=test[expr_contextType.Load] (c1=COLON (upper=test[expr_contextType.Load])? (sliceop)?)? { + $sltype = actions.makeSubscript($lower.tree, $c1, $upper.tree, $sliceop.tree); + } + | (COLON) => c2=COLON (test[expr_contextType.Load])? (sliceop)? { + $sltype = actions.makeSubscript(null, $c2, $upper.tree, $sliceop.tree); + } + | test[expr_contextType.Load] -> ^(Subscript<Index>[$test.start, (exprType)$test.tree]) + ; //sliceop: ':' [test] sliceop : COLON (test[expr_contextType.Load])? -> ^(Step COLON ^(StepOp test)?) @@ -1195,7 +1305,7 @@ //yield_expr: 'yield' [testlist] yield_expr : YIELD testlist[expr_contextType.Load]? - -> ^(YIELD ^(Value testlist)?) + -> ^(YIELD<Yield>[$YIELD, $testlist.etype]) ; //XXX: @@ -1377,6 +1487,13 @@ } ; +STRINGPART + : {partial}?=> ('r'|'u'|'ur'|'R'|'U'|'UR'|'uR'|'Ur')? + ( '\'\'\'' ~('\'\'\'')* + | '"""' ~('"""')* + ) + ; + /** the two '"'? cause a warning -- is there a way to avoid that? */ fragment TRIQUOTE This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nr...@us...> - 2008-08-18 14:46:25
|
Revision: 5197 http://jython.svn.sourceforge.net/jython/?rev=5197&view=rev Author: nriley Date: 2008-08-18 14:46:22 +0000 (Mon, 18 Aug 2008) Log Message: ----------- Run Jython regrtest (on unix) with bytecode verification. Modified Paths: -------------- branches/asm/build.xml Modified: branches/asm/build.xml =================================================================== --- branches/asm/build.xml 2008-08-18 07:17:46 UTC (rev 5196) +++ branches/asm/build.xml 2008-08-18 14:46:22 UTC (rev 5197) @@ -766,6 +766,7 @@ <target name="regrtest" depends="developer-build,regrtest-unix,regrtest-windows"/> <target name="regrtest-unix" if="os.family.unix"> <exec executable="${dist.dir}/bin/jython"> + <arg value="--verify"/> <arg value="${dist.dir}/Lib/test/regrtest.py"/> <!-- Only run the tests that are expected to work on Jython --> <arg value="--expected"/> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |