From: <fwi...@us...> - 2008-09-11 20:18:46
|
Revision: 5321 http://jython.svn.sourceforge.net/jython/?rev=5321&view=rev Author: fwierzbicki Date: 2008-09-11 20:18:43 +0000 (Thu, 11 Sep 2008) Log Message: ----------- Allow the possibility of using error nodes for bad stmtType. Modified Paths: -------------- trunk/jython/src/org/python/antlr/GrammarActions.java Modified: trunk/jython/src/org/python/antlr/GrammarActions.java =================================================================== --- trunk/jython/src/org/python/antlr/GrammarActions.java 2008-09-11 19:48:35 UTC (rev 5320) +++ trunk/jython/src/org/python/antlr/GrammarActions.java 2008-09-11 20:18:43 UTC (rev 5321) @@ -191,6 +191,17 @@ return new stmtType[]{(stmtType)elif}; } + stmtType makeStmt(Object o) { + if (o instanceof stmtType) { + return (stmtType)o; + } else if (o instanceof PythonParser.stmt_return) { + return (stmtType)((PythonParser.stmt_return)o).tree; + } else if (o instanceof PythonTree) { + return errorHandler.errorStmt((PythonTree)o); + } + return null; + } + stmtType[] makeStmts(PythonTree t) { return new stmtType[]{(stmtType)t}; } @@ -198,18 +209,8 @@ stmtType[] makeStmts(List stmts) { if (stmts != null) { List<stmtType> result = new ArrayList<stmtType>(); - for (int i=0; i<stmts.size(); i++) { - Object o = stmts.get(i); - if (o instanceof stmtType) { - result.add((stmtType)o); - } else if (o instanceof PythonTree) { - PythonTree t = (PythonTree)o; - for (int j=0; j<t.getChildCount(); j++) { - result.add((stmtType)t.getChild(i)); - } - } else { - result.add((stmtType)((PythonParser.stmt_return)o).tree); - } + for (Object o:stmts) { + result.add(makeStmt(o)); } return (stmtType[])result.toArray(new stmtType[result.size()]); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |