From: <fwi...@us...> - 2009-01-04 17:35:49
|
Revision: 5840 http://jython.svn.sourceforge.net/jython/?rev=5840&view=rev Author: fwierzbicki Date: 2009-01-04 17:35:44 +0000 (Sun, 04 Jan 2009) Log Message: ----------- Handle cases where the entire tree ends up as an error. Only comes up with alternate ErrorHandlers. Modified Paths: -------------- trunk/jython/grammar/Python.g Modified: trunk/jython/grammar/Python.g =================================================================== --- trunk/jython/grammar/Python.g 2009-01-04 08:41:16 UTC (rev 5839) +++ trunk/jython/grammar/Python.g 2009-01-04 17:35:44 UTC (rev 5840) @@ -103,6 +103,7 @@ import org.python.antlr.ast.Delete; import org.python.antlr.ast.Dict; import org.python.antlr.ast.Ellipsis; +import org.python.antlr.ast.ErrorMod; import org.python.antlr.ast.ExceptHandler; import org.python.antlr.ast.Exec; import org.python.antlr.ast.Expr; @@ -289,6 +290,13 @@ mtype = new Interactive($single_input.start, actions.castStmts($compound_stmt.tree)); } ; + //XXX: this block is duplicated in three places, how to extract? + catch [RecognitionException re] { + errorHandler.reportError(this, re); + errorHandler.recover(this, input,re); + PythonTree badNode = (PythonTree)adaptor.errorNode(input, retval.start, input.LT(-1), re); + retval.tree = new ErrorMod(badNode); + } //file_input: (NEWLINE | stmt)* ENDMARKER file_input @@ -318,7 +326,15 @@ mtype = new Module($file_input.start, actions.castStmts(stypes)); } ; + //XXX: this block is duplicated in three places, how to extract? + catch [RecognitionException re] { + errorHandler.reportError(this, re); + errorHandler.recover(this, input,re); + PythonTree badNode = (PythonTree)adaptor.errorNode(input, retval.start, input.LT(-1), re); + retval.tree = new ErrorMod(badNode); + } + //eval_input: testlist NEWLINE* ENDMARKER eval_input @init { @@ -331,7 +347,15 @@ mtype = new Expression($eval_input.start, actions.castExpr($testlist.tree)); } ; + //XXX: this block is duplicated in three places, how to extract? + catch [RecognitionException re] { + errorHandler.reportError(this, re); + errorHandler.recover(this, input,re); + PythonTree badNode = (PythonTree)adaptor.errorNode(input, retval.start, input.LT(-1), re); + retval.tree = new ErrorMod(badNode); + } + //not in CPython's Grammar file dotted_attr returns [expr etype] : n1=NAME This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |