From: <fwi...@us...> - 2009-08-13 02:50:10
|
Revision: 6665 http://jython.svn.sourceforge.net/jython/?rev=6665&view=rev Author: fwierzbicki Date: 2009-08-13 02:49:57 +0000 (Thu, 13 Aug 2009) Log Message: ----------- Adjusted BinOp lineno and col_offset to align better with CPython. Modified Paths: -------------- trunk/jython/grammar/Python.g trunk/jython/src/org/python/antlr/GrammarActions.java Modified: trunk/jython/grammar/Python.g =================================================================== --- trunk/jython/grammar/Python.g 2009-08-13 01:54:15 UTC (rev 6664) +++ trunk/jython/grammar/Python.g 2009-08-13 02:49:57 UTC (rev 6665) @@ -1180,16 +1180,18 @@ shift_expr @init { List ops = new ArrayList(); + List toks = new ArrayList(); } @after { if (!ops.isEmpty()) { - $shift_expr.tree = actions.makeBinOp($left.tree, ops, $right); + $shift_expr.tree = actions.makeBinOp($left.tree, ops, $right, toks); } } : left=arith_expr ( ( shift_op right+=arith_expr { ops.add($shift_op.op); + toks.add($shift_op.start); } )+ | @@ -1209,16 +1211,18 @@ arith_expr @init { List ops = new ArrayList(); + List toks = new ArrayList(); } @after { if (!ops.isEmpty()) { - $arith_expr.tree = actions.makeBinOp($left.tree, ops, $right); + $arith_expr.tree = actions.makeBinOp($left.tree, ops, $right, toks); } } : left=term ( (arith_op right+=term { ops.add($arith_op.op); + toks.add($arith_op.start); } )+ | @@ -1246,16 +1250,18 @@ term @init { List ops = new ArrayList(); + List toks = new ArrayList(); } @after { if (!ops.isEmpty()) { - $term.tree = actions.makeBinOp($left.tree, ops, $right); + $term.tree = actions.makeBinOp($left.tree, ops, $right, toks); } } : left=factor ( (term_op right+=factor { ops.add($term_op.op); + toks.add($term_op.start); } )+ | Modified: trunk/jython/src/org/python/antlr/GrammarActions.java =================================================================== --- trunk/jython/src/org/python/antlr/GrammarActions.java 2009-08-13 01:54:15 UTC (rev 6664) +++ trunk/jython/src/org/python/antlr/GrammarActions.java 2009-08-13 02:49:57 UTC (rev 6665) @@ -658,12 +658,12 @@ return current; } - BinOp makeBinOp(PythonTree left, List ops, List rights) { + BinOp makeBinOp(PythonTree left, List ops, List rights, List toks) { BinOp current = new BinOp(left, castExpr(left), (operatorType)ops.get(0), castExpr(rights.get(0))); for (int i = 1; i< rights.size(); i++) { expr right = castExpr(rights.get(i)); operatorType op = (operatorType)ops.get(i); - current = new BinOp(left, current, op, right); + current = new BinOp((Token)toks.get(i), current, op, right); } return current; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |