From: <fwi...@us...> - 2009-01-15 03:14:39
|
Revision: 5933 http://jython.svn.sourceforge.net/jython/?rev=5933&view=rev Author: fwierzbicki Date: 2009-01-15 03:14:36 +0000 (Thu, 15 Jan 2009) Log Message: ----------- Merged revisions 5925,5927,5930-5932 via svnmerge from https://jython.svn.sourceforge.net/svnroot/jython/trunk/jython ........ r5925 | cgroves | 2009-01-13 17:10:24 -0500 (Tue, 13 Jan 2009) | 1 line Allow importation from bytecode in a zip file even if the source isn't present ........ r5927 | fwierzbicki | 2009-01-13 22:42:42 -0500 (Tue, 13 Jan 2009) | 4 lines Small fix to grammar -- a "print" by itself should have it's NL attribute set to true as CPython does. Because "false" doesn't make sense in this context (it would be a no-op), the compiler doesn't check, so it passed unnoticed. ........ r5930 | fwierzbicki | 2009-01-14 09:09:58 -0500 (Wed, 14 Jan 2009) | 3 lines oops, move back to _ast since I want to compare with Python 2.5 which does not yet have ast.py. ........ r5931 | fwierzbicki | 2009-01-14 18:56:22 -0500 (Wed, 14 Jan 2009) | 2 lines DEDENT problem with comments in single mode fixed. ........ r5932 | fwierzbicki | 2009-01-14 21:04:31 -0500 (Wed, 14 Jan 2009) | 2 lines Small change to obsessively match CPython AST. ........ Modified Paths: -------------- trunk/sandbox/wierzbicki/grammar26/Lib/test/test_codeop_jy.py trunk/sandbox/wierzbicki/grammar26/ast/astview.py trunk/sandbox/wierzbicki/grammar26/grammar/Python.g trunk/sandbox/wierzbicki/grammar26/src/org/python/antlr/PythonTokenSource.java trunk/sandbox/wierzbicki/grammar26/src/org/python/modules/zipimport/zipimporter.java Property Changed: ---------------- trunk/sandbox/wierzbicki/grammar26/ Property changes on: trunk/sandbox/wierzbicki/grammar26 ___________________________________________________________________ Modified: svnmerge-integrated - /trunk/jython:1-5923 + /trunk/jython:1-5932 Modified: trunk/sandbox/wierzbicki/grammar26/Lib/test/test_codeop_jy.py =================================================================== --- trunk/sandbox/wierzbicki/grammar26/Lib/test/test_codeop_jy.py 2009-01-15 02:04:31 UTC (rev 5932) +++ trunk/sandbox/wierzbicki/grammar26/Lib/test/test_codeop_jy.py 2009-01-15 03:14:36 UTC (rev 5933) @@ -102,6 +102,8 @@ # Failed for Jython 2.5a2. See http://bugs.jython.org/issue1116. av("@a.b.c\ndef f():\n pass") + av("def f():\n pass\n#foo") + def test_incomplete(self): ai = self.assertIncomplete Modified: trunk/sandbox/wierzbicki/grammar26/ast/astview.py =================================================================== --- trunk/sandbox/wierzbicki/grammar26/ast/astview.py 2009-01-15 02:04:31 UTC (rev 5932) +++ trunk/sandbox/wierzbicki/grammar26/ast/astview.py 2009-01-15 03:14:36 UTC (rev 5933) @@ -10,7 +10,7 @@ """ -import ast +import _ast import sys if sys.platform.startswith('java'): @@ -49,7 +49,7 @@ children = [child] for node in children: - if isinstance(node, ast.AST): + if isinstance(node, _ast.AST): yield lispify_ast(node) else: if isinstance(node, float): @@ -64,7 +64,7 @@ def tree(pyfile): try: - node = compile(open(pyfile).read(), pyfile, "exec", ast.PyCF_ONLY_AST) + node = compile(open(pyfile).read(), pyfile, "exec", _ast.PyCF_ONLY_AST) except SyntaxError: return "SyntaxError", return lispify_ast(node) Modified: trunk/sandbox/wierzbicki/grammar26/grammar/Python.g =================================================================== --- trunk/sandbox/wierzbicki/grammar26/grammar/Python.g 2009-01-15 02:04:31 UTC (rev 5932) +++ trunk/sandbox/wierzbicki/grammar26/grammar/Python.g 2009-01-15 03:14:36 UTC (rev 5933) @@ -624,7 +624,7 @@ | RIGHTSHIFT t2=printlist2 -> ^(PRINT<Print>[$PRINT, actions.castExpr($t2.elts.get(0)), actions.castExprs($t2.elts, 1), $t2.newline]) | - -> ^(PRINT<Print>[$PRINT, null, new ArrayList<expr>(), false]) + -> ^(PRINT<Print>[$PRINT, null, new ArrayList<expr>(), true]) ) ; @@ -1412,9 +1412,9 @@ //sliceop: ':' [test] sliceop : COLON - (test[expr_contextType.Load] - -> test - )? + (test[expr_contextType.Load] -> test + |-> ^(COLON<Name>[$COLON, "None", expr_contextType.Load]) + ) ; //exprlist: expr (',' expr)* [','] Modified: trunk/sandbox/wierzbicki/grammar26/src/org/python/antlr/PythonTokenSource.java =================================================================== --- trunk/sandbox/wierzbicki/grammar26/src/org/python/antlr/PythonTokenSource.java 2009-01-15 02:04:31 UTC (rev 5932) +++ trunk/sandbox/wierzbicki/grammar26/src/org/python/antlr/PythonTokenSource.java 2009-01-15 03:14:36 UTC (rev 5933) @@ -195,7 +195,7 @@ t = stream.LT(1); stream.consume(); - enqueueHiddens(t); + List<Token> commentedNewlines = enqueueHiddens(t); // compute cpos as the char pos of next non-WS token in line int cpos = t.getCharPositionInLine(); // column dictates indent/dedent @@ -230,6 +230,9 @@ for(int i=1;i<newlines.length();i++) { generateNewline(newline); } + for (Token c : commentedNewlines) { + generateNewline(c); + } } if (t.getType() != PythonLexer.LEADING_WS) { // discard WS @@ -246,7 +249,8 @@ tokens.addElement(t); } - private void enqueueHiddens(Token t) { + private List<Token> enqueueHiddens(Token t) { + List<Token> newlines = new ArrayList<Token>(); if (inSingle && t.getType() == Token.EOF) { if (stream.size() > lastTokenAddedIndex + 1) { Token hidden = stream.get(lastTokenAddedIndex + 1); @@ -254,7 +258,7 @@ String text = hidden.getText(); int i = text.indexOf("\n"); while(i != -1) { - generateNewline(hidden); + newlines.add(hidden); i = text.indexOf("\n", i + 1); } } @@ -265,6 +269,7 @@ tokens.addAll(hiddenTokens); } lastTokenAddedIndex = t.getTokenIndex(); + return newlines; } private void handleIndents(int cpos, CommonToken t) { Modified: trunk/sandbox/wierzbicki/grammar26/src/org/python/modules/zipimport/zipimporter.java =================================================================== --- trunk/sandbox/wierzbicki/grammar26/src/org/python/modules/zipimport/zipimporter.java 2009-01-15 02:04:31 UTC (rev 5932) +++ trunk/sandbox/wierzbicki/grammar26/src/org/python/modules/zipimport/zipimporter.java 2009-01-15 03:14:36 UTC (rev 5933) @@ -315,7 +315,7 @@ String sourcePath = path.substring(0, path.length() - 9) + ".py"; PyObject sourceTocEntry = files.__finditem__(sourcePath); if (sourceTocEntry == null) { - return false; + return true;// If there is no source, assume the bytecode is ok } try { long bytecodeTime = dosTimeToEpoch(tocEntry.__finditem__(5).asInt(0), This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |