From: <fwi...@us...> - 2009-07-27 20:39:19
|
Revision: 6594 http://jython.svn.sourceforge.net/jython/?rev=6594&view=rev Author: fwierzbicki Date: 2009-07-27 20:39:10 +0000 (Mon, 27 Jul 2009) Log Message: ----------- Now handling trailing backslashes in single mode more like CPython. Modified Paths: -------------- trunk/jython/Lib/test/test_codeop.py trunk/jython/grammar/PythonPartial.g Modified: trunk/jython/Lib/test/test_codeop.py =================================================================== --- trunk/jython/Lib/test/test_codeop.py 2009-07-27 19:30:01 UTC (rev 6593) +++ trunk/jython/Lib/test/test_codeop.py 2009-07-27 20:39:10 UTC (rev 6594) @@ -168,9 +168,9 @@ ai("\n\n if 1: pass\n\npass") - #ai("a = 9+ \\\n") + ai("a = 9+ \\\n") ai("a = 'a\\ ") - #ai("a = 'a\\\n") + ai("a = 'a\\\n") ai("a = 1","eval") #ai("a = (","eval") Modified: trunk/jython/grammar/PythonPartial.g =================================================================== --- trunk/jython/grammar/PythonPartial.g 2009-07-27 19:30:01 UTC (rev 6593) +++ trunk/jython/grammar/PythonPartial.g 2009-07-27 20:39:10 UTC (rev 6594) @@ -1085,12 +1085,21 @@ * emit a newline. */ CONTINUED_LINE +@init { + boolean extraNewlines = false; +} : '\\' ('\r')? '\n' (' '|'\t')* { $channel=HIDDEN; } ( COMMENT | nl=NEWLINE + { + extraNewlines = true; + } | ) { if (input.LA(1) == -1) { + if (extraNewlines) { + throw new ParseException("invalid syntax"); + } emit(new CommonToken(TRAILBACKSLASH,"\\")); } } @@ -1103,10 +1112,7 @@ * Frank Wierzbicki added: Also ignore FORMFEEDS (\u000C). */ NEWLINE -@init { - int newlines = 0; -} - : (('\u000C')?('\r')? '\n' {newlines++; } )+ { + : (('\u000C')?('\r')? '\n' )+ { if ( startPos==0 || implicitLineJoiningLevel>0 ) $channel=HIDDEN; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |