From: <fwi...@us...> - 2008-09-06 04:28:13
|
Revision: 5292 http://jython.svn.sourceforge.net/jython/?rev=5292&view=rev Author: fwierzbicki Date: 2008-09-06 04:28:11 +0000 (Sat, 06 Sep 2008) Log Message: ----------- Some tuning of node col and line positions to align better with CPython. Modified Paths: -------------- trunk/jython/ast/astview.py trunk/jython/grammar/Python.g trunk/jython/src/org/python/antlr/GrammarActions.java Modified: trunk/jython/ast/astview.py =================================================================== --- trunk/jython/ast/astview.py 2008-09-05 16:30:36 UTC (rev 5291) +++ trunk/jython/ast/astview.py 2008-09-06 04:28:11 UTC (rev 5292) @@ -25,6 +25,10 @@ "org.python.antlr.ast.cmpopType", "org.python.antlr.ast.operatorType"): result = str(t) + if result == "AugLoad": + result = "Load" + elif result == "AugStore": + result = "Store" else: result = result.split(".")[-1] if result.endswith("Type"): Modified: trunk/jython/grammar/Python.g =================================================================== --- trunk/jython/grammar/Python.g 2008-09-05 16:30:36 UTC (rev 5291) +++ trunk/jython/grammar/Python.g 2008-09-06 04:28:11 UTC (rev 5292) @@ -806,7 +806,7 @@ //not in CPython's Grammar file elif_clause : ELIF test[expr_contextType.Load] COLON suite - -> ^(ELIF<If>[$ELIF, (exprType)$test.tree, actions.makeStmts($suite.stypes), new stmtType[0\]]) + -> ^(ELIF<If>[$test.start, (exprType)$test.tree, actions.makeStmts($suite.stypes), new stmtType[0\]]) ; //while_stmt: 'while' test ':' suite ['else' ':' suite] @@ -913,7 +913,7 @@ test[expr_contextType ctype] :o1=or_test[ctype] ( (IF or_test[null] ORELSE) => IF o2=or_test[ctype] ORELSE e=test[expr_contextType.Load] - -> ^(IF<IfExp>[$IF, (exprType)$o2.tree, (exprType)$o1.tree, (exprType)$e.tree]) + -> ^(IF<IfExp>[$o1.start, (exprType)$o2.tree, (exprType)$o1.tree, (exprType)$e.tree]) | -> or_test ) @@ -964,7 +964,7 @@ } @after { if (!cmps.isEmpty()) { - $comparison.tree = new Compare($left.tree, (exprType)$left.tree, actions.makeCmpOps(cmps), + $comparison.tree = new Compare($left.start, (exprType)$left.tree, actions.makeCmpOps(cmps), actions.makeExprs($right)); } } @@ -1136,8 +1136,7 @@ //XXX: This could be better. $etype = (exprType)$atom.tree; if ($t != null) { - for(int i = 0; i < $t.size(); i++) { - Object o = $t.get(i); + for(Object o : $t) { if ($etype instanceof Context) { ((Context)$etype).setContext(expr_contextType.Load); } @@ -1249,7 +1248,7 @@ ( ((options {k=2;}: c1=COMMA t+=test[$expr::ctype])* (c2=COMMA)? -> { $c1 != null || $c2 != null }? ^(COMMA<Tuple>[$testlist_gexp.start, actions.makeExprs($t), $expr::ctype]) - -> test + -> test ) | (gen_for[gens] { @@ -1290,7 +1289,7 @@ -> ^(LPAREN<Call>[$begin, (exprType)$tree, actions.makeExprs($arglist.args), actions.makeKeywords($arglist.keywords), $arglist.starargs, $arglist.kwargs]) | - -> ^(LPAREN<Call>[$LPAREN, (exprType)$tree, new exprType[0\], new keywordType[0\], null, null]) + -> ^(LPAREN<Call>[$begin, (exprType)$tree, new exprType[0\], new keywordType[0\], null, null]) ) RPAREN | LBRACK subscriptlist[$begin] RBRACK @@ -1447,7 +1446,7 @@ $genarg = true; Collections.reverse($gens); comprehensionType[] c = (comprehensionType[])$gens.toArray(new comprehensionType[$gens.size()]); - arguments.add(new GeneratorExp($gen_for.start, (exprType)$t1.tree, c)); + arguments.add(new GeneratorExp($t1.start, (exprType)$t1.tree, c)); } | { if (kws.size() > 0) { Modified: trunk/jython/src/org/python/antlr/GrammarActions.java =================================================================== --- trunk/jython/src/org/python/antlr/GrammarActions.java 2008-09-05 16:30:36 UTC (rev 5291) +++ trunk/jython/src/org/python/antlr/GrammarActions.java 2008-09-06 04:28:11 UTC (rev 5292) @@ -459,7 +459,8 @@ } Token extractStringToken(List s) { - return (Token)s.get(s.size() - 1); + return (Token)s.get(0); + //return (Token)s.get(s.size() - 1); } //FROM Walker: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |