|
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.
|
|
From: <pj...@us...> - 2008-11-07 05:27:34
|
Revision: 5554
http://jython.svn.sourceforge.net/jython/?rev=5554&view=rev
Author: pjenvey
Date: 2008-11-07 05:27:30 +0000 (Fri, 07 Nov 2008)
Log Message:
-----------
clarify comments
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-11-07 01:48:27 UTC (rev 5553)
+++ trunk/jython/src/org/python/antlr/GrammarActions.java 2008-11-07 05:27:30 UTC (rev 5554)
@@ -437,7 +437,9 @@
String string = t.getText();
char quoteChar = string.charAt(0);
int start = 0;
+ int end;
boolean ustring = false;
+
if (quoteChar == 'u' || quoteChar == 'U') {
ustring = true;
start++;
@@ -456,28 +458,27 @@
quotes = 1;
}
+ start = quotes + start;
+ end = string.length() - quotes;
// string is properly decoded according to the source encoding
- String result;
- int end = string.length() - quotes;
- start = quotes + start;
// XXX: No need to re-encode when the encoding is iso-8859-1, but ParserFacade
// needs to normalize the encoding name
if (!ustring && encoding != null) {
- // Plain strs with a specified encoding: First re-encode them back out
- result = new PyUnicode(string.substring(start, end)).encode(encoding);
+ // str with a specified encoding: first re-encode back out
+ string = new PyUnicode(string.substring(start, end)).encode(encoding);
if (!raw) {
// Handle escapes in non-raw strs
- result = PyString.decode_UnicodeEscape(result, 0, result.length(), "strict",
+ string = PyString.decode_UnicodeEscape(string, 0, string.length(), "strict",
ustring);
}
} else if (raw) {
- // Raw str/unicode without an encoding (ascii): simply passthru
- result = string.substring(start, end);
+ // Raw str without an encoding or raw unicode: simply passthru
+ string = string.substring(start, end);
} else {
// Plain unicode: already decoded, just handle escapes
- result = PyString.decode_UnicodeEscape(string, start, end, "strict", ustring);
+ string = PyString.decode_UnicodeEscape(string, start, end, "strict", ustring);
}
- return new StringPair(result, ustring);
+ return new StringPair(string, ustring);
}
Token extractStringToken(List s) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fwi...@us...> - 2008-12-23 19:56:56
|
Revision: 5795
http://jython.svn.sourceforge.net/jython/?rev=5795&view=rev
Author: fwierzbicki
Date: 2008-12-23 19:56:53 +0000 (Tue, 23 Dec 2008)
Log Message:
-----------
Fixed a direct cast to stmt in GrammarActions.
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-12-23 19:35:40 UTC (rev 5794)
+++ trunk/jython/src/org/python/antlr/GrammarActions.java 2008-12-23 19:56:53 UTC (rev 5795)
@@ -159,7 +159,7 @@
return new ArrayList<stmt>();
}
List <stmt> s = new ArrayList<stmt>();
- s.add((stmt)elif);
+ s.add(castStmt(elif));
return s;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fwi...@us...> - 2009-01-06 02:11:06
|
Revision: 5857
http://jython.svn.sourceforge.net/jython/?rev=5857&view=rev
Author: fwierzbicki
Date: 2009-01-06 02:11:04 +0000 (Tue, 06 Jan 2009)
Log Message:
-----------
Remove some unused methods.
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 2009-01-05 21:05:05 UTC (rev 5856)
+++ trunk/jython/src/org/python/antlr/GrammarActions.java 2009-01-06 02:11:04 UTC (rev 5857)
@@ -461,81 +461,6 @@
//return (Token)s.get(s.size() - 1);
}
- //FROM Walker:
- mod makeMod(PythonTree t, List stmts) {
- List<stmt> s = castStmts(stmts);
- return new Module(t, s);
- }
-
- mod makeExpression(PythonTree t, expr e) {
- return new Expression(t, e);
- }
-
- mod makeInteractive(PythonTree t, List stmts) {
- List<stmt> s = castStmts(stmts);
- return new Interactive(t, s);
- }
-
- stmt makeClassDef(PythonTree t, PythonTree nameToken, List bases, List body, List decorators) {
- if (nameToken == null) {
- return errorHandler.errorStmt(t);
- }
- cantBeNone(nameToken);
- List<expr> b = castExprs(bases);
- List<stmt> s = castStmts(body);
- List<expr> d = castExprs(decorators);
- return new ClassDef(t, nameToken.getText(), b, s, d);
- }
-
- stmt makeTryExcept(PythonTree t, List body, List handlers, List orelse, List finBody) {
- List<stmt> b = castStmts(body);
- List<excepthandler> e = handlers;
- List<stmt> o = castStmts(orelse);
-
- stmt te = new TryExcept(t, b, e, o);
- if (finBody == null) {
- return te;
- }
- List<stmt> f = castStmts(finBody);
- List<stmt> mainBody = new ArrayList<stmt>();
- mainBody.add(te);
- return new TryFinally(t, mainBody, f);
- }
-
- TryFinally makeTryFinally(PythonTree t, List body, List finBody) {
- List<stmt> b = castStmts(body);
- List<stmt> f = castStmts(finBody);
- return new TryFinally(t, b, f);
- }
-
- stmt makeIf(PythonTree t, expr test, List body, List orelse) {
- if (test == null) {
- return errorHandler.errorStmt(t);
- }
- List<stmt> o = castStmts(orelse);
- List<stmt> b = castStmts(body);
- return new If(t, test, b, o);
- }
-
- stmt makeWhile(PythonTree t, expr test, List body, List orelse) {
- if (test == null) {
- return errorHandler.errorStmt(t);
- }
- List<stmt> o = castStmts(orelse);
- List<stmt> b = castStmts(body);
- return new While(t, test, b, o);
- }
-
- stmt makeFor(PythonTree t, expr target, expr iter, List body, List orelse) {
- if (target == null || iter == null) {
- return errorHandler.errorStmt(t);
- }
- cantBeNone(target);
- List<stmt> o = castStmts(orelse);
- List<stmt> b = castStmts(body);
- return new For(t, target, iter, b, o);
- }
-
expr makeCall(Token t, expr func) {
return makeCall(t, func, null, null, null, null);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fwi...@us...> - 2009-01-15 03:36:13
|
Revision: 5934
http://jython.svn.sourceforge.net/jython/?rev=5934&view=rev
Author: fwierzbicki
Date: 2009-01-15 03:36:09 +0000 (Thu, 15 Jan 2009)
Log Message:
-----------
Change negate so that -0 and -0.0 behave as CPython behaves (no USub node, just
negate zero).
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 2009-01-15 03:14:36 UTC (rev 5933)
+++ trunk/jython/src/org/python/antlr/GrammarActions.java 2009-01-15 03:36:09 UTC (rev 5934)
@@ -483,7 +483,7 @@
Num num = (Num)o;
if (num.getInternalN() instanceof PyInteger) {
int v = ((PyInteger)num.getInternalN()).getValue();
- if (v > 0) {
+ if (v >= 0) {
num.setN(new PyInteger(-v));
return num;
}
@@ -495,13 +495,13 @@
}
} else if (num.getInternalN() instanceof PyFloat) {
double v = ((PyFloat)num.getInternalN()).getValue();
- if (v > 0) {
+ if (v >= 0) {
num.setN(new PyFloat(-v));
return num;
}
} else if (num.getInternalN() instanceof PyComplex) {
double v = ((PyComplex)num.getInternalN()).imag;
- if (v > 0) {
+ if (v >= 0) {
num.setN(new PyComplex(0,-v));
return num;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <pj...@us...> - 2009-05-29 05:29:15
|
Revision: 6421
http://jython.svn.sourceforge.net/jython/?rev=6421&view=rev
Author: pjenvey
Date: 2009-05-29 05:28:56 +0000 (Fri, 29 May 2009)
Log Message:
-----------
unused imports
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 2009-05-29 05:27:30 UTC (rev 6420)
+++ trunk/jython/src/org/python/antlr/GrammarActions.java 2009-05-29 05:28:56 UTC (rev 6421)
@@ -22,19 +22,14 @@
import org.python.antlr.ast.BinOp;
import org.python.antlr.ast.BoolOp;
import org.python.antlr.ast.Call;
-import org.python.antlr.ast.ClassDef;
-import org.python.antlr.ast.Expression;
import org.python.antlr.ast.ExtSlice;
import org.python.antlr.ast.For;
import org.python.antlr.ast.FunctionDef;
import org.python.antlr.ast.GeneratorExp;
-import org.python.antlr.ast.If;
import org.python.antlr.ast.IfExp;
import org.python.antlr.ast.Index;
-import org.python.antlr.ast.Interactive;
import org.python.antlr.ast.Lambda;
import org.python.antlr.ast.ListComp;
-import org.python.antlr.ast.Module;
import org.python.antlr.ast.Name;
import org.python.antlr.ast.Num;
import org.python.antlr.ast.Slice;
@@ -48,7 +43,6 @@
import org.python.antlr.ast.Yield;
import org.python.antlr.base.excepthandler;
import org.python.antlr.base.expr;
-import org.python.antlr.base.mod;
import org.python.antlr.base.slice;
import org.python.antlr.base.stmt;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|