From: <pj...@us...> - 2008-07-17 21:25:49
|
Revision: 4966 http://jython.svn.sourceforge.net/jython/?rev=4966&view=rev Author: pjenvey Date: 2008-07-17 21:25:44 +0000 (Thu, 17 Jul 2008) Log Message: ----------- fix loading of 0L in cPickle proto 2 and match cPickle's dumps(0L, 2) to pickle's Modified Paths: -------------- trunk/jython/src/org/python/modules/cPickle.java Added Paths: ----------- trunk/jython/Lib/test/test_cpickle_jy.py Added: trunk/jython/Lib/test/test_cpickle_jy.py =================================================================== --- trunk/jython/Lib/test/test_cpickle_jy.py (rev 0) +++ trunk/jython/Lib/test/test_cpickle_jy.py 2008-07-17 21:25:44 UTC (rev 4966) @@ -0,0 +1,22 @@ +"""Misc cPickle tests. + +Made for Jython. +""" +import cPickle +import pickle +import unittest +from test import test_support + +class CPickleTestCase(unittest.TestCase): + + def test_zero_long(self): + self.assertEqual(cPickle.loads(cPickle.dumps(0L, 2)), 0L) + self.assertEqual(cPickle.dumps(0L, 2), pickle.dumps(0L, 2)) + + +def test_main(): + test_support.run_unittest(CPickleTestCase) + + +if __name__ == '__main__': + test_main() Modified: trunk/jython/src/org/python/modules/cPickle.java =================================================================== --- trunk/jython/src/org/python/modules/cPickle.java 2008-07-17 21:19:56 UTC (rev 4965) +++ trunk/jython/src/org/python/modules/cPickle.java 2008-07-17 21:25:44 UTC (rev 4966) @@ -1163,9 +1163,17 @@ private void save_long(PyObject object) { if(protocol >= 2) { BigInteger integer = ((PyLong)object).getValue(); + + if (integer.compareTo(BigInteger.ZERO) == 0) { + // It's 0 -- an empty bytestring. + file.write(LONG1); + file.write((char)0); + return; + } + byte[] bytes = integer.toByteArray(); int l = bytes.length; - if(l < 256) { + if (l < 256) { file.write(LONG1); file.write((char)l); } else { @@ -1938,6 +1946,10 @@ private void load_bin_long(int length) { int longLength = read_binint(length); + if (longLength == 0) { + push(new PyLong(BigInteger.ZERO)); + return; + } String s = file.read(longLength); byte[] bytes = new byte[s.length()]; // Write to the byte array in reverse order: pickle orders This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2008-07-21 02:00:41
|
Revision: 4978 http://jython.svn.sourceforge.net/jython/?rev=4978&view=rev Author: pjenvey Date: 2008-07-21 01:59:47 +0000 (Mon, 21 Jul 2008) Log Message: ----------- fix __finditem__(int) not trying subclasses' __getitem__ if the parent overrode it (like PySequence does) Modified Paths: -------------- trunk/jython/src/org/python/core/PyArrayDerived.java trunk/jython/src/org/python/core/PyBooleanDerived.java trunk/jython/src/org/python/core/PyClassMethodDerived.java trunk/jython/src/org/python/core/PyComplexDerived.java trunk/jython/src/org/python/core/PyDictionaryDerived.java trunk/jython/src/org/python/core/PyEnumerateDerived.java trunk/jython/src/org/python/core/PyFileDerived.java trunk/jython/src/org/python/core/PyFloatDerived.java trunk/jython/src/org/python/core/PyFrozenSetDerived.java trunk/jython/src/org/python/core/PyIntegerDerived.java trunk/jython/src/org/python/core/PyListDerived.java trunk/jython/src/org/python/core/PyLongDerived.java trunk/jython/src/org/python/core/PyModuleDerived.java trunk/jython/src/org/python/core/PyObjectDerived.java trunk/jython/src/org/python/core/PyPropertyDerived.java trunk/jython/src/org/python/core/PySetDerived.java trunk/jython/src/org/python/core/PySliceDerived.java trunk/jython/src/org/python/core/PyStringDerived.java trunk/jython/src/org/python/core/PySuperDerived.java trunk/jython/src/org/python/core/PyTupleDerived.java trunk/jython/src/org/python/core/PyTypeDerived.java trunk/jython/src/org/python/core/PyUnicodeDerived.java trunk/jython/src/org/python/modules/_weakref/ReferenceTypeDerived.java trunk/jython/src/org/python/modules/collections/PyDefaultDictDerived.java trunk/jython/src/org/python/modules/collections/PyDequeDerived.java trunk/jython/src/org/python/modules/random/PyRandomDerived.java trunk/jython/src/org/python/modules/thread/PyLocalDerived.java trunk/jython/src/org/python/modules/zipimport/zipimporterDerived.java trunk/jython/src/templates/object.derived Added Paths: ----------- trunk/jython/Lib/test/test_iter_jy.py Added: trunk/jython/Lib/test/test_iter_jy.py =================================================================== --- trunk/jython/Lib/test/test_iter_jy.py (rev 0) +++ trunk/jython/Lib/test/test_iter_jy.py 2008-07-21 01:59:47 UTC (rev 4978) @@ -0,0 +1,32 @@ +"""Misc iterator tests. + +Made for Jython. +""" +import test_support +import unittest + +class IterTestCase(unittest.TestCase): + + def test_fastiter(self): + class MyList(list): + def __getitem__(self, index): + return str(index) + '!' + class MyTuple(tuple): + def __getitem__(self, index): + return str(index) + '!' + self.assertEqual(iter(MyList(['a', 'b'])).next(), 'a') + self.assertEqual(iter(MyTuple(['a', 'b'])).next(), 'a') + + def test_slowiter(self): + class MyStr(str): + def __getitem__(self, index): + return str(index) + '!' + self.assertEqual(iter(MyStr('ab')).next(), '0!') + + +def test_main(): + test_support.run_unittest(IterTestCase) + + +if __name__ == '__main__': + test_main() Modified: trunk/jython/src/org/python/core/PyArrayDerived.java =================================================================== --- trunk/jython/src/org/python/core/PyArrayDerived.java 2008-07-21 01:43:14 UTC (rev 4977) +++ trunk/jython/src/org/python/core/PyArrayDerived.java 2008-07-21 01:59:47 UTC (rev 4978) @@ -791,6 +791,20 @@ return super.__finditem__(key); } + public PyObject __finditem__(int key) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__getitem__"); + if (impl!=null) + try { + return impl.__get__(this,self_type).__call__(new PyInteger(key)); + } catch (PyException exc) { + if (Py.matchException(exc,Py.LookupError)) + return null; + throw exc; + } + return super.__finditem__(key); + } + public PyObject __getitem__(PyObject key) { // Same as __finditem__, without swallowing LookupErrors. This allows // __getitem__ implementations written in Python to raise custom Modified: trunk/jython/src/org/python/core/PyBooleanDerived.java =================================================================== --- trunk/jython/src/org/python/core/PyBooleanDerived.java 2008-07-21 01:43:14 UTC (rev 4977) +++ trunk/jython/src/org/python/core/PyBooleanDerived.java 2008-07-21 01:59:47 UTC (rev 4978) @@ -791,6 +791,20 @@ return super.__finditem__(key); } + public PyObject __finditem__(int key) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__getitem__"); + if (impl!=null) + try { + return impl.__get__(this,self_type).__call__(new PyInteger(key)); + } catch (PyException exc) { + if (Py.matchException(exc,Py.LookupError)) + return null; + throw exc; + } + return super.__finditem__(key); + } + public PyObject __getitem__(PyObject key) { // Same as __finditem__, without swallowing LookupErrors. This allows // __getitem__ implementations written in Python to raise custom Modified: trunk/jython/src/org/python/core/PyClassMethodDerived.java =================================================================== --- trunk/jython/src/org/python/core/PyClassMethodDerived.java 2008-07-21 01:43:14 UTC (rev 4977) +++ trunk/jython/src/org/python/core/PyClassMethodDerived.java 2008-07-21 01:59:47 UTC (rev 4978) @@ -791,6 +791,20 @@ return super.__finditem__(key); } + public PyObject __finditem__(int key) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__getitem__"); + if (impl!=null) + try { + return impl.__get__(this,self_type).__call__(new PyInteger(key)); + } catch (PyException exc) { + if (Py.matchException(exc,Py.LookupError)) + return null; + throw exc; + } + return super.__finditem__(key); + } + public PyObject __getitem__(PyObject key) { // Same as __finditem__, without swallowing LookupErrors. This allows // __getitem__ implementations written in Python to raise custom Modified: trunk/jython/src/org/python/core/PyComplexDerived.java =================================================================== --- trunk/jython/src/org/python/core/PyComplexDerived.java 2008-07-21 01:43:14 UTC (rev 4977) +++ trunk/jython/src/org/python/core/PyComplexDerived.java 2008-07-21 01:59:47 UTC (rev 4978) @@ -791,6 +791,20 @@ return super.__finditem__(key); } + public PyObject __finditem__(int key) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__getitem__"); + if (impl!=null) + try { + return impl.__get__(this,self_type).__call__(new PyInteger(key)); + } catch (PyException exc) { + if (Py.matchException(exc,Py.LookupError)) + return null; + throw exc; + } + return super.__finditem__(key); + } + public PyObject __getitem__(PyObject key) { // Same as __finditem__, without swallowing LookupErrors. This allows // __getitem__ implementations written in Python to raise custom Modified: trunk/jython/src/org/python/core/PyDictionaryDerived.java =================================================================== --- trunk/jython/src/org/python/core/PyDictionaryDerived.java 2008-07-21 01:43:14 UTC (rev 4977) +++ trunk/jython/src/org/python/core/PyDictionaryDerived.java 2008-07-21 01:59:47 UTC (rev 4978) @@ -791,6 +791,20 @@ return super.__finditem__(key); } + public PyObject __finditem__(int key) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__getitem__"); + if (impl!=null) + try { + return impl.__get__(this,self_type).__call__(new PyInteger(key)); + } catch (PyException exc) { + if (Py.matchException(exc,Py.LookupError)) + return null; + throw exc; + } + return super.__finditem__(key); + } + public PyObject __getitem__(PyObject key) { // Same as __finditem__, without swallowing LookupErrors. This allows // __getitem__ implementations written in Python to raise custom Modified: trunk/jython/src/org/python/core/PyEnumerateDerived.java =================================================================== --- trunk/jython/src/org/python/core/PyEnumerateDerived.java 2008-07-21 01:43:14 UTC (rev 4977) +++ trunk/jython/src/org/python/core/PyEnumerateDerived.java 2008-07-21 01:59:47 UTC (rev 4978) @@ -791,6 +791,20 @@ return super.__finditem__(key); } + public PyObject __finditem__(int key) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__getitem__"); + if (impl!=null) + try { + return impl.__get__(this,self_type).__call__(new PyInteger(key)); + } catch (PyException exc) { + if (Py.matchException(exc,Py.LookupError)) + return null; + throw exc; + } + return super.__finditem__(key); + } + public PyObject __getitem__(PyObject key) { // Same as __finditem__, without swallowing LookupErrors. This allows // __getitem__ implementations written in Python to raise custom Modified: trunk/jython/src/org/python/core/PyFileDerived.java =================================================================== --- trunk/jython/src/org/python/core/PyFileDerived.java 2008-07-21 01:43:14 UTC (rev 4977) +++ trunk/jython/src/org/python/core/PyFileDerived.java 2008-07-21 01:59:47 UTC (rev 4978) @@ -791,6 +791,20 @@ return super.__finditem__(key); } + public PyObject __finditem__(int key) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__getitem__"); + if (impl!=null) + try { + return impl.__get__(this,self_type).__call__(new PyInteger(key)); + } catch (PyException exc) { + if (Py.matchException(exc,Py.LookupError)) + return null; + throw exc; + } + return super.__finditem__(key); + } + public PyObject __getitem__(PyObject key) { // Same as __finditem__, without swallowing LookupErrors. This allows // __getitem__ implementations written in Python to raise custom Modified: trunk/jython/src/org/python/core/PyFloatDerived.java =================================================================== --- trunk/jython/src/org/python/core/PyFloatDerived.java 2008-07-21 01:43:14 UTC (rev 4977) +++ trunk/jython/src/org/python/core/PyFloatDerived.java 2008-07-21 01:59:47 UTC (rev 4978) @@ -791,6 +791,20 @@ return super.__finditem__(key); } + public PyObject __finditem__(int key) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__getitem__"); + if (impl!=null) + try { + return impl.__get__(this,self_type).__call__(new PyInteger(key)); + } catch (PyException exc) { + if (Py.matchException(exc,Py.LookupError)) + return null; + throw exc; + } + return super.__finditem__(key); + } + public PyObject __getitem__(PyObject key) { // Same as __finditem__, without swallowing LookupErrors. This allows // __getitem__ implementations written in Python to raise custom Modified: trunk/jython/src/org/python/core/PyFrozenSetDerived.java =================================================================== --- trunk/jython/src/org/python/core/PyFrozenSetDerived.java 2008-07-21 01:43:14 UTC (rev 4977) +++ trunk/jython/src/org/python/core/PyFrozenSetDerived.java 2008-07-21 01:59:47 UTC (rev 4978) @@ -791,6 +791,20 @@ return super.__finditem__(key); } + public PyObject __finditem__(int key) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__getitem__"); + if (impl!=null) + try { + return impl.__get__(this,self_type).__call__(new PyInteger(key)); + } catch (PyException exc) { + if (Py.matchException(exc,Py.LookupError)) + return null; + throw exc; + } + return super.__finditem__(key); + } + public PyObject __getitem__(PyObject key) { // Same as __finditem__, without swallowing LookupErrors. This allows // __getitem__ implementations written in Python to raise custom Modified: trunk/jython/src/org/python/core/PyIntegerDerived.java =================================================================== --- trunk/jython/src/org/python/core/PyIntegerDerived.java 2008-07-21 01:43:14 UTC (rev 4977) +++ trunk/jython/src/org/python/core/PyIntegerDerived.java 2008-07-21 01:59:47 UTC (rev 4978) @@ -791,6 +791,20 @@ return super.__finditem__(key); } + public PyObject __finditem__(int key) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__getitem__"); + if (impl!=null) + try { + return impl.__get__(this,self_type).__call__(new PyInteger(key)); + } catch (PyException exc) { + if (Py.matchException(exc,Py.LookupError)) + return null; + throw exc; + } + return super.__finditem__(key); + } + public PyObject __getitem__(PyObject key) { // Same as __finditem__, without swallowing LookupErrors. This allows // __getitem__ implementations written in Python to raise custom Modified: trunk/jython/src/org/python/core/PyListDerived.java =================================================================== --- trunk/jython/src/org/python/core/PyListDerived.java 2008-07-21 01:43:14 UTC (rev 4977) +++ trunk/jython/src/org/python/core/PyListDerived.java 2008-07-21 01:59:47 UTC (rev 4978) @@ -791,6 +791,20 @@ return super.__finditem__(key); } + public PyObject __finditem__(int key) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__getitem__"); + if (impl!=null) + try { + return impl.__get__(this,self_type).__call__(new PyInteger(key)); + } catch (PyException exc) { + if (Py.matchException(exc,Py.LookupError)) + return null; + throw exc; + } + return super.__finditem__(key); + } + public PyObject __getitem__(PyObject key) { // Same as __finditem__, without swallowing LookupErrors. This allows // __getitem__ implementations written in Python to raise custom Modified: trunk/jython/src/org/python/core/PyLongDerived.java =================================================================== --- trunk/jython/src/org/python/core/PyLongDerived.java 2008-07-21 01:43:14 UTC (rev 4977) +++ trunk/jython/src/org/python/core/PyLongDerived.java 2008-07-21 01:59:47 UTC (rev 4978) @@ -791,6 +791,20 @@ return super.__finditem__(key); } + public PyObject __finditem__(int key) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__getitem__"); + if (impl!=null) + try { + return impl.__get__(this,self_type).__call__(new PyInteger(key)); + } catch (PyException exc) { + if (Py.matchException(exc,Py.LookupError)) + return null; + throw exc; + } + return super.__finditem__(key); + } + public PyObject __getitem__(PyObject key) { // Same as __finditem__, without swallowing LookupErrors. This allows // __getitem__ implementations written in Python to raise custom Modified: trunk/jython/src/org/python/core/PyModuleDerived.java =================================================================== --- trunk/jython/src/org/python/core/PyModuleDerived.java 2008-07-21 01:43:14 UTC (rev 4977) +++ trunk/jython/src/org/python/core/PyModuleDerived.java 2008-07-21 01:59:47 UTC (rev 4978) @@ -767,6 +767,20 @@ return super.__finditem__(key); } + public PyObject __finditem__(int key) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__getitem__"); + if (impl!=null) + try { + return impl.__get__(this,self_type).__call__(new PyInteger(key)); + } catch (PyException exc) { + if (Py.matchException(exc,Py.LookupError)) + return null; + throw exc; + } + return super.__finditem__(key); + } + public PyObject __getitem__(PyObject key) { // Same as __finditem__, without swallowing LookupErrors. This allows // __getitem__ implementations written in Python to raise custom Modified: trunk/jython/src/org/python/core/PyObjectDerived.java =================================================================== --- trunk/jython/src/org/python/core/PyObjectDerived.java 2008-07-21 01:43:14 UTC (rev 4977) +++ trunk/jython/src/org/python/core/PyObjectDerived.java 2008-07-21 01:59:47 UTC (rev 4978) @@ -791,6 +791,20 @@ return super.__finditem__(key); } + public PyObject __finditem__(int key) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__getitem__"); + if (impl!=null) + try { + return impl.__get__(this,self_type).__call__(new PyInteger(key)); + } catch (PyException exc) { + if (Py.matchException(exc,Py.LookupError)) + return null; + throw exc; + } + return super.__finditem__(key); + } + public PyObject __getitem__(PyObject key) { // Same as __finditem__, without swallowing LookupErrors. This allows // __getitem__ implementations written in Python to raise custom Modified: trunk/jython/src/org/python/core/PyPropertyDerived.java =================================================================== --- trunk/jython/src/org/python/core/PyPropertyDerived.java 2008-07-21 01:43:14 UTC (rev 4977) +++ trunk/jython/src/org/python/core/PyPropertyDerived.java 2008-07-21 01:59:47 UTC (rev 4978) @@ -791,6 +791,20 @@ return super.__finditem__(key); } + public PyObject __finditem__(int key) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__getitem__"); + if (impl!=null) + try { + return impl.__get__(this,self_type).__call__(new PyInteger(key)); + } catch (PyException exc) { + if (Py.matchException(exc,Py.LookupError)) + return null; + throw exc; + } + return super.__finditem__(key); + } + public PyObject __getitem__(PyObject key) { // Same as __finditem__, without swallowing LookupErrors. This allows // __getitem__ implementations written in Python to raise custom Modified: trunk/jython/src/org/python/core/PySetDerived.java =================================================================== --- trunk/jython/src/org/python/core/PySetDerived.java 2008-07-21 01:43:14 UTC (rev 4977) +++ trunk/jython/src/org/python/core/PySetDerived.java 2008-07-21 01:59:47 UTC (rev 4978) @@ -791,6 +791,20 @@ return super.__finditem__(key); } + public PyObject __finditem__(int key) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__getitem__"); + if (impl!=null) + try { + return impl.__get__(this,self_type).__call__(new PyInteger(key)); + } catch (PyException exc) { + if (Py.matchException(exc,Py.LookupError)) + return null; + throw exc; + } + return super.__finditem__(key); + } + public PyObject __getitem__(PyObject key) { // Same as __finditem__, without swallowing LookupErrors. This allows // __getitem__ implementations written in Python to raise custom Modified: trunk/jython/src/org/python/core/PySliceDerived.java =================================================================== --- trunk/jython/src/org/python/core/PySliceDerived.java 2008-07-21 01:43:14 UTC (rev 4977) +++ trunk/jython/src/org/python/core/PySliceDerived.java 2008-07-21 01:59:47 UTC (rev 4978) @@ -791,6 +791,20 @@ return super.__finditem__(key); } + public PyObject __finditem__(int key) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__getitem__"); + if (impl!=null) + try { + return impl.__get__(this,self_type).__call__(new PyInteger(key)); + } catch (PyException exc) { + if (Py.matchException(exc,Py.LookupError)) + return null; + throw exc; + } + return super.__finditem__(key); + } + public PyObject __getitem__(PyObject key) { // Same as __finditem__, without swallowing LookupErrors. This allows // __getitem__ implementations written in Python to raise custom Modified: trunk/jython/src/org/python/core/PyStringDerived.java =================================================================== --- trunk/jython/src/org/python/core/PyStringDerived.java 2008-07-21 01:43:14 UTC (rev 4977) +++ trunk/jython/src/org/python/core/PyStringDerived.java 2008-07-21 01:59:47 UTC (rev 4978) @@ -791,6 +791,20 @@ return super.__finditem__(key); } + public PyObject __finditem__(int key) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__getitem__"); + if (impl!=null) + try { + return impl.__get__(this,self_type).__call__(new PyInteger(key)); + } catch (PyException exc) { + if (Py.matchException(exc,Py.LookupError)) + return null; + throw exc; + } + return super.__finditem__(key); + } + public PyObject __getitem__(PyObject key) { // Same as __finditem__, without swallowing LookupErrors. This allows // __getitem__ implementations written in Python to raise custom Modified: trunk/jython/src/org/python/core/PySuperDerived.java =================================================================== --- trunk/jython/src/org/python/core/PySuperDerived.java 2008-07-21 01:43:14 UTC (rev 4977) +++ trunk/jython/src/org/python/core/PySuperDerived.java 2008-07-21 01:59:47 UTC (rev 4978) @@ -791,6 +791,20 @@ return super.__finditem__(key); } + public PyObject __finditem__(int key) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__getitem__"); + if (impl!=null) + try { + return impl.__get__(this,self_type).__call__(new PyInteger(key)); + } catch (PyException exc) { + if (Py.matchException(exc,Py.LookupError)) + return null; + throw exc; + } + return super.__finditem__(key); + } + public PyObject __getitem__(PyObject key) { // Same as __finditem__, without swallowing LookupErrors. This allows // __getitem__ implementations written in Python to raise custom Modified: trunk/jython/src/org/python/core/PyTupleDerived.java =================================================================== --- trunk/jython/src/org/python/core/PyTupleDerived.java 2008-07-21 01:43:14 UTC (rev 4977) +++ trunk/jython/src/org/python/core/PyTupleDerived.java 2008-07-21 01:59:47 UTC (rev 4978) @@ -791,6 +791,20 @@ return super.__finditem__(key); } + public PyObject __finditem__(int key) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__getitem__"); + if (impl!=null) + try { + return impl.__get__(this,self_type).__call__(new PyInteger(key)); + } catch (PyException exc) { + if (Py.matchException(exc,Py.LookupError)) + return null; + throw exc; + } + return super.__finditem__(key); + } + public PyObject __getitem__(PyObject key) { // Same as __finditem__, without swallowing LookupErrors. This allows // __getitem__ implementations written in Python to raise custom Modified: trunk/jython/src/org/python/core/PyTypeDerived.java =================================================================== --- trunk/jython/src/org/python/core/PyTypeDerived.java 2008-07-21 01:43:14 UTC (rev 4977) +++ trunk/jython/src/org/python/core/PyTypeDerived.java 2008-07-21 01:59:47 UTC (rev 4978) @@ -767,6 +767,20 @@ return super.__finditem__(key); } + public PyObject __finditem__(int key) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__getitem__"); + if (impl!=null) + try { + return impl.__get__(this,self_type).__call__(new PyInteger(key)); + } catch (PyException exc) { + if (Py.matchException(exc,Py.LookupError)) + return null; + throw exc; + } + return super.__finditem__(key); + } + public PyObject __getitem__(PyObject key) { // Same as __finditem__, without swallowing LookupErrors. This allows // __getitem__ implementations written in Python to raise custom Modified: trunk/jython/src/org/python/core/PyUnicodeDerived.java =================================================================== --- trunk/jython/src/org/python/core/PyUnicodeDerived.java 2008-07-21 01:43:14 UTC (rev 4977) +++ trunk/jython/src/org/python/core/PyUnicodeDerived.java 2008-07-21 01:59:47 UTC (rev 4978) @@ -791,6 +791,20 @@ return super.__finditem__(key); } + public PyObject __finditem__(int key) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__getitem__"); + if (impl!=null) + try { + return impl.__get__(this,self_type).__call__(new PyInteger(key)); + } catch (PyException exc) { + if (Py.matchException(exc,Py.LookupError)) + return null; + throw exc; + } + return super.__finditem__(key); + } + public PyObject __getitem__(PyObject key) { // Same as __finditem__, without swallowing LookupErrors. This allows // __getitem__ implementations written in Python to raise custom Modified: trunk/jython/src/org/python/modules/_weakref/ReferenceTypeDerived.java =================================================================== --- trunk/jython/src/org/python/modules/_weakref/ReferenceTypeDerived.java 2008-07-21 01:43:14 UTC (rev 4977) +++ trunk/jython/src/org/python/modules/_weakref/ReferenceTypeDerived.java 2008-07-21 01:59:47 UTC (rev 4978) @@ -793,6 +793,20 @@ return super.__finditem__(key); } + public PyObject __finditem__(int key) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__getitem__"); + if (impl!=null) + try { + return impl.__get__(this,self_type).__call__(new PyInteger(key)); + } catch (PyException exc) { + if (Py.matchException(exc,Py.LookupError)) + return null; + throw exc; + } + return super.__finditem__(key); + } + public PyObject __getitem__(PyObject key) { // Same as __finditem__, without swallowing LookupErrors. This allows // __getitem__ implementations written in Python to raise custom Modified: trunk/jython/src/org/python/modules/collections/PyDefaultDictDerived.java =================================================================== --- trunk/jython/src/org/python/modules/collections/PyDefaultDictDerived.java 2008-07-21 01:43:14 UTC (rev 4977) +++ trunk/jython/src/org/python/modules/collections/PyDefaultDictDerived.java 2008-07-21 01:59:47 UTC (rev 4978) @@ -793,6 +793,20 @@ return super.__finditem__(key); } + public PyObject __finditem__(int key) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__getitem__"); + if (impl!=null) + try { + return impl.__get__(this,self_type).__call__(new PyInteger(key)); + } catch (PyException exc) { + if (Py.matchException(exc,Py.LookupError)) + return null; + throw exc; + } + return super.__finditem__(key); + } + public PyObject __getitem__(PyObject key) { // Same as __finditem__, without swallowing LookupErrors. This allows // __getitem__ implementations written in Python to raise custom Modified: trunk/jython/src/org/python/modules/collections/PyDequeDerived.java =================================================================== --- trunk/jython/src/org/python/modules/collections/PyDequeDerived.java 2008-07-21 01:43:14 UTC (rev 4977) +++ trunk/jython/src/org/python/modules/collections/PyDequeDerived.java 2008-07-21 01:59:47 UTC (rev 4978) @@ -793,6 +793,20 @@ return super.__finditem__(key); } + public PyObject __finditem__(int key) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__getitem__"); + if (impl!=null) + try { + return impl.__get__(this,self_type).__call__(new PyInteger(key)); + } catch (PyException exc) { + if (Py.matchException(exc,Py.LookupError)) + return null; + throw exc; + } + return super.__finditem__(key); + } + public PyObject __getitem__(PyObject key) { // Same as __finditem__, without swallowing LookupErrors. This allows // __getitem__ implementations written in Python to raise custom Modified: trunk/jython/src/org/python/modules/random/PyRandomDerived.java =================================================================== --- trunk/jython/src/org/python/modules/random/PyRandomDerived.java 2008-07-21 01:43:14 UTC (rev 4977) +++ trunk/jython/src/org/python/modules/random/PyRandomDerived.java 2008-07-21 01:59:47 UTC (rev 4978) @@ -793,6 +793,20 @@ return super.__finditem__(key); } + public PyObject __finditem__(int key) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__getitem__"); + if (impl!=null) + try { + return impl.__get__(this,self_type).__call__(new PyInteger(key)); + } catch (PyException exc) { + if (Py.matchException(exc,Py.LookupError)) + return null; + throw exc; + } + return super.__finditem__(key); + } + public PyObject __getitem__(PyObject key) { // Same as __finditem__, without swallowing LookupErrors. This allows // __getitem__ implementations written in Python to raise custom Modified: trunk/jython/src/org/python/modules/thread/PyLocalDerived.java =================================================================== --- trunk/jython/src/org/python/modules/thread/PyLocalDerived.java 2008-07-21 01:43:14 UTC (rev 4977) +++ trunk/jython/src/org/python/modules/thread/PyLocalDerived.java 2008-07-21 01:59:47 UTC (rev 4978) @@ -769,6 +769,20 @@ return super.__finditem__(key); } + public PyObject __finditem__(int key) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__getitem__"); + if (impl!=null) + try { + return impl.__get__(this,self_type).__call__(new PyInteger(key)); + } catch (PyException exc) { + if (Py.matchException(exc,Py.LookupError)) + return null; + throw exc; + } + return super.__finditem__(key); + } + public PyObject __getitem__(PyObject key) { // Same as __finditem__, without swallowing LookupErrors. This allows // __getitem__ implementations written in Python to raise custom Modified: trunk/jython/src/org/python/modules/zipimport/zipimporterDerived.java =================================================================== --- trunk/jython/src/org/python/modules/zipimport/zipimporterDerived.java 2008-07-21 01:43:14 UTC (rev 4977) +++ trunk/jython/src/org/python/modules/zipimport/zipimporterDerived.java 2008-07-21 01:59:47 UTC (rev 4978) @@ -769,6 +769,20 @@ return super.__finditem__(key); } + public PyObject __finditem__(int key) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__getitem__"); + if (impl!=null) + try { + return impl.__get__(this,self_type).__call__(new PyInteger(key)); + } catch (PyException exc) { + if (Py.matchException(exc,Py.LookupError)) + return null; + throw exc; + } + return super.__finditem__(key); + } + public PyObject __getitem__(PyObject key) { // Same as __finditem__, without swallowing LookupErrors. This allows // __getitem__ implementations written in Python to raise custom Modified: trunk/jython/src/templates/object.derived =================================================================== --- trunk/jython/src/templates/object.derived 2008-07-21 01:43:14 UTC (rev 4977) +++ trunk/jython/src/templates/object.derived 2008-07-21 01:59:47 UTC (rev 4978) @@ -179,6 +179,20 @@ return super.__finditem__(key); } + public PyObject __finditem__(int key) { + PyType self_type = getType(); + PyObject impl = self_type.lookup("__getitem__"); + if (impl != null) + try { + return impl.__get__(this,self_type).__call__(new PyInteger(key)); + } catch (PyException exc) { + if (Py.matchException(exc, Py.LookupError)) + return null; + throw exc; + } + return super.__finditem__(key); + } + public PyObject __getitem__(PyObject key) { // Same as __finditem__, without swallowing LookupErrors. This allows // __getitem__ implementations written in Python to raise custom This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2008-08-19 21:07:03
|
Revision: 5206 http://jython.svn.sourceforge.net/jython/?rev=5206&view=rev Author: fwierzbicki Date: 2008-08-19 21:06:39 +0000 (Tue, 19 Aug 2008) Log Message: ----------- Merged revisions 4386,4388-4390,4392,4403,4405,4408,4418,4424-4425,4434,4466,4474,4490,4493,4496,4499-4501,4504,4523-4524,4548-4549,4577-4579,4581-4582,4585-4589,4599-4600,4603-4605,4607-4608,4613,4628,4640,4642-4643,4648,4652-4662,4665,4667,4672,4676,4678-4680,4682,4684,4693-4695,4704-4706,4708-4712,4714-4715,4720,4729,4732-4735,4740-4751,4753-4758,4761-4765,4767-4772,4774,4777-4779,4781-4802,4806-4810,4821-4843,4845-4850,4852-4853,4855-4857,4859,4863-4870,4876-4885,4887-4897,4901-4914,4916-4919,4922,4924-4925,4928,4930,4932-4937,4939-4945,4947,4949-4952,4959,4961,4963,4965,4967-4971,4973-4974,4980,4982-5100,5102-5117,5119-5166,5168-5197 via svnmerge from https://jython.svn.sourceforge.net/svnroot/jython/branches/asm ........ r4386 | fwierzbicki | 2008-05-08 14:55:44 -0400 (Thu, 08 May 2008) | 2 lines Recreate asmified old compiler. ........ r4388 | fwierzbicki | 2008-05-10 13:19:27 -0400 (Sat, 10 May 2008) | 3 lines Hand merged changes in trunk to copiler code. Removed Attribute support -- needs to be replaced by either ASM Attributes or Annotations. ........ r4389 | fwierzbicki | 2008-05-12 13:48:35 -0400 (Mon, 12 May 2008) | 4 lines Reworked Code.java back towards old API (so methods like code.dup() are back so it is not necessary to use code.visitInsn(DUP). This makes it easier to read the code and to compare with the old code base. ........ r4390 | fwierzbicki | 2008-05-12 22:00:02 -0400 (Mon, 12 May 2008) | 2 lines Converted everything over to antlr from javacc. ........ r4392 | fwierzbicki | 2008-05-13 15:38:04 -0400 (Tue, 13 May 2008) | 3 lines Moved more code to older style Code.java methods (still based on ASM). Added Visitor and ParseException. ........ r4403 | fwierzbicki | 2008-05-15 12:39:30 -0400 (Thu, 15 May 2008) | 2 lines Enough compiler and parser tweaking to keep site.py from exploding. ........ r4405 | fwierzbicki | 2008-05-15 15:18:26 -0400 (Thu, 15 May 2008) | 2 lines Fix for "from mod import *" and start of setline support. ........ r4408 | fwierzbicki | 2008-05-15 19:29:22 -0400 (Thu, 15 May 2008) | 2 lines Temporary fix for line number problems causing NPEs. ........ r4418 | fwierzbicki | 2008-05-17 12:20:34 -0400 (Sat, 17 May 2008) | 2 lines Remove old parser. ........ r4424 | fwierzbicki | 2008-05-20 13:39:32 -0400 (Tue, 20 May 2008) | 4 lines Added a shell script to run Jython. This was adapted from a script from the JRuby project. I also included the same suport for The Java Interactive Profiler (JIP) that JRuby includes. See http://jiprof.sourceforge.net/ ........ r4425 | fwierzbicki | 2008-05-20 13:50:01 -0400 (Tue, 20 May 2008) | 2 lines Alter profile.properties for Jython. ........ r4434 | pjenvey | 2008-05-20 17:11:36 -0400 (Tue, 20 May 2008) | 1 line missed one part of the PyMethod constructor signature change in r4400, from trunk ........ r4466 | fwierzbicki | 2008-05-27 22:05:18 -0400 (Tue, 27 May 2008) | 12 lines Now that things are close to working, time to completely destroy things again. Switched to pulling in 2.5 Python libraries. Took first baby step by attempting to support def f(): yield which is not valid 2.3 syntax. (This is actually what motivated this -- I was about to "fix" the grammar to disallow this when I accidentally noticed that it was valid 2.5 syntax. ........ r4474 | fwierzbicki | 2008-05-29 15:34:22 -0400 (Thu, 29 May 2008) | 2 lines First stab at decorator support. ........ r4490 | fwierzbicki | 2008-05-30 11:19:42 -0400 (Fri, 30 May 2008) | 15 lines Begin experimenting with a partial parser -- that is a recognizer that will be able to tell if a string of code from an interactive session is a true syntax error, or if it is part of a potentially valid string of code. For example, in the interactive session: >>> s = """ ... hello Is the start of a valid string, and should be recognized as a valid partial parse. On the other hand >>> print , Is still a syntax error. ........ r4493 | nriley | 2008-06-01 15:50:00 -0400 (Sun, 01 Jun 2008) | 1 line add ImportWarning; update exceptions class doc to 2.5 ........ r4496 | fwierzbicki | 2008-06-01 20:11:03 -0400 (Sun, 01 Jun 2008) | 2 lines Need to see exception print outs. ........ r4499 | fwierzbicki | 2008-06-01 21:03:08 -0400 (Sun, 01 Jun 2008) | 2 lines Switched to 2.4 CPython lib. ........ r4500 | nriley | 2008-06-01 21:59:37 -0400 (Sun, 01 Jun 2008) | 1 line startswith/endswith on str/unicode, passes test_str from 2.5 ........ r4501 | nriley | 2008-06-01 22:34:18 -0400 (Sun, 01 Jun 2008) | 1 line TypeError rather than NotImplemented for wrong type on str.__mul__, fixes test_mul ........ r4504 | nriley | 2008-06-01 23:55:14 -0400 (Sun, 01 Jun 2008) | 1 line r4500 broke http://pylonshq.com/pasties/827, reverting ........ r4523 | fwierzbicki | 2008-06-03 02:39:41 -0400 (Tue, 03 Jun 2008) | 6 lines Most of this change is generated -- the real code changes are in Python.g, PythonWalker.g, and asdl_antlr.py. Moving to antlr 3.1 style of AST production. Changed the Num processing only so far. ........ r4524 | fwierzbicki | 2008-06-03 10:47:46 -0400 (Tue, 03 Jun 2008) | 6 lines Moved Str processing from PythonWalker.g to Python.g. Made Unicode and Str hold PyUnicode and PyString objects instead of java.lang.String objects. This will help compatibility with CPython AST -- though *may* hurt performance more investigation will be needed. Certainly the way CodeCompiler is working will need adjustment if this strategy is the way to go. ........ r4548 | nriley | 2008-06-06 16:48:42 -0400 (Fri, 06 Jun 2008) | 1 line sync sre opcodes with Python 2.4; implement SRE_OP_GROUPREF_EXISTS ........ r4549 | nriley | 2008-06-06 17:12:40 -0400 (Fri, 06 Jun 2008) | 1 line fix comment typo ........ r4577 | nriley | 2008-06-08 22:14:13 -0400 (Sun, 08 Jun 2008) | 1 line Jython-specific test_cmd_line ........ r4578 | fwierzbicki | 2008-06-08 22:34:43 -0400 (Sun, 08 Jun 2008) | 2 lines Generator Expressions. ........ r4579 | nriley | 2008-06-08 22:39:10 -0400 (Sun, 08 Jun 2008) | 1 line fix regrtest ant target dependencies so it works from clean ........ r4581 | fwierzbicki | 2008-06-08 22:58:09 -0400 (Sun, 08 Jun 2008) | 3 lines Better name for comprehension local var (comp instead of lc -- originally stolen from the list comprehension code). ........ r4582 | nriley | 2008-06-08 23:09:46 -0400 (Sun, 08 Jun 2008) | 1 line cookielib works now ........ r4585 | fwierzbicki | 2008-06-09 09:06:46 -0400 (Mon, 09 Jun 2008) | 2 lines Conditional Expression ........ r4586 | fwierzbicki | 2008-06-09 10:10:41 -0400 (Mon, 09 Jun 2008) | 3 lines switch to _(1_1) style names for the temporaries of gen expressions, so that vars with unlikely but possible names like __gen1_1 do not get clobbered. ........ r4587 | nriley | 2008-06-09 17:19:49 -0400 (Mon, 09 Jun 2008) | 1 line provenance of test_cmd_line ........ r4588 | fwierzbicki | 2008-06-09 22:29:18 -0400 (Mon, 09 Jun 2008) | 2 lines Remove unnecessary vars. ........ r4589 | fwierzbicki | 2008-06-10 07:40:31 -0400 (Tue, 10 Jun 2008) | 2 lines Remove comment that I no longer believe :) ........ r4599 | fwierzbicki | 2008-06-11 17:26:33 -0400 (Wed, 11 Jun 2008) | 6 lines Make ParseException the only exception that comes out of the antlr parsing. Unfortunately I haven't figured out how to remove "throws RecognitionException" from the generated code, so some references remain. Also renamed PythonGrammer -> ModuleParser, and some other related refactorings. ........ r4600 | fwierzbicki | 2008-06-11 17:40:36 -0400 (Wed, 11 Jun 2008) | 2 lines More descriptive name antlr.java -> ParserFacade.java ........ r4603 | fwierzbicki | 2008-06-11 21:34:06 -0400 (Wed, 11 Jun 2008) | 4 lines Added a null guard for lexing errors (they have no token) and added an experimental getOffset() method on ParseException which intends to get the char position from the start of the file where the error occured. ........ r4604 | fwierzbicki | 2008-06-11 21:38:05 -0400 (Wed, 11 Jun 2008) | 2 lines Crap, left in debugging. Removed. ........ r4605 | fwierzbicki | 2008-06-11 22:14:26 -0400 (Wed, 11 Jun 2008) | 2 lines Fix offset for lexer errors. ........ r4607 | fwierzbicki | 2008-06-12 11:27:35 -0400 (Thu, 12 Jun 2008) | 2 lines oops, wrong directory position. ........ r4608 | fwierzbicki | 2008-06-12 17:08:38 -0400 (Thu, 12 Jun 2008) | 5 lines pep 263. There is some roughness remaining, especially a strange problem around utf-8 that I need to look into (I ended up letting Jython go with its default in the case of a utf-8 encoding specified for now). ........ r4613 | fwierzbicki | 2008-06-13 13:33:31 -0400 (Fri, 13 Jun 2008) | 4 lines Add a token source for partial parsing (for now -- can probably become a subclass of PythonTokenSource once the kinks are out). Unterminated triple strings now pass. ........ r4628 | zyasoft | 2008-06-14 19:23:52 -0400 (Sat, 14 Jun 2008) | 1 line Added visitWith to support the with-statement. Changed ClassFile so that it does frame analysis with COMPUTE_FRAMES (used by Java 6, seems OK with Java 5 - and prevents code from being compiled that would fail bytecode verifier. Generally that would be a good thing. Fixed threading.Lock.__enter__ so it returns the lock object, not just do an acquire. ........ r4640 | zyasoft | 2008-06-15 01:13:59 -0400 (Sun, 15 Jun 2008) | 1 line Changed Code.ldc such that for large string constants (>32767 char), it splits into chunked ldcsand assembles with a StringBuilder ........ r4642 | nriley | 2008-06-15 17:45:22 -0400 (Sun, 15 Jun 2008) | 1 line jna-posix from http://svn.codehaus.org/jruby-contrib/trunk/jna-posix r179 ........ r4643 | nriley | 2008-06-15 18:04:11 -0400 (Sun, 15 Jun 2008) | 1 line os.stat, chmod, getegid, geteuid, getgid, getlogin, getpgrp, getpid, getppid, getuid, setpgrp, setsid via jna-posix ........ r4648 | nriley | 2008-06-16 01:23:39 -0400 (Mon, 16 Jun 2008) | 1 line enable test_posix ........ r4652 | fwierzbicki | 2008-06-16 15:23:38 -0400 (Mon, 16 Jun 2008) | 3 lines Extrated PythonTreeAdaptor from the *Parser classes, some work to improve offsets. ........ r4653 | zyasoft | 2008-06-16 15:51:12 -0400 (Mon, 16 Jun 2008) | 1 line Now supports coroutines. At this point, I have only done limited testing, especially with respect to exceptions. ........ r4654 | fwierzbicki | 2008-06-16 16:35:50 -0400 (Mon, 16 Jun 2008) | 2 lines More offset work for IDE support. ........ r4655 | zyasoft | 2008-06-16 18:54:40 -0400 (Mon, 16 Jun 2008) | 1 line Reordered public members of PyGenerator so that dir will have the same order as CPython ........ r4656 | fwierzbicki | 2008-06-16 19:11:25 -0400 (Mon, 16 Jun 2008) | 2 lines Move some imaginary tokens to concrete tokens. ........ r4657 | zyasoft | 2008-06-16 20:21:52 -0400 (Mon, 16 Jun 2008) | 1 line Added support of __future__.with_statement; this includes aligning PyTableCode with __future__.py as of 2.5. Does not yet support interactive future import of the with_statement, however ........ r4658 | fwierzbicki | 2008-06-16 20:26:20 -0400 (Mon, 16 Jun 2008) | 3 lines pass statement turned to concrete token. Also preparing to absorb more of PythonWalker.g into Python.g. ........ r4659 | pjenvey | 2008-06-16 20:42:38 -0400 (Mon, 16 Jun 2008) | 1 line we want the absolute path here ........ r4660 | fwierzbicki | 2008-06-16 22:34:20 -0400 (Mon, 16 Jun 2008) | 3 lines parameter passing that I am not using yet. Will be crucial for a one pass parse. ........ r4661 | fwierzbicki | 2008-06-16 22:47:21 -0400 (Mon, 16 Jun 2008) | 2 lines break and continue only newed in Python.g ........ r4662 | fwierzbicki | 2008-06-17 11:12:43 -0400 (Tue, 17 Jun 2008) | 2 lines Slowly adding more needed params to Python.g from PythonWalker.g. ........ r4665 | fwierzbicki | 2008-06-18 10:59:31 -0400 (Wed, 18 Jun 2008) | 3 lines Introduce an ENDMARK imaginary token to handle unfinished but partially valid statements. ........ r4667 | fwierzbicki | 2008-06-18 16:21:10 -0400 (Wed, 18 Jun 2008) | 2 lines Incremental improvement on interactive mode. ........ r4672 | fwierzbicki | 2008-06-18 21:26:41 -0400 (Wed, 18 Jun 2008) | 3 lines Fix PythonPartialTester. Added some info to toStringTree output of PythonTree. ........ r4676 | fwierzbicki | 2008-06-19 11:30:05 -0400 (Thu, 19 Jun 2008) | 3 lines Added an ImaginaryToken type so that the char positions of INDENT and DEDENT can be easily tracked. ........ r4678 | fwierzbicki | 2008-06-19 13:58:08 -0400 (Thu, 19 Jun 2008) | 2 lines Replace many imaginary tokens with concrete tokens. ........ r4679 | fwierzbicki | 2008-06-19 18:31:55 -0400 (Thu, 19 Jun 2008) | 2 lines whitespace ........ r4680 | fwierzbicki | 2008-06-19 19:50:49 -0400 (Thu, 19 Jun 2008) | 2 lines Update comments and rule positions compared to CPython's Grammar/Grammar ........ r4682 | pjenvey | 2008-06-19 20:07:46 -0400 (Thu, 19 Jun 2008) | 1 line fix whitespace ........ r4684 | pjenvey | 2008-06-19 20:50:11 -0400 (Thu, 19 Jun 2008) | 4 lines compile inplace operations to a PyObject._ixx wrapper (which uses _binop_rule, like _xxx), instead of __ixx__ for #1873148 ........ r4693 | pjenvey | 2008-06-20 01:45:14 -0400 (Fri, 20 Jun 2008) | 5 lines o fix builtin inplace methods to work as MethodType.BINARY o add missing inplace functions to operator module o fix CPython specific usage of __iadd__ in lists_tests to operator.__iadd__ for #1873148 ........ r4694 | pjenvey | 2008-06-20 02:01:14 -0400 (Fri, 20 Jun 2008) | 3 lines make deriveds inplace ops work like binary ops for #1873148 ........ r4695 | zyasoft | 2008-06-20 02:21:29 -0400 (Fri, 20 Jun 2008) | 1 line Updated most builtins to 2.5; intern, object do not yet conform. Float conversion is richer in Java than it is in Python for hex (Java supports floating point hex values, test_float). Derived longs are failing (test_longconversion). cmp might be fixed by Leo Soto. Remaining issues are probably due to partial parse problems. Added contextlib, functools. The latter uses a pure-Python implementation, so it does not look like a native type for some of the tests in test_functools; TBD. ........ r4704 | fwierzbicki | 2008-06-20 13:32:49 -0400 (Fri, 20 Jun 2008) | 3 lines Cleared up some bad behavior in Python.g (was reporting and recovering from missing tokens). ........ r4705 | fwierzbicki | 2008-06-20 13:35:59 -0400 (Fri, 20 Jun 2008) | 2 lines Switch debugging off. ........ r4706 | fwierzbicki | 2008-06-20 14:33:18 -0400 (Fri, 20 Jun 2008) | 2 lines Repaired partial strings. Partial lists, dicts, etc *sometimes* work. ........ r4708 | fwierzbicki | 2008-06-20 15:58:27 -0400 (Fri, 20 Jun 2008) | 2 lines Pretty good nested [,(,{ support for interactive mode. ........ r4709 | zyasoft | 2008-06-20 21:16:24 -0400 (Fri, 20 Jun 2008) | 1 line Added wsgiref from 2.5 ........ r4710 | fwierzbicki | 2008-06-21 08:20:13 -0400 (Sat, 21 Jun 2008) | 2 lines whitespace. ........ r4711 | fwierzbicki | 2008-06-21 08:39:06 -0400 (Sat, 21 Jun 2008) | 2 lines Now simple tests of the interactive mode are working well. ........ r4712 | pjenvey | 2008-06-21 19:42:05 -0400 (Sat, 21 Jun 2008) | 1 line always re-generate .class until APIVersion is fixed ........ r4714 | nriley | 2008-06-22 22:38:45 -0400 (Sun, 22 Jun 2008) | 1 line os.isatty, file.isatty support ........ r4715 | fwierzbicki | 2008-06-23 11:57:31 -0400 (Mon, 23 Jun 2008) | 2 lines Fix for one line compound statements in interactive mode. ........ r4720 | fwierzbicki | 2008-06-23 15:28:04 -0400 (Mon, 23 Jun 2008) | 2 lines return None for getfilesystemencoding for now. ........ r4729 | pjenvey | 2008-06-23 18:06:02 -0400 (Mon, 23 Jun 2008) | 7 lines merge trunk/jython@4725:branches/pep352@4725 to branches/asm branches/pep352 failures: test_coercion test_deque test_doctest test_exceptions test_extcall test_generators test_pickletools new asm failures: test_coercion test_deque test_pickletools test_wsgiref ........ r4732 | fwierzbicki | 2008-06-23 19:41:21 -0400 (Mon, 23 Jun 2008) | 2 lines moving to 2.5 Lib. Also small fix for encoding check. ........ r4733 | pjenvey | 2008-06-23 20:31:42 -0400 (Mon, 23 Jun 2008) | 3 lines from: http://svn.python.org/projects/python/branches/release25-maint/Lib/test/test_exceptions.py@52486 ........ r4734 | pjenvey | 2008-06-23 20:45:53 -0400 (Mon, 23 Jun 2008) | 3 lines o 2.5 EnvironmentError needs a custom __reduce__ o disable failing testInfiniteRecursion ........ r4735 | fwierzbicki | 2008-06-23 21:14:18 -0400 (Mon, 23 Jun 2008) | 2 lines better order for suite subrule. ........ r4740 | pjenvey | 2008-06-23 22:07:21 -0400 (Mon, 23 Jun 2008) | 3 lines from: http://svn.python.org/projects/python/branches/release25-maint/Lib/test/test_support.py@60337 ........ r4741 | fwierzbicki | 2008-06-23 22:10:11 -0400 (Mon, 23 Jun 2008) | 4 lines Realized that CPython forces an extra newline for *all* compound statments (including statments like "class Foo:pass"). Greatly simplified the grammar. ........ r4742 | pjenvey | 2008-06-23 22:14:19 -0400 (Mon, 23 Jun 2008) | 1 line merge Jython specific changes back into 2.5 test_support ........ r4743 | fwierzbicki | 2008-06-23 22:36:57 -0400 (Mon, 23 Jun 2008) | 2 lines Fix exploding newlines on interactive prompt. ........ r4744 | pjenvey | 2008-06-23 22:43:05 -0400 (Mon, 23 Jun 2008) | 1 line re-enable setdict, fixed by pep352 ........ r4745 | pjenvey | 2008-06-24 03:01:10 -0400 (Tue, 24 Jun 2008) | 3 lines from: http://svn.python.org/projects/python/branches/release25-maint/Lib/test/test_optparse.py@50791 ........ r4746 | pjenvey | 2008-06-24 03:03:33 -0400 (Tue, 24 Jun 2008) | 1 line allow imports outside of test ........ r4747 | pjenvey | 2008-06-24 03:04:43 -0400 (Tue, 24 Jun 2008) | 1 line don't assume __builtins__ and skip a CPython specific test ........ r4748 | fwierzbicki | 2008-06-24 09:59:06 -0400 (Tue, 24 Jun 2008) | 2 lines Finally - the threshold for a version change has been hit. Yay! ........ r4749 | zyasoft | 2008-06-24 11:45:48 -0400 (Tue, 24 Jun 2008) | 1 line Use CPythonLib's re.py, not our own ........ r4750 | fwierzbicki | 2008-06-24 12:46:35 -0400 (Tue, 24 Jun 2008) | 2 lines Support longs regardless of radix. ........ r4751 | fwierzbicki | 2008-06-24 13:10:39 -0400 (Tue, 24 Jun 2008) | 3 lines move the Jython specific test_array out of the way so we can test against the CPython test_array ........ r4753 | pjenvey | 2008-06-24 17:31:29 -0400 (Tue, 24 Jun 2008) | 1 line disable test_asynchat for now, re #1064 ........ r4754 | pjenvey | 2008-06-24 17:31:42 -0400 (Tue, 24 Jun 2008) | 1 line small cleanup ........ r4755 | pjenvey | 2008-06-24 19:12:17 -0400 (Tue, 24 Jun 2008) | 3 lines from: http://svn.python.org/projects/python/branches/release25-maint/Lib/test/test_logging.py@54275 ........ r4756 | pjenvey | 2008-06-24 19:13:31 -0400 (Tue, 24 Jun 2008) | 1 line re-integrate r4098:4167 ........ r4757 | pjenvey | 2008-06-24 19:57:42 -0400 (Tue, 24 Jun 2008) | 2 lines from: http://svn.python.org/projects/python/branches/release25-maint/Lib/doctest.py@59174 ........ r4758 | pjenvey | 2008-06-24 20:11:28 -0400 (Tue, 24 Jun 2008) | 5 lines o bring in decimal (test_decimal passes). also hashlib and platform which don't quite work yet o Jython changes for doctest, though test_doctest still fails. bring in trace for test_doctest ........ r4761 | fwierzbicki | 2008-06-25 13:22:09 -0400 (Wed, 25 Jun 2008) | 3 lines removed special handling of RecognitionException, since errors are always of type ParseException now anyway. ........ r4762 | fwierzbicki | 2008-06-25 13:51:08 -0400 (Wed, 25 Jun 2008) | 3 lines Created a flag so that external tools can use Python.g with Antlr's default error handling. ........ r4763 | fwierzbicki | 2008-06-25 14:10:21 -0400 (Wed, 25 Jun 2008) | 4 lines antlrErrorHandling needs to be public to be used by external tools. Looking at the nice error messages that are coming out makes me wonder if I might want to rethink my error handling mechanism. ........ r4764 | pjenvey | 2008-06-25 15:03:08 -0400 (Wed, 25 Jun 2008) | 1 line reapply compiled name as <module> from r4321 ........ r4765 | pjenvey | 2008-06-25 15:05:09 -0400 (Wed, 25 Jun 2008) | 2 lines from: http://svn.python.org/projects/python/branches/release25-maint/Lib/inspect.py@56297 ........ r4767 | pjenvey | 2008-06-25 15:45:51 -0400 (Wed, 25 Jun 2008) | 1 line re-integrate r4053 ........ r4768 | pjenvey | 2008-06-25 15:49:17 -0400 (Wed, 25 Jun 2008) | 3 lines o fix string exceptions which I broke in r4754 o kill OverflowWarning and the custom warnings.py that we no longer need ........ r4769 | pjenvey | 2008-06-25 16:12:14 -0400 (Wed, 25 Jun 2008) | 1 line match messages to CPython 2.5 ........ r4770 | pjenvey | 2008-06-25 16:27:31 -0400 (Wed, 25 Jun 2008) | 1 line small cleanup to unpackSequence ........ r4771 | pjenvey | 2008-06-25 16:46:49 -0400 (Wed, 25 Jun 2008) | 2 lines from: http://svn.python.org/projects/python/branches/release25-maint/Lib/test/regrtest.py@54228 ........ r4772 | pjenvey | 2008-06-25 16:48:27 -0400 (Wed, 25 Jun 2008) | 2 lines re-integrate jython specifics: mostly just -e support and java platform test defines ........ r4774 | fwierzbicki | 2008-06-25 19:08:30 -0400 (Wed, 25 Jun 2008) | 2 lines Can't live without -m. ........ r4777 | pjenvey | 2008-06-25 20:12:35 -0400 (Wed, 25 Jun 2008) | 4 lines skip a number of tests we won't pass anytime soon. mark most of the cjkencodings tests and xml_etree as perm failures for now. re-enable test_unicode as it's close to passing ........ r4778 | pjenvey | 2008-06-25 20:12:50 -0400 (Wed, 25 Jun 2008) | 1 line test_uuid passes ........ r4779 | nriley | 2008-06-25 21:16:20 -0400 (Wed, 25 Jun 2008) | 1 line Return permission denied for files opened for reading. ........ r4781 | nriley | 2008-06-25 21:47:39 -0400 (Wed, 25 Jun 2008) | 1 line Match CPython behavior, hiding banner/prompt if stdin is not interactive and showing prompt if file argument is a tty; remove related workaround from test_cmd_line. ........ r4782 | fwierzbicki | 2008-06-26 13:11:56 -0400 (Thu, 26 Jun 2008) | 2 lines hexoct is passing. ........ r4783 | fwierzbicki | 2008-06-26 13:15:03 -0400 (Thu, 26 Jun 2008) | 3 lines Corner case for fplist fixed. def foo((x)) should be treated the same as def foo(x). ........ r4784 | fwierzbicki | 2008-06-26 16:11:35 -0400 (Thu, 26 Jun 2008) | 2 lines genexp should be sole argument if no parens. First half of fix. ........ r4785 | zyasoft | 2008-06-26 18:43:05 -0400 (Thu, 26 Jun 2008) | 1 line Removed old Jython-specific tests in favor of CPythonLib versions (except that test_urllib.py has a dependency on fileno being int, so changed accordingly). Cleaned up SRE engine code such that it more closely follows _sre.c. Removed optimization of Unicode charset in sre_compile since for UCS-4 for CPython, it doesn't appear to use this optimization anyway. ........ r4786 | zyasoft | 2008-06-26 20:44:30 -0400 (Thu, 26 Jun 2008) | 1 line re.sub, re.subn now coerce to the right type (unicode/str), based on the spec provided by test_re.test_bug_1140 ........ r4787 | zyasoft | 2008-06-26 20:50:25 -0400 (Thu, 26 Jun 2008) | 1 line Removed obsolete test, superseded by 2.5 coercion rules for emptry strings on re.sub ........ r4788 | pjenvey | 2008-06-26 21:14:25 -0400 (Thu, 26 Jun 2008) | 2 lines from: http://svn.python.org/projects/python/branches/release25-maint/Lib/test/test_urllib2_localnet.py@55806 ........ r4789 | pjenvey | 2008-06-26 21:15:47 -0400 (Thu, 26 Jun 2008) | 1 line explicitly close the server socket instead of relying on GC ........ r4790 | zyasoft | 2008-06-26 21:26:29 -0400 (Thu, 26 Jun 2008) | 1 line test_re now passes completely. This was done by commenting inapplicable tests re recursion limits, since we are not going to implement a non-recursive variant, as well as adding the unimplemented typecodes for PyArray. Too bad that there's a lot more to do to get array working as well! ........ r4791 | pjenvey | 2008-06-26 21:30:12 -0400 (Thu, 26 Jun 2008) | 2 lines upgrade socket._fileobject to 2.5's ........ r4792 | pjenvey | 2008-06-26 22:39:20 -0400 (Thu, 26 Jun 2008) | 2 lines from: http://svn.python.org/projects/python/branches/release25-maint/Lib/test/test_hashlib.py@39316 ........ r4793 | pjenvey | 2008-06-26 22:52:59 -0400 (Thu, 26 Jun 2008) | 3 lines add _hashlib with support for everything but sha224, via java.security.MessageDigest. supersedes our md5 module ........ r4794 | pjenvey | 2008-06-26 23:04:45 -0400 (Thu, 26 Jun 2008) | 2 lines from: http://svn.python.org/projects/python/branches/release25-maint/Lib/test/test_hmac.py@58870 ........ r4795 | zyasoft | 2008-06-26 23:14:37 -0400 (Thu, 26 Jun 2008) | 1 line Added stack_size to thread, threading since it's available since 1.4, but only as a hint to the JVM. test_re was not added in the prev commit. test_threading's test of foreign threads doesn't make sense for Jython, or so I decree ........ r4796 | pjenvey | 2008-06-26 23:25:09 -0400 (Thu, 26 Jun 2008) | 3 lines optimize _hashlib.HASH to take advantage of MessageDigest.clone which is supported for all of our hashing types ........ r4797 | pjenvey | 2008-06-26 23:26:55 -0400 (Thu, 26 Jun 2008) | 3 lines o sha is superceded by hashlib o special case test_hmac to avoid our lack of sha224 support ........ r4798 | zyasoft | 2008-06-26 23:50:14 -0400 (Thu, 26 Jun 2008) | 1 line Fixed test_bigmem to reflect Java realities. Didn't get the commit in last time of commenting out test_foreign_thread, not applicable to Jython ........ r4799 | zyasoft | 2008-06-27 00:17:33 -0400 (Fri, 27 Jun 2008) | 1 line Working too fast here, here's the test_bigmem.py fixes. Also added all methods to threading such that it passes tests in test_contextlib ........ r4800 | pjenvey | 2008-06-27 00:27:32 -0400 (Fri, 27 Jun 2008) | 2 lines from: http://svn.python.org/projects/python/branches/release25-maint/Lib/fileinput.py@42507 ........ r4801 | pjenvey | 2008-06-27 00:28:43 -0400 (Fri, 27 Jun 2008) | 1 line reapply Jython workaround for lack of fstat ........ r4802 | zyasoft | 2008-06-27 00:30:59 -0400 (Fri, 27 Jun 2008) | 1 line Enable testing of stack size changing for java platform ........ r4806 | zyasoft | 2008-06-27 00:50:06 -0400 (Fri, 27 Jun 2008) | 1 line NA'ed test_traceback.test_members since it depends on sys.exc_traceback global var, which is not implemented in Jython (not threadsafe/deprecated since Python 1.5) ........ r4807 | zyasoft | 2008-06-27 01:28:40 -0400 (Fri, 27 Jun 2008) | 1 line binascii.a2b_qp now escapes '= ' to '= '. a2b_uu takes empty strings ........ r4808 | pjenvey | 2008-06-27 01:45:44 -0400 (Fri, 27 Jun 2008) | 1 line unused var ........ r4809 | zyasoft | 2008-06-27 03:24:14 -0400 (Fri, 27 Jun 2008) | 1 line Added to os module: devnull, urandom. Worked around issue in java.io.File#mkdirs when adding directory like x/y/z/. ........ r4810 | fwierzbicki | 2008-06-27 13:47:50 -0400 (Fri, 27 Jun 2008) | 8 lines Cleaned up Call node creation, and now gen expressions are checked from both sides so that: foo(x for x in range(10), 100) foo(100, x for x in range(10)) properly fail. ........ r4821 | zyasoft | 2008-06-30 03:06:55 -0400 (Mon, 30 Jun 2008) | 1 line Rewrote cStringIO to use StringBuffer instead of managing its own buffer (also not StringBuilder) ........ r4822 | zyasoft | 2008-06-30 03:41:08 -0400 (Mon, 30 Jun 2008) | 1 line Fixed cStringIO to support ops for cPickle ........ r4823 | zyasoft | 2008-06-30 04:18:38 -0400 (Mon, 30 Jun 2008) | 1 line Fixed unicode coercion for str.__mod__ with unicode args ........ r4824 | zyasoft | 2008-06-30 04:59:43 -0400 (Mon, 30 Jun 2008) | 1 line Fixed unicode coercion logic for PyString.__mod__. Removed 2.5 contextlib.py in favor of direct from CPythonLib ........ r4825 | zyasoft | 2008-06-30 12:14:30 -0400 (Mon, 30 Jun 2008) | 1 line Change cStringIO to use StringBuilder semantics. Use via thread confinement, or with external locking. Keep it simple, keep it lightweight. ........ r4826 | zyasoft | 2008-06-30 14:08:37 -0400 (Mon, 30 Jun 2008) | 1 line Restored cStringIO.getString ........ r4827 | zyasoft | 2008-07-01 09:52:38 -0400 (Tue, 01 Jul 2008) | 1 line Removed modules and tests exactly duplicated from CPythonLib ........ r4828 | zyasoft | 2008-07-01 11:50:43 -0400 (Tue, 01 Jul 2008) | 1 line Removed modules/tests that are trivially changed with respect to CPythonLib ........ r4829 | zyasoft | 2008-07-01 13:21:43 -0400 (Tue, 01 Jul 2008) | 1 line Removed modules/tests that should be updated to CPythonLib. Incidentally, test_cmath now tests that cmath.log takes a base ........ r4830 | zyasoft | 2008-07-01 16:38:05 -0400 (Tue, 01 Jul 2008) | 1 line test_mailbox has been rewritten since 2.2, the version that was committed ........ r4831 | zyasoft | 2008-07-01 17:12:34 -0400 (Tue, 01 Jul 2008) | 1 line Removed spurious placement of test_bigmem ........ r4832 | leosoto | 2008-07-01 17:30:12 -0400 (Tue, 01 Jul 2008) | 1 line pyBoolean.__tojava__(Object.class) now returns a Boolean instead of an Integer. Also used valueOf static methods instead of constructors. ........ r4833 | zyasoft | 2008-07-01 18:02:55 -0400 (Tue, 01 Jul 2008) | 1 line cStringIO#readline should not insert backslash-n (ambigous reading, but CPython implementation says otherwise) ........ r4834 | leosoto | 2008-07-01 18:24:50 -0400 (Tue, 01 Jul 2008) | 1 line zxJDBC: Added BigInteger support to the PostgreSQLDataHandler ........ r4835 | leosoto | 2008-07-01 19:38:37 -0400 (Tue, 01 Jul 2008) | 1 line zxJDBC: Avoid preparing a statement when executemany() is called with an empty sequence ........ r4836 | leosoto | 2008-07-01 20:33:20 -0400 (Tue, 01 Jul 2008) | 1 line Workaround for issue 1047. At least on my system (jdk 1.6.0_06) it makes pulldom usable ........ r4837 | leosoto | 2008-07-01 23:51:43 -0400 (Tue, 01 Jul 2008) | 1 line Another string interpolation fix, this time when the left operand is an unicode containing non-ascii chars and there are no unicodes on the right argument ........ r4838 | zyasoft | 2008-07-02 01:56:10 -0400 (Wed, 02 Jul 2008) | 1 line cmath.log now takes a base parameter; all functions now test for ValueError to reraise as a TypeError, to be consistent with CPython ........ r4839 | leosoto | 2008-07-02 16:17:29 -0400 (Wed, 02 Jul 2008) | 1 line Updated eclipse configuration to use the antlr3.1b1 JAR instead of 3.0.1 ........ r4840 | leosoto | 2008-07-02 17:09:14 -0400 (Wed, 02 Jul 2008) | 1 line Syncing PyBaseExceptionDerived ........ r4841 | leosoto | 2008-07-02 17:43:16 -0400 (Wed, 02 Jul 2008) | 1 line Fixing Derived#__cmp__ to avoid raise TypeError when __cmp__ has not been overrided and super.__cmp__() returns -2 (see #1031) ........ r4842 | leosoto | 2008-07-02 20:36:50 -0400 (Wed, 02 Jul 2008) | 1 line Enable utf-8 source encoding support (the test_cookielib issue was fixed upstream: http://bugs.python.org/issue3261). Also recognize 'latin-1' as an alias for 'iso8859-1' ........ r4843 | leosoto | 2008-07-02 22:39:07 -0400 (Wed, 02 Jul 2008) | 1 line Limiting the buffer size used for discovering the encoding, to avoid crashing when reading big files (such as django/tests/regressiontests/forms/fields.py), as the default size of BufferedReader was too close to the readlimit set by the mark() call ........ r4845 | fwierzbicki | 2008-07-03 21:13:07 -0400 (Thu, 03 Jul 2008) | 3 lines change token name from ENDMARK to ENDMARKER to better fit with CPython's Grammar/Grammar file. Alse some tabs->spaces. ........ r4846 | fwierzbicki | 2008-07-03 21:49:41 -0400 (Thu, 03 Jul 2008) | 3 lines Introduced ENDMARKER to Python.g -- needed for files that lack a newline. ........ r4847 | fwierzbicki | 2008-07-03 22:01:44 -0400 (Thu, 03 Jul 2008) | 2 lines import test_support. ........ r4848 | fwierzbicki | 2008-07-04 08:21:30 -0400 (Fri, 04 Jul 2008) | 3 lines Removed ENDMARKER from Python.g and applied Leo Soto's patch to add a newline to the end of input that ends w/o a newline. ........ r4849 | fwierzbicki | 2008-07-04 08:33:14 -0400 (Fri, 04 Jul 2008) | 2 lines Formatting and remove unused variable. ........ r4850 | fwierzbicki | 2008-07-04 17:25:24 -0400 (Fri, 04 Jul 2008) | 3 lines Moved the actual emit of the generated newline (for input w/o a newline) to *after* dedents are emitted. ........ r4852 | leosoto | 2008-07-05 20:37:12 -0400 (Sat, 05 Jul 2008) | 20 lines StringFormatter: '%d' and '%f' support for the __int__ and __float__ protocol respectively. The implementation is more convulted than it should be, because we have PyString implementing __float__ and __int__ at the "java level" but not at the "python level". For string formatting, only "python level" __float__ and __int__ must be supported. Also, considering that __int__ can return a PyLong, this case needs special care. Basically formatInteger now can call formatLong if a PyLong is found as the result of calling __int__. Then, as formatLong can also be called from formatInteger, __hex__, __oct__ and __str__ conversions were moved inside formatLong. Finally, test_format_jy was changed to stop checking that we don't support big floats on '%d' (CPython doesn't, but that seems a limitation of the specific implementation and I can't imagine a program that could break on Jython because we *support* it). ........ r4853 | pjenvey | 2008-07-05 21:51:20 -0400 (Sat, 05 Jul 2008) | 1 line always recompile bytecode from zipimporter too ........ r4855 | fwierzbicki | 2008-07-07 05:08:22 -0400 (Mon, 07 Jul 2008) | 3 lines Create a jython-complete.jar to make it easier to put out a 2.5 alpha. ........ r4856 | zyasoft | 2008-07-07 07:22:16 -0400 (Mon, 07 Jul 2008) | 1 line Removed double-checked locking used to init ThreadStateMap; didn't make sense to do any locking here anyway. Moved trycatch emit in visitWith to be where it ahappens (doesn't change output, but makes it easier to follow code). ........ r4857 | pjenvey | 2008-07-07 15:59:32 -0400 (Mon, 07 Jul 2008) | 1 line no need to go through __builtin__ for issubclass ........ r4859 | pjenvey | 2008-07-07 19:21:43 -0400 (Mon, 07 Jul 2008) | 1 line simplify ........ r4863 | pjenvey | 2008-07-07 21:14:55 -0400 (Mon, 07 Jul 2008) | 2 lines from: http://svn.python.org/projects/python/branches/release25-maint/Lib/test/test_enumerate.py@39608 ........ r4864 | pjenvey | 2008-07-07 21:15:40 -0400 (Mon, 07 Jul 2008) | 1 line avoid implementation detail tests ........ r4865 | pjenvey | 2008-07-08 01:20:37 -0400 (Tue, 08 Jul 2008) | 2 lines from: http://svn.python.org/projects/python/branches/release25-maint/Lib/test/test_iter.py@33742 ........ r4866 | pjenvey | 2008-07-08 01:24:17 -0400 (Tue, 08 Jul 2008) | 4 lines o make StopIteration (and the like) a 'sink state' in iter and call-iter, to fix the test_iter test_sinkstate_* tests o workaround test_iter test_unpack_iter GC related issues ........ r4867 | pjenvey | 2008-07-08 01:37:05 -0400 (Tue, 08 Jul 2008) | 5 lines o wrap the fstat usage in is_jython instead of commenting it out o "sync" with: http://svn.python.org/projects/python/branches/release25-maint/Lib/test/test_largefile.py@33923 (no changes; equiv to 2.3's) ........ r4868 | pjenvey | 2008-07-08 02:20:46 -0400 (Tue, 08 Jul 2008) | 4 lines from: http://svn.python.org/projects/python/branches/release25-maint/Lib/test/test_repr.py@58123 http://svn.python.org/projects/python/branches/release25-maint/Lib/test/test_richcmp.py@43274 ........ r4869 | pjenvey | 2008-07-08 03:27:03 -0400 (Tue, 08 Jul 2008) | 4 lines o workaround jython issues in test_richcmp and test_repr o our custom test_operations isn't really necessary and we pass stdlib's. also now pass stdlib's test_long ........ r4870 | fwierzbicki | 2008-07-08 04:59:37 -0400 (Tue, 08 Jul 2008) | 2 lines some tweaks to help the install task. ........ r4876 | pjenvey | 2008-07-08 15:55:47 -0400 (Tue, 08 Jul 2008) | 3 lines always re-generating byte code is more trouble than it's worth right now (breaks the imp module) ........ r4877 | pjenvey | 2008-07-08 16:38:02 -0400 (Tue, 08 Jul 2008) | 5 lines from: http://svn.python.org/projects/python/branches/release25-maint/Lib/test/test_scope.py@50493 http://svn.python.org/projects/python/branches/release25-maint/Lib/test/test_types.py@51140 http://svn.python.org/projects/python/branches/release25-maint/Lib/test/test_zlib.py@62236 ........ r4878 | pjenvey | 2008-07-08 17:05:48 -0400 (Tue, 08 Jul 2008) | 4 lines o allow a length argument to zlib decompressobj flush o workarounds for 2.5 test_scope test_types (which output now matches stdlib's) and test_zlib ........ r4879 | pjenvey | 2008-07-08 20:41:01 -0400 (Tue, 08 Jul 2008) | 3 lines from: http://svn.python.org/projects/python/branches/release25-maint/Lib/platform.py@62855 ........ r4880 | pjenvey | 2008-07-08 20:42:59 -0400 (Tue, 08 Jul 2008) | 1 line s/java.os/os/g ........ r4881 | nriley | 2008-07-08 23:50:19 -0400 (Tue, 08 Jul 2008) | 1 line overriding fillInStackTrace for PyException speeds things up quite a bit ........ r4882 | nriley | 2008-07-10 01:12:05 -0400 (Thu, 10 Jul 2008) | 1 line need bash to test the script, too ........ r4883 | leosoto | 2008-07-10 15:51:37 -0400 (Thu, 10 Jul 2008) | 1 line zxJDBC: Map SQLExceptions to zxJDBC.IntegrityError if the sqlState says the exception was caused by a integrity violation ........ r4884 | pjenvey | 2008-07-10 23:36:29 -0400 (Thu, 10 Jul 2008) | 2 lines from: http://svn.python.org/projects/python/branches/release25-maint/Lib/test/test_support.py@60337 ........ r4885 | pjenvey | 2008-07-10 23:46:09 -0400 (Thu, 10 Jul 2008) | 3 lines add a -j option to regrtest for capturing test output to JUnit XML files (one file per TestCase or module import or doctest) in the specified dir ........ r4887 | fwierzbicki | 2008-07-11 07:52:55 -0400 (Fri, 11 Jul 2008) | 3 lines move "not needed" checks into separate task because all such tasks *are* needed during a full build regardless of up to date status of files. ........ r4888 | zyasoft | 2008-07-11 08:16:28 -0400 (Fri, 11 Jul 2008) | 1 line Begin port of PyPy's _rawffi, which with their pure-Python ctypes wrapper, implements ctypes ........ r4889 | fwierzbicki | 2008-07-11 08:45:41 -0400 (Fri, 11 Jul 2008) | 4 lines added svnant-jars by default for more convenient full-build. Fixed jarjar and jar-complete (so jarjar only recompiles on changes and jar-complete properly depends on jarjar). ........ r4890 | zyasoft | 2008-07-11 10:05:13 -0400 (Fri, 11 Jul 2008) | 1 line From PyPy's test__rawffi, broke out standard ctypes_test code they use (to avoid using their compilation toolchain). Implemented minimum to get test__rawffi.test_short_addition to pass. ........ r4891 | pjenvey | 2008-07-11 15:37:19 -0400 (Fri, 11 Jul 2008) | 1 line test_pep263 passes now ........ r4892 | pjenvey | 2008-07-11 16:10:32 -0400 (Fri, 11 Jul 2008) | 3 lines from: http://svn.python.org/projects/python/branches/release25-maint/Lib/test/string_tests.py@55878 ........ r4893 | pjenvey | 2008-07-11 16:16:53 -0400 (Fri, 11 Jul 2008) | 5 lines o re-integrate workarounds for string_tests o add rsplit fixes #1023 thanks Nimish Telang ........ r4894 | pjenvey | 2008-07-11 20:10:28 -0400 (Fri, 11 Jul 2008) | 2 lines fix unicode(str_subclass) not using its __unicode__ method ........ r4895 | pjenvey | 2008-07-11 20:13:15 -0400 (Fri, 11 Jul 2008) | 3 lines fix some odder 2.5 tests of string count/find/rfind. rewrite join to act like CPython's, mainly so: a.join([b]) is b ........ r4896 | pjenvey | 2008-07-11 20:33:21 -0400 (Fri, 11 Jul 2008) | 1 line fix java exception names being prefixed with <unknown> in Python tracebacks ........ r4897 | pjenvey | 2008-07-11 20:53:44 -0400 (Fri, 11 Jul 2008) | 1 line fake reload(sys), like reload(PyJavaClass). fix ClassCastException in reload ........ r4901 | pjenvey | 2008-07-11 21:28:39 -0400 (Fri, 11 Jul 2008) | 1 line expect test_mhlib to pass on posix and skip elsewhere ........ r4902 | zyasoft | 2008-07-12 05:13:38 -0400 (Sat, 12 Jul 2008) | 1 line Removed tests not appropriate for Jython, test_peepholer, test_profile; added test_strptime, test_csv ........ r4903 | zyasoft | 2008-07-12 06:08:11 -0400 (Sat, 12 Jul 2008) | 1 line Replaced Lib/datetime.py with version from PyPy, http://codespeak.net/svn/pypy/dist/pypy/lib/datetime.py@56484 ........ r4904 | zyasoft | 2008-07-12 09:50:19 -0400 (Sat, 12 Jul 2008) | 1 line Fixed str|string|unicode.replace for PyString or PyUnicode in the basic plane ........ r4905 | zyasoft | 2008-07-12 09:51:06 -0400 (Sat, 12 Jul 2008) | 1 line Removed tests not relevant to Jython around CPython code compilation ........ r4906 | zyasoft | 2008-07-12 10:09:20 -0400 (Sat, 12 Jul 2008) | 1 line Operations on unicode objs in basic plane can only result in basic plane objs (btw, not true of astral) ........ r4907 | zyasoft | 2008-07-12 11:42:09 -0400 (Sat, 12 Jul 2008) | 1 line Added datetime.strptime ........ r4908 | zyasoft | 2008-07-12 11:55:44 -0400 (Sat, 12 Jul 2008) | 1 line datetime.fromtimestamp now rounds seconds,microseconds within 1 microsecond of an integer second to that second ........ r4909 | zyasoft | 2008-07-12 12:50:22 -0400 (Sat, 12 Jul 2008) | 1 line ascii codec will always be in basic plane, so at least optimize setting of that when constructing unicode ........ r4910 | leosoto | 2008-07-12 15:50:43 -0400 (Sat, 12 Jul 2008) | 1 line Now test_strptime pass. This is done by improving the current SimpleDateFormat-backed implementation a bit, and delegating to _strptime.strptime for formats not supported by SimpleDateFormat. ........ r4911 | leosoto | 2008-07-12 15:52:59 -0400 (Sat, 12 Jul 2008) | 1 line Removing a duplicate line on CPythonLib.includes I introduced on r4910 ........ r4912 | pjenvey | 2008-07-12 15:57:48 -0400 (Sat, 12 Jul 2008) | 4 lines o add popen2.cleanup for CPython compat. and to fix test_popen2 o make threading.currentThread() is threading.currentThread() (with the help of a WeakKeyDictionary) to allow _threading_local to work ........ r4913 | pjenvey | 2008-07-12 20:47:08 -0400 (Sat, 12 Jul 2008) | 4 lines max_read_chunk of 10mb kills test_gzip.test_many_append's performance due to repeated 10mb reads. CPython doesn't suffer from this -- maybe its allocator recycles the same 10mb. lowering to 256K speeds test time from 15 to 1 second ........ r4914 | pjenvey | 2008-07-12 22:07:51 -0400 (Sat, 12 Jul 2008) | 1 line add C_EXTENSION because pkgutil references it ........ r4916 | pjenvey | 2008-07-12 23:36:31 -0400 (Sat, 12 Jul 2008) | 2 lines fix to make the 'g' formatter closer to CPython's. fixes test_tokenize ........ r4917 | zyasoft | 2008-07-14 06:47:01 -0400 (Mon, 14 Jul 2008) | 1 line split and rsplit do not need to be UTF-16 aware ........ r4918 | zyasoft | 2008-07-14 06:52:18 -0400 (Mon, 14 Jul 2008) | 3 lines From http://svn.python.org/projects/python/branches/release25-maint/Lib/test/test_str@64946 ........ r4919 | zyasoft | 2008-07-14 07:03:54 -0400 (Mon, 14 Jul 2008) | 1 line Removed inapplicable test due to different algorithm in expandtabs which cannot overflow in Jython ........ r4922 | zyasoft | 2008-07-14 07:44:28 -0400 (Mon, 14 Jul 2008) | 1 line time.struct_time can now take any obj that can be turned into a list and converted into 9 integers ........ r4924 | zyasoft | 2008-07-14 08:11:26 -0400 (Mon, 14 Jul 2008) | 3 lines From http://svn.python.org/projects/python/branches/release25-maint/Lib/uu.py@64946 ........ r4925 | zyasoft | 2008-07-14 08:19:10 -0400 (Mon, 14 Jul 2008) | 2 lines Fixed uu.encode, decode so that it does not rely on refcounting to close files ........ r4928 | zyasoft | 2008-07-14 11:19:01 -0400 (Mon, 14 Jul 2008) | 3 lines ReferenceQueue objs, by their nature, only make sense if transient. So make them so, this enables interoperation with Terracotta. ........ r4930 | pjenvey | 2008-07-14 15:24:49 -0400 (Mon, 14 Jul 2008) | 1 line couple small array fixes ........ r4932 | fwierzbicki | 2008-07-14 15:25:59 -0400 (Mon, 14 Jul 2008) | 2 lines unbreak --memo again :) ........ r4933 | pjenvey | 2008-07-14 15:26:58 -0400 (Mon, 14 Jul 2008) | 3 lines from: http://svn.python.org/projects/python/branches/release25-maint/Lib/distutils@64955 ........ r4934 | fwierzbicki | 2008-07-14 15:27:40 -0400 (Mon, 14 Jul 2008) | 3 lines generate newlines before the dedents again. Although the reverse was solving some problems, it was creating more. ........ r4935 | pjenvey | 2008-07-14 15:31:38 -0400 (Mon, 14 Jul 2008) | 3 lines o re-integrate Jython distutils changes o check for $py.class on Jython instead of pyc in test_build_py ........ r4936 | leosoto | 2008-07-14 16:12:27 -0400 (Mon, 14 Jul 2008) | 1 line Allow derived types written in Jython to implement a __tojava__ method. This will allow better integration with java for python types such as decimal.Decimal, datetime.date, etc. ........ r4937 | fwierzbicki | 2008-07-15 11:23:32 -0400 (Tue, 15 Jul 2008) | 4 lines Fixes in build.xml to make full-build work again. Some cleanup like the removal of old parser and old website tasks. Changed README to describe 2.5 alpha release. ........ r4939 | leosoto | 2008-07-15 12:13:50 -0400 (Tue, 15 Jul 2008) | 1 line decimal.py from http://svn.python.org/projects/python/branches/release25-maint/Lib/decimal.py@64967 ........ r4940 | leosoto | 2008-07-15 12:24:18 -0400 (Tue, 15 Jul 2008) | 1 line Implemented decimal.Decimal.__tojava__ to convert decimal instances to java BigDecimal when python -> java conversion is requested ........ r4941 | leosoto | 2008-07-15 13:16:16 -0400 (Tue, 15 Jul 2008) | 1 line Implemented __tojava__ on datetime.time, datetime.date and datetime.datetime. On the current implementation, they can be converted to java.sql.Time, java.sql.Date, java.sql.Timestamp, respectively. All of them can also be converted to java.util.Calendar. Only one caveat: the tzinfo attribute of times and datetimes is currently ignored ........ r4942 | leosoto | 2008-07-15 14:00:57 -0400 (Tue, 15 Jul 2008) | 1 line Removing decimal.py from CPythonLib.includes. I forgot to do that on r4939 ........ r4943 | fwierzbicki | 2008-07-15 14:33:40 -0400 (Tue, 15 Jul 2008) | 2 lines build tweaks + workaround for an NT problem in site.py ........ r4944 | nriley | 2008-07-15 14:42:08 -0400 (Tue, 15 Jul 2008) | 1 line fix for startup problem on Windows - AttributeError was accidentally trapping posixpath abspath failure ........ r4945 | fwierzbicki | 2008-07-15 15:27:53 -0400 (Tue, 15 Jul 2008) | 3 lines already incrementing to 2.5a1 -- sourceforge is caching the old one too hard and I really need to get Windows fixed. ........ r4947 | leosoto | 2008-07-15 17:21:30 -0400 (Tue, 15 Jul 2008) | 18 lines Improvements to the zxJDBC default DataHandler: - Map DATE, TIME and TIMESTAMP columns to datetime.date, datetime.time and datetime.datetime respectively. Factory methods to create instances of datetime.* were added to Py.java. - Map VARCHAR columns to unicode instead of str. - Don't try to guess the precision of NUMERIC columns . - Use Py.True and Py.False instead of Py.One and Py.Zero. Some of this changes may cause backwards-incompatibility, so I've copied the old DataHandler logic into Jython22DataHandler. Then, old code should simply setup this datahandler on its connections if it is not going to be adapted to the new DataHandler default behaviour. ........ r4949 | amak | 2008-07-15 17:33:35 -0400 (Tue, 15 Jul 2008) | 1 line Merging support for IPv6 and UDP <broadcast> ........ r4950 | nriley | 2008-07-15 18:33:04 -0400 (Tue, 15 Jul 2008) | 1 line (Partial) Windows port of Jython launcher script; should work on Windows 2000 and later. ........ r4951 | nriley | 2008-07-15 18:37:38 -0400 (Tue, 15 Jul 2008) | 1 line Oops, left some debugging code in. ........ r4952 | amak | 2008-07-15 18:51:51 -0400 (Tue, 15 Jul 2008) | 1 line Backing out what I thought were simple changes, which appear to have broken the build. ........ r4959 | pjenvey | 2008-07-16 21:23:59 -0400 (Wed, 16 Jul 2008) | 1 line add symlink on posix ........ r4961 | pjenvey | 2008-07-16 23:21:35 -0400 (Wed, 16 Jul 2008) | 5 lines fix the symlink related tests by adding readlink, using _posix.lstat and utilizing _posix symlink stuff in posixpath. also utilize real stat results in posixpath, and re-enable ismount in ntpath since we can support it in posixpath ........ r4963 | pjenvey | 2008-07-17 00:59:53 -0400 (Thu, 17 Jul 2008) | 9 lines o fix PythonPOSIXHandler getEnv/getCurrentWorkingDirectory return signatures o fix posixpath.__all__ o only enable os.symlink/readlink and posixpath friends if the posix factory appears native. pure java support for symlinks is still sketchy -- in particular with dead links -- switching these on enables tests in test_glob, test_posixpath, test_tarfile that utilize dead links and are doomed to failure o allow partial filling of stat results from jna-posix, padding the rest with 0s ........ r4965 | fwierzbicki | 2008-07-17 17:19:56 -0400 (Thu, 17 Jul 2008) | 2 lines added custom toStringTree to each node. ........ r4967 | pjenvey | 2008-07-17 20:28:49 -0400 (Thu, 17 Jul 2008) | 3 lines boost the mark limit even higher for the lenghty lines in pygments.lexers._vimbuiltins ........ r4968 | nriley | 2008-07-18 15:20:39 -0400 (Fri, 18 Jul 2008) | 1 line Work with jython-complete.jar; handle spaces in $JAVA_HOME. ........ r4969 | nriley | 2008-07-18 15:21:37 -0400 (Fri, 18 Jul 2008) | 1 line Actually use JYTHON_OPTS; correct error message and properly delete _JYTHON_HOME. ........ r4970 | nriley | 2008-07-18 16:40:17 -0400 (Fri, 18 Jul 2008) | 1 line Make ant regrtest work on Windows again. ........ r4971 | nriley | 2008-07-18 16:51:00 -0400 (Fri, 18 Jul 2008) | 1 line Conditionalize launcher test; no need for Cygwin test. ........ r4973 | nriley | 2008-07-19 01:54:20 -0400 (Sat, 19 Jul 2008) | 1 line Clean up install targets; allow install to be run without full-build; normalize source directory structure between checked-out and installed versions. ........ r4974 | fwierzbicki | 2008-07-19 18:48:21 -0400 (Sat, 19 Jul 2008) | 4 lines Make PythonTree's toStringTree more easily comparable with ast/astview.py output. This will help with the walkerless Python.g, as it doesn't quite parse ast/astview.py yet. ........ r4980 | pjenvey | 2008-07-21 01:00:49 -0400 (Mon, 21 Jul 2008) | 1 line integrate the sink state conditions ........ r4982 | pjenvey | 2008-07-21 15:11:48 -0400 (Mon, 21 Jul 2008) | 1 line fix exposed __getitem__ possibly returning null ........ r4983 | pjenvey | 2008-07-21 15:45:12 -0400 (Mon, 21 Jul 2008) | 3 lines o fix filter to pass test_builtin.test_filter and test_filter_subclasses o remove the unnecessary __builtin__.tuple ........ r4984 | pjenvey | 2008-07-21 15:48:17 -0400 (Mon, 21 Jul 2008) | 1 line make the failure verbose because test_site_flag occasionally fails on the buildbot mysteriously ........ r4985 | pjenvey | 2008-07-22 21:18:53 -0400 (Tue, 22 Jul 2008) | 4 lines o make Py.makeCharacter consisitent in never returning unicode unless it was asked for o move calculateIndex into PySequence for PyArray o allow PyLong.getLong access for PyArray ........ r4986 | pjenvey | 2008-07-22 21:19:34 -0400 (Tue, 22 Jul 2008) | 2 lines from: http://svn.python.org/projects/python/branches/release25-maint/Lib/test/test_array.py@60839 ........ r4987 | pjenvey | 2008-07-22 21:21:32 -0400 (Tue, 22 Jul 2008) | 1 line many various PyArray fixes for 2.5 test_array ........ r4988 | fwierzbicki | 2008-07-22 21:58:01 -0400 (Tue, 22 Jul 2008) | 4 lines Made Str offsets better match CPython. PythonTree now extends BaseTree (too much of CommonTree was getting changed anyway). astdump.py repaired so that it is a useful testing ground for ast comparisons. ........ r4989 | fwierzbicki | 2008-07-23 14:39:09 -0400 (Wed, 23 Jul 2008) | 2 lines Offset fixes for Try/Catch and Call. ........ r4990 | fwierzbicki | 2008-07-23 15:13:04 -0400 (Wed, 23 Jul 2008) | 6 lines Made except blocks optional in PythonPartial.g since: try: Is a valid partial parse. ........ r4991 | pjenvey | 2008-07-23 16:36:42 -0400 (Wed, 23 Jul 2008) | 2 lines o fix passing chars > 256 to Py.makeCharacter o make struct.error a class and raise struct.errors instead of OverflowErrors ........ r4992 | pjenvey | 2008-07-23 16:55:03 -0400 (Wed, 23 Jul 2008) | 3 lines support the new float.__get/setformat__ classmethods -- they just claim our formats are 'unknown' ........ r4993 | pjenvey | 2008-07-24 03:22:38 -0400 (Thu, 24 Jul 2008) | 2 lines fix a regression from the bug 1140 fix ........ r4994 | pjenvey | 2008-07-24 03:29:54 -0400 (Thu, 24 Jul 2008) | 3 lines add codecs.charmap_build which builds optimized encoding maps now used by the charmap encoder ........ r4995 | fwierzbicki | 2008-07-24 09:51:47 -0400 (Thu, 24 Jul 2008) | 2 lines Make stopCharIndex consistent. ........ r4996 | fwierzbicki | 2008-07-24 12:58:24 -0400 (Thu, 24 Jul 2008) | 2 lines Fix for wrong line numbers in func.co_firstlineno. ........ r4997 | pjenvey | 2008-07-24 19:42:09 -0400 (Thu, 24 Jul 2008) | 1 line cleanup unused var ........ r4998 | nriley | 2008-07-25 02:07:24 -0400 (Fri, 25 Jul 2008) | 1 line Suppress exception truncating /dev/null when opening it for write on Linux and Solaris; should fix test_os. ........ r4999 | fwierzbicki | 2008-07-25 21:27:25 -0400 (Fri, 25 Jul 2008) | 3 lines Re-enabled APIVersion checking in imp.java. Used ASM to read and write APIVersion as an annotation. Incremented APIVersion from 12 to 13. ........ r5000 | fwierzbicki | 2008-07-25 21:34:48 -0400 (Fri, 25 Jul 2008) | 2 lines Small cleanups in imp. ........ r5001 | fwierzbicki | 2008-07-25 21:51:48 -0400 (Fri, 25 Jul 2008) | 2 lines Small cleanup in Py.java -- killing stray System.outs. ........ r5002 | fwierzbicki | 2008-07-25 21:55:04 -0400 (Fri, 25 Jul 2008) | 2 lines Removed stray System.outs. ........ r5003 | fwierzbicki | 2008-07-26 10:41:46 -0400 (Sat, 26 Jul 2008) | 2 lines Changing comment convention back to proper style (start with Returns). ........ r5004 | fwierzbicki | 2008-07-27 09:21:12 -0400 (Sun, 27 Jul 2008) | 2 lines comment out DEBUG.class in the repo. ........ r5005 | fwierzbicki | 2008-07-27 22:41:38 -0400 (Sun, 27 Jul 2008) | 2 lines Better error messages in the face of parser errors (line numbers + char column). ........ r5006 | pjenvey | 2008-07-28 00:56:03 -0400 (Mon, 28 Jul 2008) | 3 lines o add os.link (fixes test_shutil) o fix test_re's test output -- it shouldn't have any now ........ r5007 | pjenvey | 2008-07-28 02:38:44 -0400 (Mon, 28 Jul 2008) | 7 lines PEP 357 (__index__), adds: o PyObject.isIndex - true if int, long or implements __index__ o PyObject.asIndex - like asInt for indexes o also fixed a dispatching to __get/set/delitem__ vs __get/set/delslice__ bug and __get/set/delitem__ indices weren't utilizing __len__ when available (fixes test_userstring) ........ r5008 | pjenvey | 2008-07-28 02:40:09 -0400 (Mon, 28 Jul 2008) | 2 lines deriveds changes for __index__ ........ r5009 | zyasoft | 2008-07-28 07:51:51 -0400 (Mon, 28 Jul 2008) | 3 lines test__rawffi will now skip if it cannot load ctypes_test, a test dynamic library that we do not yet have an ant task to create. ........ r5010 | zyasoft | 2008-07-28 08:13:52 -0400 (Mon, 28 Jul 2008) | 3 lines Replaced test_inspect.py with rewritten version (using unittest!) from 2.5: http://svn.python.org/projects/python/branches/release25-maint/Lib/test/test_inspect.py@65262 ........ r5011 | zyasoft | 2008-07-28 09:33:50 -0400 (Mon, 28 Jul 2008) | 5 lines Excluded test cases that depend on tuple unpacking in the arg specification, since this depends on introspecing bytecode. (Perhaps we should provide a Jython-specific version where appropriate metadata is emitted in the compiled code object?) ........ r5012 | pjenvey | 2008-07-28 15:46:39 -0400 (Mon, 28 Jul 2008) | 5 lines fix stock UserList/test_userlist: o handle __get/set/delslice__ start/stop as null or None in PySlice.indices2 o fix list slice assignments of the same underlying list (always copy first as CPython does) ........ r5013 | pjenvey | 2008-07-28 15:50:43 -0400 (Mon, 28 Jul 2008) | 1 line include UserList ........ r5014 | nriley | 2008-07-28 18:55:35 -0400 (Mon, 28 Jul 2008) | 1 line jna-posix from http://svn.codehaus.org/jruby-contrib/trunk/jna-posix r210 ........ r5015 | nriley | 2008-07-28 18:56:55 -0400 (Mon, 28 Jul 2008) | 1 line pwd, grp; test_posix no longer skipped ........ r5016 | pjenvey | 2008-07-28 19:13:21 -0400 (Mon, 28 Jul 2008) | 1 line fix chdir('/') on windows ........ r5017 | fwierzbicki | 2008-07-28 21:40:32 -0400 (Mon, 28 Jul 2008) | 2 lines IParserHost is no longer used. ........ r5018 | fwierzbicki | 2008-07-29 08:31:46 -0400 (Tue, 29 Jul 2008) | 2 lines Move testing classes out of main code. ........ r5019 | pjenvey | 2008-07-29 16:29:08 -0400 (Tue, 29 Jul 2008) | 4 lines add an InputStream tie-in to TextIOBases, for parsing in universal newlines mode fixes #1082 ........ r5020 | zyasoft | 2008-07-29 18:33:56 -0400 (Tue, 29 Jul 2008) | 5 lines cStringIO.tell needs to return an int for it to be used by __len__ (perhaps that should be relaxed instead?). Found by testing against PyAMF which uses cStringIO as a backing store for its BufferedByteStream objs. ........ r5021 | pjenvey | 2008-07-29 18:40:05 -0400 (Tue, 29 Jul 2008) | 2 lines fix readChunk reading more than CHUNK_SIZE, which'll blow up packReadahead ........ r5022 | zyasoft | 2008-07-30 11:46:31 -0400 (Wed, 30 Jul 2008) | 4 lines Support inf, -inf, nan literals (and any uppercasing). struct.pack("d") ducktypes like CPython and calls __float__. This fixes a number of issues for PyAMF. ........ r5023 | zyasoft | 2008-07-30 15:57:16 -0400 (Wed, 30 Jul 2008) | 3 lines Changed default format for __getformat__/__setformat__ to "IEEE, big-endian", and supported switching back and forth with "unknown". ........ r5024 | pjenvey | 2008-07-30 18:39:24 -0400 (Wed, 30 Jul 2008) | 2 lines add a builtin _functools.partial type ........ r5025 | pjenvey | 2008-07-30 19:00:32 -0400 (Wed, 30 Jul 2008) | 1 line include functools ........ r5026 | fwierzbicki | 2008-07-31 09:10:57 -0400 (Thu, 31 Jul 2008) | 2 lines Switch to Antlr 3.1b2. ........ r5027 ... [truncated message content] |
From: <pj...@us...> - 2008-08-20 00:28:58
|
Revision: 5212 http://jython.svn.sourceforge.net/jython/?rev=5212&view=rev Author: pjenvey Date: 2008-08-20 00:28:55 +0000 (Wed, 20 Aug 2008) Log Message: ----------- o rename unmarshalCode -> readCode, as it doesn't relate to Python's marshal o zipimport shouldn't cacheCompiledSource (it's just been silently failing), and use java enums Modified Paths: -------------- trunk/jython/Lib/pkgutil.py trunk/jython/src/org/python/core/imp.java trunk/jython/src/org/python/modules/zipimport/zipimporter.java Modified: trunk/jython/Lib/pkgutil.py =================================================================== --- trunk/jython/Lib/pkgutil.py 2008-08-19 23:34:29 UTC (rev 5211) +++ trunk/jython/Lib/pkgutil.py 2008-08-20 00:28:55 UTC (rev 5212) @@ -22,7 +22,7 @@ # accessed by _imp here def read_jython_code(fullname, file, filename): - data = _imp.unmarshalCode(filename, file, False) + data = _imp.readCode(filename, file, False) return BytecodeLoader.makeCode(fullname + "$py", data, filename) def simplegeneric(func): Modified: trunk/jython/src/org/python/core/imp.java =================================================================== --- trunk/jython/src/org/python/core/imp.java 2008-08-19 23:34:29 UTC (rev 5211) +++ trunk/jython/src/org/python/core/imp.java 2008-08-20 00:28:55 UTC (rev 5212) @@ -87,7 +87,7 @@ static PyObject createFromPyClass(String name, InputStream fp, boolean testing, String fileName) { - byte[] data = unmarshalCode(name, fp, testing); + byte[] data = readCode(name, fp, testing); if (testing && data == null) { return null; } @@ -107,8 +107,7 @@ return createFromCode(name, code, fileName); } - public static byte[] unmarshalCode(String name, InputStream fp, - boolean testing) { + public static byte[] readCode(String name, InputStream fp, boolean testing) { byte[] data = readBytes(fp); int n = data.length; Modified: trunk/jython/src/org/python/modules/zipimport/zipimporter.java =================================================================== --- trunk/jython/src/org/python/modules/zipimport/zipimporter.java 2008-08-19 23:34:29 UTC (rev 5211) +++ trunk/jython/src/org/python/modules/zipimport/zipimporter.java 2008-08-20 00:28:55 UTC (rev 5212) @@ -6,6 +6,7 @@ import java.io.InputStream; import java.util.Date; import java.util.Enumeration; +import java.util.EnumSet; import java.util.zip.ZipEntry; import java.util.zip.ZipFile; @@ -51,19 +52,22 @@ /** zip_searchorder defines how we search for a module in the Zip * archive */ - static final int IS_SOURCE = 0; - static final int IS_BYTECODE = 1; - static final int IS_PACKAGE = 2; + static enum EntryType { + IS_SOURCE, IS_BYTECODE, IS_PACKAGE + }; static final SearchOrderEntry[] zip_searchorder = new SearchOrderEntry[] { - new SearchOrderEntry(File.separator + "__init__$py.class", IS_PACKAGE | IS_BYTECODE), - new SearchOrderEntry(File.separator + "__init__.py", IS_PACKAGE | IS_SOURCE), - new SearchOrderEntry("$py.class", IS_BYTECODE), - new SearchOrderEntry(".py", IS_SOURCE), - new SearchOrderEntry("", 0) + new SearchOrderEntry(File.separator + "__init__$py.class", + EnumSet.of(EntryType.IS_PACKAGE, EntryType.IS_BYTECODE)), + new SearchOrderEntry(File.separator + "__init__.py", + EnumSet.of(EntryType.IS_PACKAGE, EntryType.IS_SOURCE)), + new SearchOrderEntry("$py.class", EnumSet.of(EntryType.IS_BYTECODE)), + new SearchOrderEntry(".py", EnumSet.of(EntryType.IS_SOURCE)), }; /** Module information */ - static enum ModuleInfo {ERROR, NOT_FOUND, MODULE, PACKAGE}; + static enum ModuleInfo { + ERROR, NOT_FOUND, MODULE, PACKAGE + }; /** Pathname of the Zip archive */ @ExposedGet @@ -366,7 +370,7 @@ if (tocEntry == null) continue; - if ((entry.type & IS_PACKAGE) == IS_PACKAGE) { + if (entry.type.contains(EntryType.IS_PACKAGE)) { return ModuleInfo.PACKAGE; } return ModuleInfo.MODULE; @@ -399,8 +403,8 @@ continue; } - boolean ispackage = (entry.type & IS_PACKAGE) == IS_PACKAGE; - boolean isbytecode = (entry.type & IS_BYTECODE) == IS_BYTECODE; + boolean ispackage = entry.type.contains(EntryType.IS_PACKAGE); + boolean isbytecode = entry.type.contains(EntryType.IS_BYTECODE); if (isbytecode && isOutdatedBytecode(searchPath, tocEntry)) { continue; @@ -410,7 +414,7 @@ ZipBundle zipBundle = getDataStream(searchPath); byte[] codeBytes; if (isbytecode) { - codeBytes = imp.unmarshalCode(fullname, zipBundle.inputStream, true); + codeBytes = imp.readCode(fullname, zipBundle.inputStream, true); } else { codeBytes = imp.compileSource(fullname, zipBundle.inputStream, pathToEntry); @@ -422,7 +426,6 @@ continue; } - imp.cacheCompiledSource(pathToEntry, null, codeBytes); PyCode code = BytecodeLoader.makeCode(fullname + "$py", codeBytes, pathToEntry); return new ModuleCodeData(code, ispackage, pathToEntry); } @@ -661,9 +664,9 @@ */ protected static class SearchOrderEntry { public String suffix; - public int type; + public EnumSet type; - public SearchOrderEntry(String suffix, int type) { + public SearchOrderEntry(String suffix, EnumSet type) { this.suffix = suffix; this.type = type; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2008-08-20 23:01:44
|
Revision: 5227 http://jython.svn.sourceforge.net/jython/?rev=5227&view=rev Author: pjenvey Date: 2008-08-20 23:01:42 +0000 (Wed, 20 Aug 2008) Log Message: ----------- rewrite the subx joiner yet again: this time exactly as CPython does it, with __getslice__ and join. fixes a string subclass corner case Modified Paths: -------------- trunk/jython/Lib/test/test_re_jy.py trunk/jython/src/org/python/modules/sre/PatternObject.java Modified: trunk/jython/Lib/test/test_re_jy.py =================================================================== --- trunk/jython/Lib/test/test_re_jy.py 2008-08-20 20:59:44 UTC (rev 5226) +++ trunk/jython/Lib/test/test_re_jy.py 2008-08-20 23:01:42 UTC (rev 5227) @@ -8,6 +8,23 @@ result = re.sub('', lambda match : None, 'foo') self.assertEqual(result, 'foo') self.assert_(isinstance(result, str)) + + def test_sub_with_subclasses(self): + class Foo(unicode): + def join(self, items): + return Foo(unicode.join(self, items)) + result = re.sub('bar', 'baz', Foo('bar')) + self.assertEqual(result, u'baz') + self.assertEqual(type(result), unicode) + + class Foo2(unicode): + def join(self, items): + return Foo2(unicode.join(self, items)) + def __getslice__(self, start, stop): + return Foo2(unicode.__getslice__(self, start, stop)) + result = re.sub('bar', 'baz', Foo2('bar')) + self.assertEqual(result, Foo2('baz')) + self.assert_(isinstance(result, Foo2)) def test_unkown_groupname(self): self.assertRaises(IndexError, Modified: trunk/jython/src/org/python/modules/sre/PatternObject.java =================================================================== --- trunk/jython/src/org/python/modules/sre/PatternObject.java 2008-08-20 20:59:44 UTC (rev 5226) +++ trunk/jython/src/org/python/modules/sre/PatternObject.java 2008-08-20 23:01:42 UTC (rev 5227) @@ -118,7 +118,7 @@ SRE_STATE state = new SRE_STATE(string, 0, Integer.MAX_VALUE, flags); - StringBuilder buf = new StringBuilder(); + PyList list = new PyList(); int n = 0; int i = 0; @@ -137,7 +137,7 @@ if (i < b) { /* get segment before this match */ - buf.append(string.substring(i, b)); + list.append(string.__getslice__(Py.newInteger(i), Py.newInteger(b))); } if (! (i == b && i == e && n > 0)) { PyObject item; @@ -150,7 +150,7 @@ } if (item != Py.None) { - buf.append(item.toString()); + list.append(item); } i = e; n++; @@ -163,25 +163,23 @@ state.start = state.ptr; } if (i < state.endpos) { - buf.append(string.substring(i, state.endpos)); + list.append(string.__getslice__(Py.newInteger(i), Py.newInteger(state.endpos))); } - // Follows rules enumerated in test_re.test_bug_1140 - PyString outstring; - if (buf.length() == 0) { - outstring = instring.createInstance(buf.toString()); - } else if (template instanceof PyUnicode || instring instanceof PyUnicode) { - outstring = Py.newUnicode(buf.toString()); - } else { - outstring = Py.newString(buf.toString()); - } - + PyObject outstring = join_list(list, string); if (subn) { return new PyTuple(outstring, Py.newInteger(n)); } return outstring; } + private PyObject join_list(PyList list, PyString string) { + PyObject joiner = string.__getslice__(Py.Zero, Py.Zero); + if (list.size() == 0) { + return joiner; + } + return joiner.__getattr__("join").__call__(list); + } public PyObject split(PyObject[] args, String[] kws) { ArgParser ap = new ArgParser("split", args, kws, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <le...@us...> - 2008-08-21 03:23:30
|
Revision: 5229 http://jython.svn.sourceforge.net/jython/?rev=5229&view=rev Author: leosoto Date: 2008-08-21 03:23:28 +0000 (Thu, 21 Aug 2008) Log Message: ----------- Fixing #1095 for old-style classes. Thanks to Anselm Kruls for the patch. Modified Paths: -------------- trunk/jython/Lib/test/test_descr_jy.py trunk/jython/src/org/python/core/PyInstance.java Modified: trunk/jython/Lib/test/test_descr_jy.py =================================================================== --- trunk/jython/Lib/test/test_descr_jy.py 2008-08-21 02:58:24 UTC (rev 5228) +++ trunk/jython/Lib/test/test_descr_jy.py 2008-08-21 03:23:28 UTC (rev 5229) @@ -326,16 +326,34 @@ def __getattr__(self, name): raise BarAttributeError + class BarClassic: + def __getattr__(self, name): + raise BarAttributeError + class Foo(object): def __getattr__(self, name): raise AttributeError("Custom message") + + class FooClassic: + def __getattr__(self, name): + raise AttributeError("Custom message") + self.assertRaises(BarAttributeError, lambda: Bar().x) + self.assertRaises(BarAttributeError, lambda: BarClassic().x) + try: Foo().x self.assert_(False) # Previous line should raise AttributteError except AttributeError, e: self.assertEquals("Custom message", str(e)) + try: + FooClassic().x + self.assert_(False) # Previous line should raise AttributteError + except AttributeError, e: + self.assertEquals("Custom message", str(e)) + + def test_main(): test_support.run_unittest(TestDescrTestCase, SubclassDescrTestCase, Modified: trunk/jython/src/org/python/core/PyInstance.java =================================================================== --- trunk/jython/src/org/python/core/PyInstance.java 2008-08-21 02:58:24 UTC (rev 5228) +++ trunk/jython/src/org/python/core/PyInstance.java 2008-08-21 03:23:28 UTC (rev 5229) @@ -201,10 +201,19 @@ } public PyObject __findattr_ex__(String name) { - return __findattr__(name, false); + return __findattr_ex__(name, false); } public PyObject __findattr__(String name, boolean stopAtJava) { + try { + return __findattr_ex__(name, stopAtJava); + } catch (PyException exc) { + if (Py.matchException(exc, Py.AttributeError)) return null; + throw exc; + } + } + + protected PyObject __findattr_ex__(String name, boolean stopAtJava) { PyObject result = ifindlocal(name); if (result != null) return result; @@ -234,12 +243,7 @@ if (getter == null) return null; - try { - return getter.__call__(this, new PyString(name)); - } catch (PyException exc) { - if (Py.matchException(exc, Py.AttributeError)) return null; - throw exc; - } + return getter.__call__(this, new PyString(name)); } public boolean isCallable() { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2008-08-22 20:17:02
|
Revision: 5234 http://jython.svn.sourceforge.net/jython/?rev=5234&view=rev Author: pjenvey Date: 2008-08-22 20:16:59 +0000 (Fri, 22 Aug 2008) Log Message: ----------- fix unicode __add__ and repeat always forcing the basic plane on the result -- can't optimize for strs when unicode also uses these methods Modified Paths: -------------- trunk/jython/src/org/python/core/PyString.java Added Paths: ----------- trunk/jython/Lib/test/test_unicode_jy.py Added: trunk/jython/Lib/test/test_unicode_jy.py =================================================================== --- trunk/jython/Lib/test/test_unicode_jy.py (rev 0) +++ trunk/jython/Lib/test/test_unicode_jy.py 2008-08-22 20:16:59 UTC (rev 5234) @@ -0,0 +1,28 @@ +"""Misc unicode tests + +Made for Jython. +""" +import re +import unittest +from test import test_support + +class UnicodeTestCase(unittest.TestCase): + + def test_simplejson_plane_bug(self): + # a bug exposed by simplejson: unicode __add__ was always + # forcing the basic plane + chunker = re.compile(r'(.*?)(["\\\x00-\x1f])', re.VERBOSE | re.MULTILINE | re.DOTALL) + orig = u'z\U0001d120x' + quoted1 = u'"z\U0001d120x"' + quoted2 = '"' + orig + '"' + # chunker re gives different results depending on the plane + self.assertEqual(chunker.match(quoted1, 1).groups(), (orig, u'"')) + self.assertEqual(chunker.match(quoted2, 1).groups(), (orig, u'"')) + + +def test_main(): + test_support.run_unittest(UnicodeTestCase) + + +if __name__ == "__main__": + test_main() Modified: trunk/jython/src/org/python/core/PyString.java =================================================================== --- trunk/jython/src/org/python/core/PyString.java 2008-08-22 15:31:56 UTC (rev 5233) +++ trunk/jython/src/org/python/core/PyString.java 2008-08-22 20:16:59 UTC (rev 5234) @@ -670,7 +670,7 @@ for(int i = 0; i < count; i++) { string.getChars(0, s, new_chars, i * s); } - return createInstance(new String(new_chars), true); + return createInstance(new String(new_chars)); } @Override @@ -711,7 +711,7 @@ if (generic_other instanceof PyUnicode) { return new PyUnicode(result); } - return createInstance(result, true); + return createInstance(result); } else return null; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2008-08-29 13:47:25
|
Revision: 5264 http://jython.svn.sourceforge.net/jython/?rev=5264&view=rev Author: fwierzbicki Date: 2008-08-29 13:47:16 +0000 (Fri, 29 Aug 2008) Log Message: ----------- Merged revisions 5210,5216-5220,5223-5226,5228,5230,5236-5261 via svnmerge from https://jython.svn.sourceforge.net/svnroot/jython/branches/nowalker ........ r5210 | fwierzbicki | 2008-08-19 17:43:06 -0400 (Tue, 19 Aug 2008) | 5 lines Work to date on the one pass grammar. Not ready for others to look at really. If you really want to try it note that you need to comment out parts of site.py and os.py to get things to work. They *almost* parse and compile, but not quite, and they are basic dependencies for Jython to run. ........ r5216 | fwierzbicki | 2008-08-20 08:10:26 -0400 (Wed, 20 Aug 2008) | 2 lines Much better BoolOp. ........ r5217 | fwierzbicki | 2008-08-20 10:06:30 -0400 (Wed, 20 Aug 2008) | 2 lines Fix "del". ........ r5218 | fwierzbicki | 2008-08-20 10:39:21 -0400 (Wed, 20 Aug 2008) | 2 lines Dict support. ........ r5219 | fwierzbicki | 2008-08-20 11:23:14 -0400 (Wed, 20 Aug 2008) | 2 lines Conditional Expression support. ........ r5220 | fwierzbicki | 2008-08-20 11:37:02 -0400 (Wed, 20 Aug 2008) | 2 lines repr support. ........ r5223 | fwierzbicki | 2008-08-20 15:57:39 -0400 (Wed, 20 Aug 2008) | 2 lines Start of list comprehensions and generator expressions. ........ r5224 | fwierzbicki | 2008-08-20 15:58:17 -0400 (Wed, 20 Aug 2008) | 2 lines oops revert build.xml ........ r5225 | fwierzbicki | 2008-08-20 16:57:09 -0400 (Wed, 20 Aug 2008) | 2 lines re-remove PythonWalker.g from build ........ r5226 | fwierzbicki | 2008-08-20 16:59:44 -0400 (Wed, 20 Aug 2008) | 2 lines gen expressions and list comps now actually work... ........ r5228 | fwierzbicki | 2008-08-20 22:58:24 -0400 (Wed, 20 Aug 2008) | 2 lines debugging of some expr_contextType values. ........ r5230 | fwierzbicki | 2008-08-20 23:47:32 -0400 (Wed, 20 Aug 2008) | 2 lines bugfix on exception and on assign value expr_contextType. ........ r5236 | fwierzbicki | 2008-08-22 19:03:45 -0400 (Fri, 22 Aug 2008) | 2 lines Bugfix for expr_contextType on assign values. ........ r5237 | fwierzbicki | 2008-08-22 22:33:48 -0400 (Fri, 22 Aug 2008) | 2 lines Add expr types to BaseTree children. ........ r5238 | fwierzbicki | 2008-08-23 15:19:16 -0400 (Sat, 23 Aug 2008) | 2 lines BinOp now works in one pass. ........ r5239 | fwierzbicki | 2008-08-23 15:43:19 -0400 (Sat, 23 Aug 2008) | 2 lines Fine tuning List and Assign col position. ........ r5240 | fwierzbicki | 2008-08-23 19:03:59 -0400 (Sat, 23 Aug 2008) | 5 lines Make PythonTree's toStringTree more easily comparable with ast/astview.py output. This will help with the walkerless Python.g, as it doesn't quite parse ast/astview.py yet. ........ r5241 | fwierzbicki | 2008-08-23 22:04:43 -0400 (Sat, 23 Aug 2008) | 2 lines Fix lambda without args. ........ r5242 | fwierzbicki | 2008-08-24 05:38:22 -0400 (Sun, 24 Aug 2008) | 2 lines check for PythonTree in makeStmts. ........ r5243 | fwierzbicki | 2008-08-25 10:21:29 -0400 (Mon, 25 Aug 2008) | 2 lines Fix generator expressions, rename all "stmts" in Python.g to "stypes". ........ r5244 | fwierzbicki | 2008-08-25 11:25:24 -0400 (Mon, 25 Aug 2008) | 2 lines Clean up creation of stmtType[] and exprType[]. ........ r5245 | fwierzbicki | 2008-08-25 14:44:46 -0400 (Mon, 25 Aug 2008) | 3 lines Fix build.xml (oops) Fix Generator Expression assignments and multi-statement simple_stmt. ........ r5246 | fwierzbicki | 2008-08-25 16:36:04 -0400 (Mon, 25 Aug 2008) | 3 lines Fixed fplist, subscripts (especially extslice) and enable Interactive and Expression (single and eval). regrtest.py is now running. ........ r5247 | fwierzbicki | 2008-08-25 17:18:03 -0400 (Mon, 25 Aug 2008) | 2 lines Fix ** ........ r5248 | fwierzbicki | 2008-08-25 22:04:27 -0400 (Mon, 25 Aug 2008) | 3 lines Cleanup: removal of comments, re-format of Python.g and removal of PYNODE. ........ r5249 | fwierzbicki | 2008-08-26 08:21:42 -0400 (Tue, 26 Aug 2008) | 3 lines Remove unnecessary constructor on BinOp (now it is just the generated version again) Remove some whitespace in Python.g ........ r5250 | fwierzbicki | 2008-08-26 11:05:19 -0400 (Tue, 26 Aug 2008) | 2 lines Moved makeSliceType code to GrammarActions. ........ r5251 | fwierzbicki | 2008-08-26 12:51:15 -0400 (Tue, 26 Aug 2008) | 2 lines Moved Subscript creation up a rule - fixed a bunch of unit tests. ........ r5252 | fwierzbicki | 2008-08-26 15:37:34 -0400 (Tue, 26 Aug 2008) | 2 lines Another expr_contextType adjustment. ........ r5253 | fwierzbicki | 2008-08-26 16:17:50 -0400 (Tue, 26 Aug 2008) | 2 lines checking for bad assignment statements. ........ r5254 | fwierzbicki | 2008-08-26 20:44:35 -0400 (Tue, 26 Aug 2008) | 3 lines Fix illegal Lambda statements and more illegal assigns. Also raise exceptions on illegal gen expression arguments. ........ r5255 | fwierzbicki | 2008-08-26 22:38:35 -0400 (Tue, 26 Aug 2008) | 2 lines Fix for FunctionDef and Call problems. ........ r5256 | fwierzbicki | 2008-08-26 22:47:56 -0400 (Tue, 26 Aug 2008) | 2 lines whitespace ........ r5257 | fwierzbicki | 2008-08-27 12:07:35 -0400 (Wed, 27 Aug 2008) | 2 lines revert build.xml after accidently checking in my local copy. ........ r5258 | fwierzbicki | 2008-08-27 15:51:16 -0400 (Wed, 27 Aug 2008) | 2 lines for not_test, replacing manual tree construction with ->. ........ r5259 | fwierzbicki | 2008-08-27 16:09:39 -0400 (Wed, 27 Aug 2008) | 2 lines TODO comment. ........ r5260 | fwierzbicki | 2008-08-27 16:35:54 -0400 (Wed, 27 Aug 2008) | 3 lines Removed XXX comments that no longer apply (special testlists don't seem to be needed). Removed unused c1 and c2 alias. ........ r5261 | fwierzbicki | 2008-08-27 16:51:19 -0400 (Wed, 27 Aug 2008) | 2 lines simplify testlist. ........ Modified Paths: -------------- trunk/jython/ast/asdl_antlr.py trunk/jython/build.xml trunk/jython/grammar/Python.g trunk/jython/src/org/python/antlr/ExpressionParser.java trunk/jython/src/org/python/antlr/GrammarActions.java trunk/jython/src/org/python/antlr/InteractiveParser.java trunk/jython/src/org/python/antlr/ModuleParser.java trunk/jython/src/org/python/antlr/ast/Assert.java trunk/jython/src/org/python/antlr/ast/Assign.java trunk/jython/src/org/python/antlr/ast/Attribute.java trunk/jython/src/org/python/antlr/ast/AugAssign.java trunk/jython/src/org/python/antlr/ast/BinOp.java trunk/jython/src/org/python/antlr/ast/Call.java trunk/jython/src/org/python/antlr/ast/Compare.java trunk/jython/src/org/python/antlr/ast/Exec.java trunk/jython/src/org/python/antlr/ast/Expr.java trunk/jython/src/org/python/antlr/ast/Expression.java trunk/jython/src/org/python/antlr/ast/For.java trunk/jython/src/org/python/antlr/ast/GeneratorExp.java trunk/jython/src/org/python/antlr/ast/If.java trunk/jython/src/org/python/antlr/ast/IfExp.java trunk/jython/src/org/python/antlr/ast/Index.java trunk/jython/src/org/python/antlr/ast/Lambda.java trunk/jython/src/org/python/antlr/ast/ListComp.java trunk/jython/src/org/python/antlr/ast/Print.java trunk/jython/src/org/python/antlr/ast/Raise.java trunk/jython/src/org/python/antlr/ast/Repr.java trunk/jython/src/org/python/antlr/ast/Return.java trunk/jython/src/org/python/antlr/ast/Slice.java trunk/jython/src/org/python/antlr/ast/Subscript.java trunk/jython/src/org/python/antlr/ast/UnaryOp.java trunk/jython/src/org/python/antlr/ast/While.java trunk/jython/src/org/python/antlr/ast/With.java trunk/jython/src/org/python/antlr/ast/Yield.java trunk/jython/src/org/python/antlr/ast/comprehensionType.java trunk/jython/src/org/python/antlr/ast/excepthandlerType.java trunk/jython/src/org/python/antlr/ast/keywordType.java trunk/jython/src/org/python/util/jython.java trunk/jython/tests/java/org/python/antlr/PythonTreeTester.java Removed Paths: ------------- trunk/jython/grammar/PythonWalker.g Property Changed: ---------------- trunk/jython/ Property changes on: trunk/jython ___________________________________________________________________ Modified: svnmerge-integrated - /branches/nowalker:1-5209 + /branches/nowalker:1-5263 Modified: trunk/jython/ast/asdl_antlr.py =================================================================== --- trunk/jython/ast/asdl_antlr.py 2008-08-29 12:14:12 UTC (rev 5263) +++ trunk/jython/ast/asdl_antlr.py 2008-08-29 13:47:16 UTC (rev 5264) @@ -260,12 +260,15 @@ if f.typedef is not None and f.typedef.simple: not_simple = False #For now ignoring String -- will want to revisit - if f.seq and not_simple and not fparg.startswith("String"): - self.emit("if (%s != null) {" % f.name, depth+1); - self.emit("for(int i%(name)s=0;i%(name)s<%(name)s.length;i%(name)s++) {" % {"name":f.name}, depth+2) - self.emit("addChild(%s[i%s]);" % (f.name, f.name), depth+3) - self.emit("}", depth+2) - self.emit("}", depth+1) + if not_simple and not fparg.startswith("String"): + if f.seq: + self.emit("if (%s != null) {" % f.name, depth+1); + self.emit("for(int i%(name)s=0;i%(name)s<%(name)s.length;i%(name)s++) {" % {"name":f.name}, depth+2) + self.emit("addChild(%s[i%s]);" % (f.name, f.name), depth+3) + self.emit("}", depth+2) + self.emit("}", depth+1) + elif str(f.type) == "expr": + self.emit("addChild(%s);" % (f.name), depth+1) def javaMethods(self, type, clsname, ctorname, fields, depth): # The java ctors Modified: trunk/jython/build.xml =================================================================== --- trunk/jython/build.xml 2008-08-29 12:14:12 UTC (rev 5263) +++ trunk/jython/build.xml 2008-08-29 13:47:16 UTC (rev 5264) @@ -434,7 +434,6 @@ <arg value="-lib"/> <arg path="${work.dir}/build/gensrc/org/python/antlr"/> <arg file="${jython.base.dir}/grammar/Python.g"/> - <arg file="${jython.base.dir}/grammar/PythonWalker.g"/> <arg file="${jython.base.dir}/grammar/PythonPartial.g"/> <classpath refid="main.classpath"/> </java> Modified: trunk/jython/grammar/Python.g =================================================================== --- trunk/jython/grammar/Python.g 2008-08-29 12:14:12 UTC (rev 5263) +++ trunk/jython/grammar/Python.g 2008-08-29 13:47:16 UTC (rev 5264) @@ -61,8 +61,7 @@ * grammar from Jim Baker. The current parsing and compiling strategy looks * like this: * - * Python source->Python.g->simple antlr AST->PythonWalker.g-> - * decorated AST (org/python/parser/ast/*)->CodeCompiler(ASM)->.class + * Python source->Python.g->AST (org/python/parser/ast/*)->CodeCompiler(ASM)->.class */ grammar Python; @@ -74,75 +73,6 @@ tokens { INDENT; DEDENT; - - Module; - Interactive; - Expression; - NameTok; - Test; - Msg; - Level; - Body; - Bases; - Arguments; - Args; - Arg; - Keyword; - StarArgs; - KWArgs; - Assign; - AugAssign; - Tuple; - List; - Dict; - IfExp; - TryExcept; - TryFinally; - ExceptHandler; - StrTok; - NumTok; - IsNot; - NotIn; - Type; - Inst; - Tback; - Globals; - Locals; - Ellipsis; - ListComp; - Repr; - Subscript; - SubscriptList; - Index; - Target; - Value; - Lower; - Upper; - Step; - UAdd; - USub; - Invert; - Alias; - Asname; - Decorators; - GeneratorExp; - Ifs; - Elts; - Call; - Dest; - Values; - Newline; - - FpList; - StepOp; - UpperOp; - - GenFor; - GenIf; - ListFor; - ListIf; - Parens; - Brackets; } @header { @@ -152,38 +82,82 @@ import org.python.antlr.ParseException; import org.python.antlr.PythonTree; +import org.python.antlr.ast.aliasType; import org.python.antlr.ast.argumentsType; +import org.python.antlr.ast.Assert; +import org.python.antlr.ast.Assign; import org.python.antlr.ast.Attribute; +import org.python.antlr.ast.AugAssign; +import org.python.antlr.ast.BinOp; +import org.python.antlr.ast.BoolOp; +import org.python.antlr.ast.boolopType; import org.python.antlr.ast.Break; +import org.python.antlr.ast.Call; +import org.python.antlr.ast.ClassDef; +import org.python.antlr.ast.cmpopType; +import org.python.antlr.ast.Compare; +import org.python.antlr.ast.comprehensionType; import org.python.antlr.ast.Context; import org.python.antlr.ast.Continue; +import org.python.antlr.ast.Delete; +import org.python.antlr.ast.Dict; +import org.python.antlr.ast.Ellipsis; +import org.python.antlr.ast.excepthandlerType; +import org.python.antlr.ast.Exec; import org.python.antlr.ast.Expr; +import org.python.antlr.ast.Expression; import org.python.antlr.ast.exprType; import org.python.antlr.ast.expr_contextType; +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.Global; +import org.python.antlr.ast.If; +import org.python.antlr.ast.IfExp; +import org.python.antlr.ast.Import; +import org.python.antlr.ast.ImportFrom; +import org.python.antlr.ast.Index; +import org.python.antlr.ast.Interactive; +import org.python.antlr.ast.keywordType; +import org.python.antlr.ast.ListComp; +import org.python.antlr.ast.Lambda; import org.python.antlr.ast.modType; import org.python.antlr.ast.Module; import org.python.antlr.ast.Name; import org.python.antlr.ast.Num; +import org.python.antlr.ast.operatorType; import org.python.antlr.ast.Pass; import org.python.antlr.ast.Print; +import org.python.antlr.ast.Raise; +import org.python.antlr.ast.Repr; import org.python.antlr.ast.Return; +import org.python.antlr.ast.Slice; +import org.python.antlr.ast.sliceType; import org.python.antlr.ast.stmtType; import org.python.antlr.ast.Str; +import org.python.antlr.ast.Subscript; +import org.python.antlr.ast.TryExcept; +import org.python.antlr.ast.TryFinally; +import org.python.antlr.ast.Tuple; +import org.python.antlr.ast.unaryopType; +import org.python.antlr.ast.UnaryOp; +import org.python.antlr.ast.While; +import org.python.antlr.ast.With; +import org.python.antlr.ast.Yield; import org.python.core.Py; import org.python.core.PyString; import org.python.core.PyUnicode; import java.math.BigInteger; +import java.util.Collections; +import java.util.Iterator; +import java.util.ListIterator; } @members { - boolean debugOn = false; - private ErrorHandler errorHandler; - private boolean seenSingleOuterSuite = false; - private GrammarActions actions = new GrammarActions(); public void setErrorHandler(ErrorHandler eh) { @@ -191,12 +165,6 @@ actions.setErrorHandler(eh); } - private void debug(String message) { - if (debugOn) { - System.out.println(message); - } - } - protected void mismatch(IntStream input, int ttype, BitSet follow) throws RecognitionException { if (errorHandler.isRecoverable()) { super.mismatch(input, ttype, follow); @@ -243,7 +211,7 @@ int implicitLineJoiningLevel = 0; int startPos=-1; -//If you want to use another error recovery mechanisms change this +//If you want to use another error recovery mechanism change this //and the same one in the parser. private ErrorHandler errorHandler; @@ -291,23 +259,59 @@ } //single_input: NEWLINE | simple_stmt | compound_stmt NEWLINE -single_input : NEWLINE* EOF -> ^(Interactive) - | simple_stmt NEWLINE* EOF -> ^(Interactive simple_stmt) - | compound_stmt NEWLINE+ EOF -> ^(Interactive compound_stmt) - ; +single_input +@init { + modType mtype = null; +} +@after { + $single_input.tree = mtype; +} + : NEWLINE* EOF { + mtype = new Interactive($single_input.start, new stmtType[0]); + } + | simple_stmt NEWLINE* EOF { + mtype = new Interactive($single_input.start, actions.makeStmts($simple_stmt.stypes)); + } + | compound_stmt NEWLINE+ EOF { + mtype = new Interactive($single_input.start, actions.makeStmts($compound_stmt.tree)); + } + ; //file_input: (NEWLINE | stmt)* ENDMARKER -file_input : (NEWLINE | stmt)* EOF - -> ^(Module stmt*) - ; +file_input +@init { + modType mtype = null; + List stypes = new ArrayList(); +} +@after { + $file_input.tree = mtype; +} + : (NEWLINE + | stmt {stypes.addAll($stmt.stypes);} + )* { + mtype = new Module($file_input.start, actions.makeStmts(stypes)); + } + ; //eval_input: testlist NEWLINE* ENDMARKER -eval_input : LEADING_WS? (NEWLINE)* testlist[expr_contextType.Load] (NEWLINE)* EOF -> ^(Expression testlist) - ; +eval_input +@init { + modType mtype = null; +} +@after { + $eval_input.tree = mtype; +} + : LEADING_WS? (NEWLINE)* testlist[expr_contextType.Load] (NEWLINE)* EOF { + mtype = new Expression($eval_input.start, (exprType)$testlist.tree); + } + ; //not in CPython's Grammar file -dotted_attr - : NAME (DOT^ attr)* +dotted_attr returns [exprType etype] + : n1=NAME + ( (DOT n2+=dotted_attr)+ { $etype = actions.makeDottedAttr($n1, $n2); } + | { $etype = new Name($NAME, $NAME.text, expr_contextType.Load); } + ) ; //attr is here for Java compatibility. A Java foo.getIf() can be called from Jython as foo.if @@ -349,72 +353,145 @@ ; //decorator: '@' dotted_name [ '(' [arglist] ')' ] NEWLINE -decorator: AT dotted_attr - ( (LPAREN arglist? RPAREN) -> ^(AT dotted_attr ^(Call ^(Args arglist)?)) - | -> ^(AT dotted_attr) - ) NEWLINE - ; +decorator returns [exprType etype] +@after { + $decorator.tree = $etype; +} + : AT dotted_attr + ( LPAREN + ( arglist + { + $etype = actions.makeCall($LPAREN, $dotted_attr.etype, $arglist.args, $arglist.keywords, + $arglist.starargs, $arglist.kwargs); + } + | { + $etype = actions.makeCall($LPAREN, $dotted_attr.etype); + } + ) + RPAREN + | { + $etype = $dotted_attr.etype; + } + ) NEWLINE + ; //decorators: decorator+ -decorators: decorator+ - ; +decorators returns [List etypes] + : d+=decorator+ + { + $etypes = $d; + } + ; //funcdef: [decorators] 'def' NAME parameters ':' suite -funcdef : decorators? DEF NAME parameters COLON suite - -> ^(DEF NAME parameters ^(Body suite) ^(Decorators decorators?)) - ; +funcdef +@init { stmtType stype = null; } +@after { $funcdef.tree = stype; } + : decorators? DEF NAME parameters COLON suite + { + Token t = $DEF; + if ($decorators.start != null) { + t = $decorators.start; + } + stype = actions.makeFuncdef(t, $NAME, $parameters.args, $suite.stypes, $decorators.etypes); + } + ; //parameters: '(' [varargslist] ')' -parameters : LPAREN - (varargslist -> ^(Arguments varargslist) - | -> ^(Arguments) - ) - RPAREN - ; +parameters returns [argumentsType args] + : LPAREN + (varargslist {$args = $varargslist.args;} + | { $args = new argumentsType($parameters.start, new exprType[0], null, null, new exprType[0]); + } + ) + RPAREN + ; //not in CPython's Grammar file -defparameter : fpdef (ASSIGN test[expr_contextType.Load])? {debug("parsed defparameter");} - ; +defparameter[List defaults] returns [exprType etype] +@after { + $defparameter.tree = $etype; +} + : fpdef[expr_contextType.Param] (ASSIGN test[expr_contextType.Load])? + { + $etype = (exprType)$fpdef.tree; + if ($ASSIGN != null) { + defaults.add($test.tree); + } else if (!defaults.isEmpty()) { + throw new ParseException("non-default argument follows default argument", $fpdef.tree); + } + } + ; //varargslist: ((fpdef ['=' test] ',')* // ('*' NAME [',' '**' NAME] | '**' NAME) | // fpdef ['=' test] (',' fpdef ['=' test])* [',']) -varargslist : defparameter (options {greedy=true;}:COMMA defparameter)* - (COMMA - ( STAR starargs=NAME (COMMA DOUBLESTAR kwargs=NAME)? - | DOUBLESTAR kwargs=NAME - )? - )? {debug("parsed varargslist");} - -> ^(Args defparameter+) ^(StarArgs $starargs)? ^(KWArgs $kwargs)? - | STAR starargs=NAME (COMMA DOUBLESTAR kwargs=NAME)?{debug("parsed varargslist STARARGS");} - -> ^(StarArgs $starargs) ^(KWArgs $kwargs)? - | DOUBLESTAR kwargs=NAME {debug("parsed varargslist KWS");} - -> ^(KWArgs $kwargs) - ; +varargslist returns [argumentsType args] +@init { + List defaults = new ArrayList(); +} + : d+=defparameter[defaults] (options {greedy=true;}:COMMA d+=defparameter[defaults])* + (COMMA + (STAR starargs=NAME (COMMA DOUBLESTAR kwargs=NAME)? + | DOUBLESTAR kwargs=NAME + )? + )? + { + $args = actions.makeArgumentsType($varargslist.start, $d, $starargs, $kwargs, defaults); + } + | STAR starargs=NAME (COMMA DOUBLESTAR kwargs=NAME)? + { + $args = actions.makeArgumentsType($varargslist.start, $d, $starargs, $kwargs, defaults); + } + | DOUBLESTAR kwargs=NAME + { + $args = actions.makeArgumentsType($varargslist.start, $d, null, $kwargs, defaults); + } + ; //fpdef: NAME | '(' fplist ')' -fpdef : NAME {debug("parsed fpdef NAME");} - | (LPAREN fpdef COMMA) => LPAREN fplist RPAREN - -> ^(FpList fplist) - | LPAREN fplist RPAREN - -> fplist - ; +fpdef[expr_contextType ctype] +@after { + actions.checkAssign((exprType)$fpdef.tree); +} + : NAME + -> ^(NAME<Name>[$NAME, $NAME.text, ctype]) + | (LPAREN fpdef[null] COMMA) => LPAREN fplist RPAREN + -> ^(LPAREN<Tuple>[$fplist.start, actions.makeExprs($fplist.etypes), expr_contextType.Store]) + | LPAREN fplist RPAREN + -> fplist + ; //fplist: fpdef (',' fpdef)* [','] -fplist : fpdef (options {greedy=true;}:COMMA fpdef)* (COMMA)? - {debug("parsed fplist");} - -> fpdef+ - ; +fplist returns [List etypes] + : f+=fpdef[expr_contextType.Store] + (options {greedy=true;}:COMMA f+=fpdef[expr_contextType.Store])* (COMMA)? + { + $etypes = $f; + } + ; //stmt: simple_stmt | compound_stmt -stmt : simple_stmt - | compound_stmt - ; +stmt returns [List stypes] + : simple_stmt + { + $stypes = $simple_stmt.stypes; + } + | compound_stmt + { + $stypes = new ArrayList(); + $stypes.add($compound_stmt.tree); + } + ; //simple_stmt: small_stmt (';' small_stmt)* [';'] NEWLINE -simple_stmt : small_stmt (options {greedy=true;}:SEMI small_stmt)* (SEMI)? NEWLINE - -> small_stmt+ - ; +simple_stmt returns [List stypes] + : s+=small_stmt (options {greedy=true;}:SEMI s+=small_stmt)* (SEMI)? NEWLINE + { + $stypes = $s; + } + ; + //small_stmt: (expr_stmt | print_stmt | del_stmt | pass_stmt | flow_stmt | // import_stmt | global_stmt | exec_stmt | assert_stmt) small_stmt : expr_stmt @@ -430,310 +507,481 @@ //expr_stmt: testlist (augassign (yield_expr|testlist) | // ('=' (yield_expr|testlist))*) -expr_stmt : lhs=testlist[expr_contextType.Store] - ( (augassign yield_expr -> ^(augassign $lhs yield_expr)) - | (augassign rhs=testlist[expr_contextType.Load] -> ^(augassign $lhs $rhs)) - | ((assigns) {debug("matched assigns");} -> ^(Assign ^(Target $lhs) assigns)) - | -> $lhs - ) - ; - -//not in CPython's Grammar file -assigns - @after { - PythonTree pt = ((PythonTree)$assigns.tree); - int children = pt.getChildCount(); - PythonTree child; - if (children == 1) { - child = pt; - pt.token = new CommonToken(Value, "Value"); - } else { - child = (PythonTree)pt.getChild(children - 1); - child.token = new CommonToken(Value, "Value"); - } - child.token = new CommonToken(Value, "Value"); - PythonTree targ = (PythonTree)child.getChild(0); - if (targ instanceof Context) { - ((Context)targ).setContext(expr_contextType.Load); - } +expr_stmt +@init { + stmtType stype = null; } - : assign_testlist+ - | assign_yield+ +@after { + if (stype != null) { + $expr_stmt.tree = stype; + } +} + : ((testlist[null] augassign) => lhs=testlist[expr_contextType.AugStore] + ( (aay=augassign y1=yield_expr + { + actions.checkAssign((exprType)$lhs.tree); + stype = new AugAssign($lhs.tree, (exprType)$lhs.tree, $aay.op, (exprType)$y1.tree); + } + ) + | (aat=augassign rhs=testlist[expr_contextType.Load] + { + actions.checkAssign((exprType)$lhs.tree); + stype = new AugAssign($lhs.tree, (exprType)$lhs.tree, $aat.op, (exprType)$rhs.tree); + } + ) + ) + | (testlist[null] ASSIGN) => lhs=testlist[expr_contextType.Store] + ( + | ((at=ASSIGN t+=testlist[expr_contextType.Store])+ + -> ^(ASSIGN<Assign>[$lhs.start, actions.makeAssignTargets((exprType)$lhs.tree, $t), + actions.makeAssignValue($t)]) + ) + | ((ay=ASSIGN y2+=yield_expr)+ + -> ^(ASSIGN<Assign>[$lhs.start, actions.makeAssignTargets((exprType)$lhs.tree, $y2), + actions.makeAssignValue($y2)]) + ) + ) + | lhs=testlist[expr_contextType.Load] + { + stype = new Expr($lhs.start, (exprType)$lhs.tree); + } + ) ; -//not in CPython's Grammar file -assign_testlist - : ASSIGN testlist[expr_contextType.Store] -> ^(Target testlist) - ; - -//not in CPython's Grammar file -assign_yield - : ASSIGN yield_expr -> ^(Value yield_expr) - ; - //augassign: ('+=' | '-=' | '*=' | '/=' | '%=' | '&=' | '|=' | '^=' | // '<<=' | '>>=' | '**=' | '//=') -augassign : PLUSEQUAL - | MINUSEQUAL - | STAREQUAL - | SLASHEQUAL - | PERCENTEQUAL - | AMPEREQUAL - | VBAREQUAL - | CIRCUMFLEXEQUAL - | LEFTSHIFTEQUAL - | RIGHTSHIFTEQUAL - | DOUBLESTAREQUAL - | DOUBLESLASHEQUAL - ; +augassign returns [operatorType op] + : PLUSEQUAL {$op = operatorType.Add;} + | MINUSEQUAL {$op = operatorType.Sub;} + | STAREQUAL {$op = operatorType.Mult;} + | SLASHEQUAL {$op = operatorType.Div;} + | PERCENTEQUAL {$op = operatorType.Mod;} + | AMPEREQUAL {$op = operatorType.BitAnd;} + | VBAREQUAL {$op = operatorType.BitOr;} + | CIRCUMFLEXEQUAL {$op = operatorType.BitXor;} + | LEFTSHIFTEQUAL {$op = operatorType.LShift;} + | RIGHTSHIFTEQUAL {$op = operatorType.RShift;} + | DOUBLESTAREQUAL {$op = operatorType.Pow;} + | DOUBLESLASHEQUAL {$op = operatorType.FloorDiv;} + ; //print_stmt: 'print' ( [ test (',' test)* [','] ] | // '>>' test [ (',' test)+ [','] ] ) -print_stmt : PRINT - ( t1=printlist -> {$t1.newline}? ^(PRINT ^(Values $t1) ^(Newline)) - -> ^(PRINT ^(Values $t1)) - | RIGHTSHIFT t2=printlist2 -> {$t2.newline}? ^(PRINT ^(Dest RIGHTSHIFT) ^(Values $t2) ^(Newline)) - -> ^(PRINT ^(Dest RIGHTSHIFT) ^(Values $t2)) - | -> ^(PRINT ^(Newline)) - ) +print_stmt + : PRINT + (t1=printlist + -> ^(PRINT<Print>[$PRINT, null, actions.makeExprs($t1.elts), $t1.newline]) + | RIGHTSHIFT t2=printlist2 + -> ^(PRINT<Print>[$PRINT, (exprType)$t2.elts.get(0), actions.makeExprs($t2.elts, 1), $t2.newline]) + | + -> ^(PRINT<Print>[$PRINT, null, new exprType[0\], false]) + ) ; //not in CPython's Grammar file -printlist returns [boolean newline] - : (test[expr_contextType.Load] COMMA) => test[expr_contextType.Load] (options {k=2;}: COMMA test[expr_contextType.Load])* (trailcomma=COMMA)? - { if ($trailcomma == null) { +printlist returns [boolean newline, List elts] + : (test[null] COMMA) => + t+=test[expr_contextType.Load] (options {k=2;}: COMMA t+=test[expr_contextType.Load])* + (trailcomma=COMMA)? + { + $elts=$t; + if ($trailcomma == null) { + $newline = true; + } else { + $newline = false; + } + } + | t+=test[expr_contextType.Load] + { + $elts=$t; $newline = true; - } else { - $newline = false; } - } - -> ^(Elts test+) - | test[expr_contextType.Load] {$newline = true;} - -> ^(Elts test) ; +//XXX: would be nice if printlist and printlist2 could be merged. //not in CPython's Grammar file -printlist2 returns [boolean newline] - : (test[expr_contextType.Load] COMMA test[expr_contextType.Load]) => test[expr_contextType.Load] (options {k=2;}: COMMA test[expr_contextType.Load])* (trailcomma=COMMA)? - { if ($trailcomma == null) { +printlist2 returns [boolean newline, List elts] + : (test[null] COMMA test[null]) => + t+=test[expr_contextType.Load] (options {k=2;}: COMMA t+=test[expr_contextType.Load])* + (trailcomma=COMMA)? + { $elts=$t; + if ($trailcomma == null) { + $newline = true; + } else { + $newline = false; + } + } + | t+=test[expr_contextType.Load] + { + $elts=$t; $newline = true; - } else { - $newline = false; } - } - -> ^(Elts test+) - | test[expr_contextType.Load] {$newline = true;} - -> ^(Elts test) ; //del_stmt: 'del' exprlist -del_stmt : DELETE exprlist2 - -> ^(DELETE exprlist2) - ; +del_stmt + : DELETE del_list + -> ^(DELETE<Delete>[$DELETE, actions.makeExprs($del_list.etypes)]) + ; //pass_stmt: 'pass' -pass_stmt : PASS - -> ^(PASS) - ; +pass_stmt + : PASS + -> ^(PASS<Pass>[$PASS]) + ; //flow_stmt: break_stmt | continue_stmt | return_stmt | raise_stmt | yield_stmt -flow_stmt : break_stmt - | continue_stmt - | return_stmt - | raise_stmt - | yield_stmt - ; +flow_stmt + : break_stmt + | continue_stmt + | return_stmt + | raise_stmt + | yield_stmt + ; //break_stmt: 'break' -break_stmt : BREAK - -> ^(BREAK<Break>[$BREAK]) - ; +break_stmt + : BREAK + -> ^(BREAK<Break>[$BREAK]) + ; //continue_stmt: 'continue' -continue_stmt : CONTINUE - -> ^(CONTINUE<Continue>[$CONTINUE]) - ; +continue_stmt + : CONTINUE + -> ^(CONTINUE<Continue>[$CONTINUE]) + ; //return_stmt: 'return' [testlist] -return_stmt : RETURN (testlist[expr_contextType.Load])? - -> ^(RETURN ^(Value testlist)?) - ; +return_stmt + : RETURN + (testlist[expr_contextType.Load] + -> ^(RETURN<Return>[$RETURN, (exprType)$testlist.tree]) + | + -> ^(RETURN<Return>[$RETURN, null]) + ) + ; //yield_stmt: yield_expr -yield_stmt : yield_expr - ; +yield_stmt + : yield_expr -> ^(YIELD<Expr>[$yield_expr.start, (exprType)$yield_expr.tree]) + ; //raise_stmt: 'raise' [test [',' test [',' test]]] -raise_stmt: RAISE (t1=test[expr_contextType.Load] (COMMA t2=test[expr_contextType.Load] (COMMA t3=test[expr_contextType.Load])?)?)? - -> ^(RAISE ^(Type $t1)? ^(Inst $t2)? ^(Tback $t3)?) - ; +raise_stmt + : RAISE (t1=test[expr_contextType.Load] (COMMA t2=test[expr_contextType.Load] + (COMMA t3=test[expr_contextType.Load])?)?)? + -> ^(RAISE<Raise>[$RAISE, (exprType)$t1.tree, (exprType)$t2.tree, (exprType)$t3.tree]) + ; //import_stmt: import_name | import_from -import_stmt : import_name - | import_from - ; +import_stmt + : import_name + | import_from + ; //import_name: 'import' dotted_as_names -import_name : IMPORT dotted_as_names - -> ^(IMPORT dotted_as_names) - ; +import_name + : IMPORT dotted_as_names + -> ^(IMPORT<Import>[$IMPORT, $dotted_as_names.atypes]) + ; //import_from: ('from' ('.'* dotted_name | '.'+) // 'import' ('*' | '(' import_as_names ')' | import_as_names)) -import_from: FROM (DOT* dotted_name | DOT+) IMPORT - (STAR - -> ^(FROM ^(Level DOT*)? ^(Value dotted_name)? ^(IMPORT STAR)) - | import_as_names - -> ^(FROM ^(Level DOT*)? ^(Value dotted_name)? ^(IMPORT import_as_names)) - | LPAREN import_as_names COMMA? RPAREN - -> ^(FROM ^(Level DOT*)? ^(Value dotted_name)? ^(IMPORT import_as_names)) - ) - ; +import_from + : FROM (d+=DOT* dotted_name | d+=DOT+) IMPORT + (STAR + -> ^(FROM<ImportFrom>[$FROM, actions.makeFromText($d, $dotted_name.text), + actions.makeStarAlias($STAR), actions.makeLevel($d)]) + | i1=import_as_names + -> ^(FROM<ImportFrom>[$FROM, actions.makeFromText($d, $dotted_name.text), + actions.makeAliases($i1.atypes), actions.makeLevel($d)]) + | LPAREN i2=import_as_names COMMA? RPAREN + -> ^(FROM<ImportFrom>[$FROM, actions.makeFromText($d, $dotted_name.text), + actions.makeAliases($i2.atypes), actions.makeLevel($d)]) + ) + ; //import_as_names: import_as_name (',' import_as_name)* [','] -import_as_names : import_as_name (COMMA! import_as_name)* - ; +import_as_names returns [aliasType[\] atypes] + : n+=import_as_name (COMMA! n+=import_as_name)* + { + $atypes = (aliasType[])$n.toArray(new aliasType[$n.size()]); + } + ; //import_as_name: NAME [('as' | NAME) NAME] -import_as_name : name=NAME (AS asname=NAME)? - -> ^(Alias $name ^(Asname $asname)?) - ; +import_as_name returns [aliasType atype] +@after { + $import_as_name.tree = $atype; +} + : name=NAME (AS asname=NAME)? + { + $atype = new aliasType($name, $name.text, $asname.text); + } + ; //XXX: when does CPython Grammar match "dotted_name NAME NAME"? //dotted_as_name: dotted_name [('as' | NAME) NAME] -dotted_as_name : dotted_name (AS asname=NAME)? - -> ^(Alias dotted_name ^(Asname NAME)?) - ; +dotted_as_name returns [aliasType atype] +@after { + $dotted_as_name.tree = $atype; +} + : dotted_name (AS NAME)? + { + $atype = new aliasType($NAME, $dotted_name.text, $NAME.text); + } + ; + //dotted_as_names: dotted_as_name (',' dotted_as_name)* -dotted_as_names : dotted_as_name (COMMA! dotted_as_name)* - ; +dotted_as_names returns [aliasType[\] atypes] + : d+=dotted_as_name (COMMA! d+=dotted_as_name)* + { + $atypes = (aliasType[])$d.toArray(new aliasType[$d.size()]); + } + ; + //dotted_name: NAME ('.' NAME)* -dotted_name : NAME (DOT attr)* - ; +dotted_name + : NAME (DOT attr)* + ; //global_stmt: 'global' NAME (',' NAME)* -global_stmt : GLOBAL NAME (COMMA NAME)* - -> ^(GLOBAL NAME+) - ; +global_stmt + : GLOBAL n+=NAME (COMMA n+=NAME)* + -> ^(GLOBAL<Global>[$GLOBAL, actions.makeNames($n)]) + ; //exec_stmt: 'exec' expr ['in' test [',' test]] -exec_stmt : EXEC expr[expr_contextType.Load] (IN t1=test[expr_contextType.Load] (COMMA t2=test[expr_contextType.Load])?)? - -> ^(EXEC expr ^(Globals $t1)? ^(Locals $t2)?) - ; +exec_stmt +@init { + stmtType stype = null; +} +@after { + $exec_stmt.tree = stype; +} + : EXEC expr[expr_contextType.Load] (IN t1=test[expr_contextType.Load] + (COMMA t2=test[expr_contextType.Load])?)? + { + stype = new Exec($EXEC, (exprType)$expr.tree, (exprType)$t1.tree, (exprType)$t2.tree); + } + ; //assert_stmt: 'assert' test [',' test] -assert_stmt : ASSERT t1=test[expr_contextType.Load] (COMMA t2=test[expr_contextType.Load])? - -> ^(ASSERT ^(Test $t1) ^(Msg $t2)?) - ; +assert_stmt + : ASSERT t1=test[expr_contextType.Load] (COMMA t2=test[expr_contextType.Load])? + -> ^(ASSERT<Assert>[$ASSERT, (exprType)$t1.tree, (exprType)$t2.tree]) + ; //compound_stmt: if_stmt | while_stmt | for_stmt | try_stmt | funcdef | classdef -compound_stmt : if_stmt - | while_stmt - | for_stmt - | try_stmt - | with_stmt - | funcdef - | classdef - ; +compound_stmt + : if_stmt + | while_stmt + | for_stmt + | try_stmt + | with_stmt + | funcdef + | classdef + ; //if_stmt: 'if' test ':' suite ('elif' test ':' suite)* ['else' ':' suite] -if_stmt: IF test[expr_contextType.Load] COLON ifsuite=suite elif_clause* (ORELSE COLON elsesuite=suite)? - -> ^(IF test $ifsuite elif_clause* ^(ORELSE $elsesuite)?) - ; +if_stmt + : IF test[expr_contextType.Load] COLON ifsuite=suite elifs+=elif_clause* + (ORELSE COLON elsesuite=suite)? + -> ^(IF<If>[$IF, (exprType)$test.tree, actions.makeStmts($ifsuite.stypes), + actions.makeElses($elsesuite.stypes, $elifs)]) + ; //not in CPython's Grammar file -elif_clause : ELIF test[expr_contextType.Load] COLON suite - -> ^(ELIF test suite) - ; +elif_clause + : ELIF test[expr_contextType.Load] COLON suite + -> ^(ELIF<If>[$ELIF, (exprType)$test.tree, actions.makeStmts($suite.stypes), new stmtType[0\]]) + ; //while_stmt: 'while' test ':' suite ['else' ':' suite] -while_stmt : WHILE test[expr_contextType.Load] COLON s1=suite (ORELSE COLON s2=suite)? - -> ^(WHILE test ^(Body $s1) ^(ORELSE $s2)?) - ; +while_stmt +@init { + stmtType stype = null; +} +@after { + $while_stmt.tree = stype; +} + : WHILE test[expr_contextType.Load] COLON s1=suite (ORELSE COLON s2=suite)? + { + stype = actions.makeWhile($WHILE, (exprType)$test.tree, $s1.stypes, $s2.stypes); + } + ; //for_stmt: 'for' exprlist 'in' testlist ':' suite ['else' ':' suite] -for_stmt : FOR exprlist[expr_contextType.Store] IN testlist[expr_contextType.Load] COLON s1=suite (ORELSE COLON s2=suite)? - -> ^(FOR ^(Target exprlist) ^(IN testlist) ^(Body $s1) ^(ORELSE $s2)?) - ; +for_stmt +@init { + stmtType stype = null; +} +@after { + $for_stmt.tree = stype; +} + : FOR exprlist[expr_contextType.Store] IN testlist[expr_contextType.Load] COLON s1=suite + (ORELSE COLON s2=suite)? + { + stype = actions.makeFor($FOR, $exprlist.etype, (exprType)$testlist.tree, $s1.stypes, $s2.stypes); + } + ; //try_stmt: ('try' ':' suite // ((except_clause ':' suite)+ // ['else' ':' suite] // ['finally' ':' suite] | // 'finally' ':' suite)) -try_stmt : TRY COLON trysuite=suite - ( (except_clause+ (ORELSE COLON elsesuite=suite)? (FINALLY COLON finalsuite=suite)? - -> ^(TryExcept[$TRY] ^(Body $trysuite) except_clause+ ^(ORELSE $elsesuite)? ^(FINALLY $finalsuite)?)) - | (FINALLY COLON finalsuite=suite - -> ^(TryFinally[$TRY] ^(Body $trysuite) ^(FINALLY $finalsuite))) - ) - ; +try_stmt +@init { + stmtType stype = null; +} +@after { + $try_stmt.tree = stype; +} + : TRY COLON trysuite=suite + ( e+=except_clause+ (ORELSE COLON elsesuite=suite)? (FINALLY COLON finalsuite=suite)? + { + stype = actions.makeTryExcept($TRY, $trysuite.stypes, $e, $elsesuite.stypes, $finalsuite.stypes); + } + | FINALLY COLON finalsuite=suite + { + stype = actions.makeTryFinally($TRY, $trysuite.stypes, $finalsuite.stypes); + } + ) + ; //with_stmt: 'with' test [ with_var ] ':' suite -with_stmt: WITH test[expr_contextType.Load] (with_var)? COLON suite - -> ^(WITH test with_var? ^(Body suite)) - ; +with_stmt +@init { + stmtType stype = null; +} +@after { + $with_stmt.tree = stype; +} + : WITH test[expr_contextType.Load] (with_var)? COLON suite + { + stype = new With($WITH, (exprType)$test.tree, $with_var.etype, + actions.makeStmts($suite.stypes)); + } + ; //with_var: ('as' | NAME) expr -with_var: (AS | NAME) expr[expr_contextType.Load] - ; +with_var returns [exprType etype] + : (AS | NAME) expr[expr_contextType.Store] + { + $etype = (exprType)$expr.tree; + } + ; //except_clause: 'except' [test [',' test]] -except_clause : EXCEPT (t1=test[expr_contextType.Load] (COMMA t2=test[expr_contextType.Load])?)? COLON suite - //Note: passing the 'except' keyword on so we can pass the same offset - // as CPython. - -> ^(EXCEPT ^(Type $t1)? ^(Value $t2)? ^(Body suite)) - ; +except_clause + : EXCEPT (t1=test[expr_contextType.Load] (COMMA t2=test[expr_contextType.Store])?)? COLON suite + -> ^(EXCEPT<excepthandlerType>[$EXCEPT, (exprType)$t1.tree, (exprType)$t2.tree, + actions.makeStmts($suite.stypes), $EXCEPT.getLine(), $EXCEPT.getCharPositionInLine()]) + ; //suite: simple_stmt | NEWLINE INDENT stmt+ DEDENT -suite +suite returns [List stypes] +@init { + $stypes = new ArrayList(); +} : simple_stmt - | NEWLINE! INDENT (stmt)+ DEDENT + { + $stypes = $simple_stmt.stypes; + } + | NEWLINE INDENT + (stmt + { + $stypes.addAll($stmt.stypes); + } + )+ DEDENT ; //test: or_test ['if' or_test 'else' test] | lambdef test[expr_contextType ctype] :o1=or_test[ctype] - ( (IF or_test[expr_contextType.Load] ORELSE) => IF o2=or_test[ctype] ORELSE test[expr_contextType.Load] - -> ^(IfExp ^(Test $o2) ^(Body $o1) ^(ORELSE test)) - | -> or_test - ) - | lambdef {debug("parsed lambdef");} + ( (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]) + | + -> or_test + ) + | lambdef ; //or_test: and_test ('or' and_test)* -or_test[expr_contextType ctype] : and_test[ctype] (OR^ and_test[ctype])* - ; +or_test[expr_contextType ctype] +@after { + if ($or != null) { + $or_test.tree = actions.makeBoolOp($left.tree, boolopType.Or, $right); + } +} + : left=and_test[ctype] + ( (or=OR right+=and_test[ctype] + )+ + | + -> $left + ) + ; //and_test: not_test ('and' not_test)* -and_test[expr_contextType ctype] : not_test[ctype] (AND^ not_test[ctype])* - ; +and_test[expr_contextType ctype] +@after { + if ($and != null) { + $and_test.tree = actions.makeBoolOp($left.tree, boolopType.And, $right); + } +} + : left=not_test[ctype] + ( (and=AND right+=not_test[ctype] + )+ + | + -> $left + ) + ; //not_test: 'not' not_test | comparison -not_test[expr_contextType ctype] : NOT^ not_test[ctype] - | comparison[ctype] - ; +not_test[expr_contextType ctype] + : NOT nt=not_test[ctype] + -> ^(NOT<UnaryOp>[$NOT, unaryopType.Not, (exprType)$nt.tree]) + | comparison[ctype] + ; //comparison: expr (comp_op expr)* -comparison[expr_contextType ctype]: expr[ctype] (comp_op^ expr[ctype])* +comparison[expr_contextType ctype] +@init { + List cmps = new ArrayList(); +} +@after { + if (!cmps.isEmpty()) { + $comparison.tree = new Compare($left.tree, (exprType)$left.tree, actions.makeCmpOps(cmps), + actions.makeExprs($right)); + } +} + : left=expr[ctype] + ( ( comp_op right+=expr[ctype] {cmps.add($comp_op.op);} + )+ + | + -> $left + ) ; //comp_op: '<'|'>'|'=='|'>='|'<='|'<>'|'!='|'in'|'not' 'in'|'is'|'is' 'not' -comp_op : LESS - | GREATER - | EQUAL - | GREATEREQUAL - | LESSEQUAL - | ALT_NOTEQUAL - | NOTEQUAL - | IN - | NOT IN -> NotIn - | IS - | IS NOT -> IsNot - ; +comp_op returns [cmpopType op] + : LESS {$op = cmpopType.Lt;} + | GREATER {$op = cmpopType.Gt;} + | EQUAL {$op = cmpopType.Eq;} + | GREATEREQUAL {$op = cmpopType.GtE;} + | LESSEQUAL {$op = cmpopType.LtE;} + | ALT_NOTEQUAL {$op = cmpopType.NotEq;} + | NOTEQUAL {$op = cmpopType.NotEq;} + | IN {$op = cmpopType.In;} + | NOT IN {$op = cmpopType.NotIn;} + | IS {$op = cmpopType.Is;} + | IS NOT {$op = cmpopType.IsNot;} + ; + //expr: xor_expr ('|' xor_expr)* expr[expr_contextType ect] scope { @@ -742,219 +990,531 @@ @init { $expr::ctype = ect; } - - : xor_expr (VBAR^ xor_expr)* +@after { + if ($op != null) { + $expr.tree = actions.makeBinOp($left.tree, operatorType.BitOr, $right); + } +} + : left=xor_expr + ( (op=VBAR right+=xor_expr + )+ + | + -> $left + ) ; + //xor_expr: and_expr ('^' and_expr)* -xor_expr : and_expr (CIRCUMFLEX^ and_expr)* - ; +xor_expr +@after { + if ($op != null) { + $xor_expr.tree = actions.makeBinOp($left.tree, operatorType.BitXor, $right); + } +} + : left=and_expr + ( (op=CIRCUMFLEX right+=and_expr + )+ + | + -> $left + ) + ; //and_expr: shift_expr ('&' shift_expr)* -and_expr : shift_expr (AMPER^ shift_expr)* - ; +and_expr +@after { + if ($op != null) { + $and_expr.tree = actions.makeBinOp($left.tree, operatorType.BitAnd, $right); + } +} + : left=shift_expr + ( (op=AMPER right+=shift_expr + )+ + | + -> $left + ) + ; //shift_expr: arith_expr (('<<'|'>>') arith_expr)* -shift_expr : arith_expr ((LEFTSHIFT^|RIGHTSHIFT^) arith_expr)* - ; +shift_expr +@init { + List ops = new ArrayList(); +} +@after { + if (!ops.isEmpty()) { + $shift_expr.tree = actions.makeBinOp($left.tree, ops, $right); + } +} + : left=arith_expr + ( ( shift_op right+=arith_expr {ops.add($shift_op.op);} + )+ + | + -> $left + ) + ; +shift_op returns [operatorType op] + : LEFTSHIFT {$op = operatorType.LShift;} + | RIGHTSHIFT {$op = operatorType.RShift;} + ; + //arith_expr: term (('+'|'-') term)* -arith_expr: term ((PLUS^|MINUS^) term)* +arith_expr +@init { + List ops = new ArrayList(); +} +@after { + if (!ops.isEmpty()) { + $arith_expr.tree = actions.makeBinOp($left.tree, ops, $right); + } +} + : left=term + ( (arith_op right+=term {ops.add($arith_op.op);} + )+ + | + -> $left + ) ; +arith_op returns [operatorType op] + : PLUS {$op = operatorType.Add;} + | MINUS {$op = operatorType.Sub;} + ; + //term: factor (('*'|'/'|'%'|'//') factor)* -term : factor ((STAR^ | SLASH^ | PERCENT^ | DOUBLESLASH^ ) factor)* - ; +term +@init { + List ops = new ArrayList(); +} +@after { + if (!ops.isEmpty()) { + $term.tree = actions.makeBinOp($left.tree, ops, $right); + } +} + : left=factor + ( (term_op right+=factor {ops.add($term_op.op);} + )+ + | + -> $left + ) + ; +term_op returns [operatorType op] + :STAR {$op = operatorType.Mult;} + |SLASH {$op = operatorType.Div;} + |PERCENT {$op = operatorType.Mod;} + |DOUBLESLASH {$op = operatorType.FloorDiv;} + ; + //factor: ('+'|'-'|'~') factor | power -factor : PLUS factor -> ^(UAdd PLUS factor) - | MINUS factor -> ^(USub MINUS factor) - | TILDE factor -> ^(Invert TILDE factor) - | power - ; +factor returns [exprType etype] +@after { + $factor.tree = $etype; +} + : PLUS p=factor {$etype = new UnaryOp($PLUS, unaryopType.UAdd, $p.etype);} + | MINUS m=factor {$etype = actions.negate($MINUS, $m.etype);} + | TILDE t=factor {$etype = new UnaryOp($TILDE, unaryopType.Invert, $t.etype);} + | power {$etype = (exprType)$power.tree;} + ; //power: atom trailer* ['**' factor] -power : atom (trailer^)* (options {greedy=true;}:DOUBLESTAR^ factor)? - ; +power returns [exprType etype] +@after { + $power.tree = $etype; +} + : atom (t+=trailer[$atom.start, $atom.tree])* (options {greedy=true;}:d=DOUBLESTAR factor)? + { + //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); + if ($etype instanceof Context) { + ((Context)$etype).setContext(expr_contextType.Load); + } + if (o instanceof Call) { + Call c = (Call)o; + c.func = $etype; + $etype = c; + } else if (o instanceof Subscript) { + Subscript c = (Subscript)o; + c.value = $etype; + $etype = c; + } else if (o instanceof Attribute) { + Attribute c = (Attribute)o; + c.value = $etype; + $etype = c; + } + } + } + if ($d != null) { + List right = new ArrayList(); + right.add($factor.tree); + $etype = actions.makeBinOp($etype, operatorType.Pow, right); + } + } + ; //atom: ('(' [yield_expr|testlist_gexp] ')' | // '[' [listmaker] ']' | // '{' [dictmaker] '}' | // '`' testlist1 '`' | // NAME | NUMBER | STRING+) -atom : LPAREN - ( yield_expr -> ^(Parens LPAREN yield_expr) - | testlist_gexp {debug("parsed testlist_gexp");} -> ^(Parens LPAREN testlist_gexp) - | -> ^(Tuple) +atom + : LPAREN + ( yield_expr + -> yield_expr + | testlist_gexp + -> testlist_gexp + | + -> ^(LPAREN<Tuple>[$LPAREN, new exprType[0\], $expr::ctype]) + ) + RPAREN + | LBRACK + (listmaker[$LBRACK] + -> listmaker + | + -> ^(LBRACK<org.python.antlr.ast.List>[$LBRACK, new exprType[0\], $expr::ctype]) + ) + RBRACK + | LCURLY + (dictmaker + -> ^(LCURLY<Dict>[$LCURLY, actions.makeExprs($dictmaker.keys), + actions.makeExprs($dictmaker.values)]) + | + -> ^(LCURLY<Dict>[$LCURLY, new exprType[0\], new exprType[0\]]) ) - RPAREN - | LBRACK - (listmaker -> ^(Brackets LBRACK listmaker) - | -> ^(Brackets LBRACK ^(List)) - ) - RBRACK - | LCURLY (dictmaker)? RCURLY -> ^(Dict LCURLY ^(Elts dictmaker)?) - | BACKQUOTE testlist[expr_contextType.Load] BACKQUOTE -> ^(Repr BACKQUOTE testlist) - | NAME -> ^(NameTok NAME) - | INT -> ^(NumTok<Num>[$INT, actions.makeInt($INT)]) - | LONGINT -> ^(NumTok<Num>[$LONGINT, actions.makeInt($LONGINT)]) - | FLOAT -> ^(NumTok<Num>[$FLOAT, actions.makeFloat($FLOAT)]) - | COMPLEX -> ^(NumTok<Num>[$COMPLEX, actions.makeComplex($COMPLEX)]) + RCURLY + | lb=BACKQUOTE testlist[expr_contextType.Load] rb=BACKQUOTE + -> ^(BACKQUOTE<Repr>[$lb, (exprType)$testlist.tree]) + | NAME + -> ^(NAME<Name>[$NAME, $NAME.text, $expr::ctype]) + | INT + -> ^(INT<Num>[$INT, actions.makeInt($INT)]) + | LONGINT + -> ^(LONGINT<Num>[$LONGINT, actions.makeInt($LONGINT)]) + | FLOAT + -> ^(FLOAT<Num>[$FLOAT, actions.makeFloat($FLOAT)]) + | COMPLEX + -> ^(COMPLEX<Num>[$COMPLEX, actions.makeComplex($COMPLEX)]) | (S+=STRING)+ - -> ^(StrTok<Str>[actions.extractStringToken($S), actions.extractStrings($S)]) + -> ^(STRING<Str>[actions.extractStringToken($S), actions.extractStrings($S)]) ; //listmaker: test ( list_for | (',' test)* [','] ) -listmaker : test[expr_contextType.Load] - ( list_for -> ^(ListComp test list_for) - | (options {greedy=true;}:COMMA test[expr_contextType.Load])* -> ^(List ^(Elts test+)) - ) (COMMA)? +listmaker[Token lbrack] +@init { + List gens = new ArrayList(); + exprType etype = null; +} +@after { + $listmaker.tree = etype; +} + : t+=test[$expr::ctype] + (list_for[gens] + { + Collections.reverse(gens); + comprehensionType[] c = + (comprehensionType[])gens.toArray(new comprehensionType[gens.size()]); + etype = new ListComp($listmaker.start, (exprType)$t.get(0), c); + } + | (options {greedy=true;}:COMMA t+=test[$expr::ctype])* + { + etype = new org.python.antlr.ast.List($lbrack, actions.makeExprs($t), $expr::ctype); + } + ) (COMMA)? ; //testlist_gexp: test ( gen_for | (',' test)* [','] ) testlist_gexp - : test[expr_contextType.Load] ( ((options {k=2;}: c1=COMMA test[expr_contextType.Load])* (c2=COMMA)? -> { $c1 != null || $c2 != null }? ^(Tuple ^(Elts test+)) - -> test - ) - | ( gen_for -> ^(GeneratorExp test gen_for)) - ) +@init { + exprType etype = null; + List gens = new ArrayList(); +} +@after { + if (etype != null) { + $testlist_gexp.tree = etype; + } +} + : t+=test[$expr::ctype] + ( ((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 + ) + | (gen_for[gens] + { + Collections.reverse(gens); + comprehensionType[] c = (comprehensionType[])gens.toArray(new comprehensionType[gens.size()]); + exprType e = (exprType)$t.get(0); + if (e instanceof Context) { + ((Context)e).setContext(expr_contextType.Load); + } + etype = new GeneratorExp($testlist_gexp.start, (exprType)$t.get(0), c); + } + ) + ) ; //lambdef: 'lambda' [varargslist] ':' test -lambdef: LAMBDA (varargslist)? COLON test[expr_contextType.Load] {debug("parsed lambda");} - -> ^(LAMBDA varargslist? ^(Body test)) - ; +lambdef +@init { + exprType etype = null; +} +@after { + $lambdef.tree = etype; +} + : LAMBDA (varargslist)? COLON test[expr_contextType.Load] + { + argumentsType a = $varargslist.args; + if (a == null) { + a = new argumentsType($LAMBDA, new exprType[0], null, null, new exprType[0]); + } + etype = new Lambda($LAMBDA, a, (exprType)$test.tree); + } + ; //trailer: '(' [arglist] ')' | '[' subscriptlist ']' | '.' NAME -trailer : LPAREN (arglist)? RPAREN -> ^(Call ^(Args arglist)?) - | LBRACK subscriptlist RBRACK -> ^(SubscriptList subscriptlist) - | DOT^ attr {debug("motched DOT^ NAME");} - ; +trailer [Token begin, PythonTree tree] + : LPAREN + (arglist + -> ^(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]) + ) + RPAREN + | LBRACK subscriptlist[$begin] RBRACK + -> ^(LBRACK<Subscript>[$begin, (exprType)$tree, (sliceType)$subscriptlist.tree, $expr::ctype]) + | DOT attr + -> ^(DOT<Attribute>[$begin, (exprType)$tree, $attr.text, $expr::ctype]) + ; //subscriptlist: subscript (',' subscript)* [','] -subscriptlist : subscript (options {greedy=true;}:c1=COMMA subscript)* (c2=COMMA)? - -> { $c1 != null || $c2 != null }? ^(Tuple ^(Elts subscript+)) - -> subscript - ; +subscriptlist[Token begin] +@init { + sliceType sltype = null; +} +@after { + $subscriptlist.tree = sltype; +} + : sub+=subscript (options {greedy=true;}:c1=COMMA sub+=subscript)* (c2=COMMA)? + { + sltype = actions.makeSliceType($begin, $c1, $c2, $sub); + } + ; //subscript: '.' '.' '.' | test | [test] ':' [test] [sliceop] -subscript : DOT DOT DOT -> Ellipsis - | (test[expr_contextType.Load] COLON) => t1=test[expr_contextType.Load] (COLON (t2=test[expr_contextType.Load])? (sliceop)?)? -> ^(Subscript ^(Lower $t1) ^(Upper COLON ^(UpperOp $t2)?)? sliceop?) - | (COLON) => COLON (test[expr_contextType.Load])? (sliceop)? -> ^(Subscript ^(Upper COLON ^(UpperOp test)?)? sliceop?) - | test[expr_contextType.Load] -> ^(Index test) - ; +subscript returns [sliceType sltype] +@after { + if ($sltype != null) { + $subscript.tree = $sltype; + } +} + : d1=DOT DOT DOT + -> DOT<Ellipsis>[$d1] + | (test[null] COLON) + => lower=test[expr_contextType.Load] (c1=COLON (upper1=test[expr_contextType.Load])? (sliceop)?)? + { + $sltype = actions.makeSubscript($lower.tree, $c1, $upper1.tree, $sliceop.tree); + } + | (COLON) + => c2=COLON (upper2=test[expr_contextType.Load])? (sliceop)? + { + $sltype = actions.makeSubscript(null, $c2, $upper2.tree, $sliceop.tree); + } + | test[expr_contextType.Load] + -> ^(LPAREN<Index>[$test.start, (exprType)$test.tree]) + ; //sliceop: ':' [test] -sliceop : COLON (test[expr_contextType.Load])? -> ^(Step COLON ^(StepOp test)?) - ; +sliceop + : COLON + (test[expr_contextType.Load] + -> test + )? + ; //exprlist: expr (',' expr)* [','] -exprlist[expr_contextType ctype]: (expr[expr_contextType.Load] COMMA) => expr[ctype] (options {k=2;}: COMMA expr[ctype])* (COMMA)? -> ^(Tuple ^(Elts expr+)) - | expr[ctype] - ; +exprlist[expr_contextType ctype] returns [exprType etype] + : (expr[null] COMMA) => e+=expr[ctype] (options {k=2;}: COMMA e+=expr[ctype])* (COMMA)? + { + $etype = new Tuple($exprlist.start, actions.makeExprs($e), ctype); + } + | expr[ctype] + { + $etype = (exprType)$expr.tree; + } + ; -//XXX: I'm hoping I can get rid of this -- but for now I need an exprlist that does not produce tuples -// at least for del_stmt -exprlist2 : expr[expr_contextType.Load] (options {k=2;}: COMMA expr[expr_contextType.Load])* (COMMA)? - -> expr+ - ; +//not in CPython's Grammar file +//Needed as an exprlist that does not produce tuples for del_stmt. +del_list returns [List etypes] + : e+=expr[expr_contextType.Del] (options {k=2;}: COMMA e+=expr[expr_contextType.Del])* (COMMA)? + { + $etypes = $e; + } + ; //testlist: test (',' test)* [','] testlist[expr_contextType ctype] - : test[ctype] (options {k=2;}: c1=COMMA test[ctype])* (c2=COMMA)? - -> { $c1 != null || $c2 != null }? ^(Tuple ^(Elts test+)) - -> test + : (test[null] COMMA) + => t+=test[ctype] (options {k=2;}: COMMA t+=test[ctype])* (COMMA)? + -> ^(COMMA<Tuple>[$testlist.start, actions.makeExprs($t), ctype]) + | test[ctype] ; -//XXX: -//testlist_safe: test [(',' test)+ [',']] - //dictmaker: test ':' test (',' test ':' test)* [','] -dictmaker : test[expr_contextType.Load] COLON test[expr_contextType.Load] - (options {k=2;}:COMMA test[expr_contextType.Load] COLON test[expr_contextType.Load])* (COMMA)? - -> test+ - ; +dictmaker returns [List keys, List values] + : k+=test[expr_contextType.Load] COLON v+=test[expr_contextType.Load] + (options {k=2;}:COMMA k+=test[expr_contextType.Load] COLON v+=test[expr_contextType.Load])* + (COMMA)? + { + $keys = $k; + $values= $v; + } + ; //classdef: 'class' NAME ['(' [testlist] ')'] ':' suite -classdef: CLASS NAME (LPAREN testlist[expr_contextType.Load]? RPAREN)? COLON suite - -> ^(CLASS NAME ^(Bases testlist)? ^(Body suite)) +cla... [truncated message content] |
From: <nr...@us...> - 2008-08-29 19:53:07
|
Revision: 5266 http://jython.svn.sourceforge.net/jython/?rev=5266&view=rev Author: nriley Date: 2008-08-29 19:53:04 +0000 (Fri, 29 Aug 2008) Log Message: ----------- Close file immediately after comparing it. Fixes test_filecmp on Windows. Modified Paths: -------------- trunk/jython/CPythonLib.includes trunk/jython/Lib/filecmp.py Modified: trunk/jython/CPythonLib.includes =================================================================== --- trunk/jython/CPythonLib.includes 2008-08-29 19:51:57 UTC (rev 5265) +++ trunk/jython/CPythonLib.includes 2008-08-29 19:53:04 UTC (rev 5266) @@ -52,7 +52,6 @@ dospath.py dumbdbm.py exceptions.py -filecmp.py fileinput.py fnmatch.py formatter.py Modified: trunk/jython/Lib/filecmp.py =================================================================== --- trunk/jython/Lib/filecmp.py 2008-08-29 19:51:57 UTC (rev 5265) +++ trunk/jython/Lib/filecmp.py 2008-08-29 19:53:04 UTC (rev 5266) @@ -65,13 +65,17 @@ bufsize = BUFSIZE fp1 = open(f1, 'rb') fp2 = open(f2, 'rb') - while True: - b1 = fp1.read(bufsize) - b2 = fp2.read(bufsize) - if b1 != b2: - return False - if not b1: - return True + try: + while True: + b1 = fp1.read(bufsize) + b2 = fp2.read(bufsize) + if b1 != b2: + return False + if not b1: + return True + finally: + fp1.close() + fp2.close() # Directory comparison class. # This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <zy...@us...> - 2008-08-30 18:40:03
|
Revision: 5274 http://jython.svn.sourceforge.net/jython/?rev=5274&view=rev Author: zyasoft Date: 2008-08-30 18:39:59 +0000 (Sat, 30 Aug 2008) Log Message: ----------- Exposed unicode_toString, str_toString so that Jython code can directly access the underlying java.lang.String backing our unicode and str types. This enables writing code like this: return Normalizer.normalize(unistr.toString(), normalizer_form) without Jython automatically encoding the string on our behalf. That's often what we want for CPython compatibility, but not when we are calling methods like this. (Too bad we need to know.) Added unicodedata.py and supporting data files UnicodeData.txt and EastAsianWidth.txt, both from 4.10. (We may wish to update to be more compliant with Java than Python 2.5.) Because the time it takes to import, serious refactoring should be considered, including possibly doing a codegen to Java approach. Currently does not pass MD5 hash tests in test_unicodedata, which by their nature are highly sensitive. Added collections.namedtuple. First 2.6 feature. (We should have a few in Jython 2.5.) This was originally added to support Python version of unicodedata.py, but is now just included. Modified Paths: -------------- trunk/jython/CoreExposed.includes trunk/jython/Lib/test/regrtest.py trunk/jython/src/org/python/core/PyString.java trunk/jython/src/org/python/core/PyUnicode.java trunk/jython/src/org/python/modules/Setup.java Added Paths: ----------- trunk/jython/Lib/EastAsianWidth.txt trunk/jython/Lib/UnicodeData.txt trunk/jython/Lib/collections/ trunk/jython/Lib/collections/__init__.py trunk/jython/Lib/unicodedata.py trunk/jython/src/org/python/modules/_collections/ trunk/jython/src/org/python/modules/_collections/Collections.java trunk/jython/src/org/python/modules/_collections/PyDefaultDict.java trunk/jython/src/org/python/modules/_collections/PyDefaultDictDerived.java trunk/jython/src/org/python/modules/_collections/PyDeque.java trunk/jython/src/org/python/modules/_collections/PyDequeDerived.java Removed Paths: ------------- trunk/jython/src/org/python/modules/_collections/Collections.java trunk/jython/src/org/python/modules/_collections/PyDefaultDict.java trunk/jython/src/org/python/modules/_collections/PyDefaultDictDerived.java trunk/jython/src/org/python/modules/_collections/PyDeque.java trunk/jython/src/org/python/modules/_collections/PyDequeDerived.java trunk/jython/src/org/python/modules/collections/ Modified: trunk/jython/CoreExposed.includes =================================================================== --- trunk/jython/CoreExposed.includes 2008-08-29 23:45:59 UTC (rev 5273) +++ trunk/jython/CoreExposed.includes 2008-08-30 18:39:59 UTC (rev 5274) @@ -44,8 +44,8 @@ org/python/modules/_weakref/ReferenceType.class org/python/modules/_weakref/ProxyType.class org/python/modules/_hashlib$Hash.class -org/python/modules/collections/PyDefaultDict.class -org/python/modules/collections/PyDeque.class +org/python/modules/_collections/PyDefaultDict.class +org/python/modules/_collections/PyDeque.class org/python/modules/operator$PyAttrGetter.class org/python/modules/operator$PyItemGetter.class org/python/modules/random/PyRandom.class Added: trunk/jython/Lib/EastAsianWidth.txt =================================================================== --- trunk/jython/Lib/EastAsianWidth.txt (rev 0) +++ trunk/jython/Lib/EastAsianWidth.txt 2008-08-30 18:39:59 UTC (rev 5274) @@ -0,0 +1,16368 @@ +# EastAsianWidth-4.1.0.txt +# Date: 2005-03-17, 15:21:00 PST [KW] +# +# East Asian Width Properties +# +# This file is an informative contributory data file in the +# Unicode Character Database. +# +# Copyright (c) 1991-2005 Unicode, Inc. +# For terms of use, see http://www.unicode.org/terms_of_use.html +# +# The format is two fields separated by a semicolon. +# Field 0: Unicode value +# Field 1: East Asian Width property, consisting of one of the following values: +# "N", "A", "H", "W", "F", "Na" +# - All code points, assigned or unassigned, that are not listed +# explicitly are given the value "N". +# - Characters ranges are specified as for other property files in +# the Unicode Character Database. +# +# The Unicode name of each character is provided in a comment for help +# in identifying the characters. +# +# See UAX #11: East Asian Character Width, for more information. +0000;N # <control> +0001;N # <control> +0002;N # <control> +0003;N # <control> +0004;N # <control> +0005;N # <control> +0006;N # <control> +0007;N # <control> +0008;N # <control> +0009;N # <control> +000A;N # <control> +000B;N # <control> +000C;N # <control> +000D;N # <control> +000E;N # <control> +000F;N # <control> +0010;N # <control> +0011;N # <control> +0012;N # <control> +0013;N # <control> +0014;N # <control> +0015;N # <control> +0016;N # <control> +0017;N # <control> +0018;N # <control> +0019;N # <control> +001A;N # <control> +001B;N # <control> +001C;N # <control> +001D;N # <control> +001E;N # <control> +001F;N # <control> +0020;Na # SPACE +0021;Na # EXCLAMATION MARK +0022;Na # QUOTATION MARK +0023;Na # NUMBER SIGN +0024;Na # DOLLAR SIGN +0025;Na # PERCENT SIGN +0026;Na # AMPERSAND +0027;Na # APOSTROPHE +0028;Na # LEFT PARENTHESIS +0029;Na # RIGHT PARENTHESIS +002A;Na # ASTERISK +002B;Na # PLUS SIGN +002C;Na # COMMA +002D;Na # HYPHEN-MINUS +002E;Na # FULL STOP +002F;Na # SOLIDUS +0030;Na # DIGIT ZERO +0031;Na # DIGIT ONE +0032;Na # DIGIT TWO +0033;Na # DIGIT THREE +0034;Na # DIGIT FOUR +0035;Na # DIGIT FIVE +0036;Na # DIGIT SIX +0037;Na # DIGIT SEVEN +0038;Na # DIGIT EIGHT +0039;Na # DIGIT NINE +003A;Na # COLON +003B;Na # SEMICOLON +003C;Na # LESS-THAN SIGN +003D;Na # EQUALS SIGN +003E;Na # GREATER-THAN SIGN +003F;Na # QUESTION MARK +0040;Na # COMMERCIAL AT +0041;Na # LATIN CAPITAL LETTER A +0042;Na # LATIN CAPITAL LETTER B +0043;Na # LATIN CAPITAL LETTER C +0044;Na # LATIN CAPITAL LETTER D +0045;Na # LATIN CAPITAL LETTER E +0046;Na # LATIN CAPITAL LETTER F +0047;Na # LATIN CAPITAL LETTER G +0048;Na # LATIN CAPITAL LETTER H +0049;Na # LATIN CAPITAL LETTER I +004A;Na # LATIN CAPITAL LETTER J +004B;Na # LATIN CAPITAL LETTER K +004C;Na # LATIN CAPITAL LETTER L +004D;Na # LATIN CAPITAL LETTER M +004E;Na # LATIN CAPITAL LETTER N +004F;Na # LATIN CAPITAL LETTER O +0050;Na # LATIN CAPITAL LETTER P +0051;Na # LATIN CAPITAL LETTER Q +0052;Na # LATIN CAPITAL LETTER R +0053;Na # LATIN CAPITAL LETTER S +0054;Na # LATIN CAPITAL LETTER T +0055;Na # LATIN CAPITAL LETTER U +0056;Na # LATIN CAPITAL LETTER V +0057;Na # LATIN CAPITAL LETTER W +0058;Na # LATIN CAPITAL LETTER X +0059;Na # LATIN CAPITAL LETTER Y +005A;Na # LATIN CAPITAL LETTER Z +005B;Na # LEFT SQUARE BRACKET +005C;Na # REVERSE SOLIDUS +005D;Na # RIGHT SQUARE BRACKET +005E;Na # CIRCUMFLEX ACCENT +005F;Na # LOW LINE +0060;Na # GRAVE ACCENT +0061;Na # LATIN SMALL LETTER A +0062;Na # LATIN SMALL LETTER B +0063;Na # LATIN SMALL LETTER C +0064;Na # LATIN SMALL LETTER D +0065;Na # LATIN SMALL LETTER E +0066;Na # LATIN SMALL LETTER F +0067;Na # LATIN SMALL LETTER G +0068;Na # LATIN SMALL LETTER H +0069;Na # LATIN SMALL LETTER I +006A;Na # LATIN SMALL LETTER J +006B;Na # LATIN SMALL LETTER K +006C;Na # LATIN SMALL LETTER L +006D;Na # LATIN SMALL LETTER M +006E;Na # LATIN SMALL LETTER N +006F;Na # LATIN SMALL LETTER O +0070;Na # LATIN SMALL LETTER P +0071;Na # LATIN SMALL LETTER Q +0072;Na # LATIN SMALL LETTER R +0073;Na # LATIN SMALL LETTER S +0074;Na # LATIN SMALL LETTER T +0075;Na # LATIN SMALL LETTER U +0076;Na # LATIN SMALL LETTER V +0077;Na # LATIN SMALL LETTER W +0078;Na # LATIN SMALL LETTER X +0079;Na # LATIN SMALL LETTER Y +007A;Na # LATIN SMALL LETTER Z +007B;Na # LEFT CURLY BRACKET +007C;Na # VERTICAL LINE +007D;Na # RIGHT CURLY BRACKET +007E;Na # TILDE +007F;N # <control> +0080;N # <control> +0081;N # <control> +0082;N # <control> +0083;N # <control> +0084;N # <control> +0085;N # <control> +0086;N # <control> +0087;N # <control> +0088;N # <control> +0089;N # <control> +008A;N # <control> +008B;N # <control> +008C;N # <control> +008D;N # <control> +008E;N # <control> +008F;N # <control> +0090;N # <control> +0091;N # <control> +0092;N # <control> +0093;N # <control> +0094;N # <control> +0095;N # <control> +0096;N # <control> +0097;N # <control> +0098;N # <control> +0099;N # <control> +009A;N # <control> +009B;N # <control> +009C;N # <control> +009D;N # <control> +009E;N # <control> +009F;N # <control> +00A0;N # NO-BREAK SPACE +00A1;A # INVERTED EXCLAMATION MARK +00A2;Na # CENT SIGN +00A3;Na # POUND SIGN +00A4;A # CURRENCY SIGN +00A5;Na # YEN SIGN +00A6;Na # BROKEN BAR +00A7;A # SECTION SIGN +00A8;A # DIAERESIS +00A9;N # COPYRIGHT SIGN +00AA;A # FEMININE ORDINAL INDICATOR +00AB;N # LEFT-POINTING DOUBLE ANGLE QUOTATION MARK +00AC;Na # NOT SIGN +00AD;A # SOFT HYPHEN +00AE;A # REGISTERED SIGN +00AF;Na # MACRON +00B0;A # DEGREE SIGN +00B1;A # PLUS-MINUS SIGN +00B2;A # SUPERSCRIPT TWO +00B3;A # SUPERSCRIPT THREE +00B4;A # ACUTE ACCENT +00B5;N # MICRO SIGN +00B6;A # PILCROW SIGN +00B7;A # MIDDLE DOT +00B8;A # CEDILLA +00B9;A # SUPERSCRIPT ONE +00BA;A # MASCULINE ORDINAL INDICATOR +00BB;N # RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK +00BC;A # VULGAR FRACTION ONE QUARTER +00BD;A # VULGAR FRACTION ONE HALF +00BE;A # VULGAR FRACTION THREE QUARTERS +00BF;A # INVERTED QUESTION MARK +00C0;N # LATIN CAPITAL LETTER A WITH GRAVE +00C1;N # LATIN CAPITAL LETTER A WITH ACUTE +00C2;N # LATIN CAPITAL LETTER A WITH CIRCUMFLEX +00C3;N # LATIN CAPITAL LETTER A WITH TILDE +00C4;N # LATIN CAPITAL LETTER A WITH DIAERESIS +00C5;N # LATIN CAPITAL LETTER A WITH RING ABOVE +00C6;A # LATIN CAPITAL LETTER AE +00C7;N # LATIN CAPITAL LETTER C WITH CEDILLA +00C8;N # LATIN CAPITAL LETTER E WITH GRAVE +00C9;N # LATIN CAPITAL LETTER E WITH ACUTE +00CA;N # LATIN CAPITAL LETTER E WITH CIRCUMFLEX +00CB;N # LATIN CAPITAL LETTER E WITH DIAERESIS +00CC;N # LATIN CAPITAL LETTER I WITH GRAVE +00CD;N # LATIN CAPITAL LETTER I WITH ACUTE +00CE;N # LATIN CAPITAL LETTER I WITH CIRCUMFLEX +00CF;N # LATIN CAPITAL LETTER I WITH DIAERESIS +00D0;A # LATIN CAPITAL LETTER ETH +00D1;N # LATIN CAPITAL LETTER N WITH TILDE +00D2;N # LATIN CAPITAL LETTER O WITH GRAVE +00D3;N # LATIN CAPITAL LETTER O WITH ACUTE +00D4;N # LATIN CAPITAL LETTER O WITH CIRCUMFLEX +00D5;N # LATIN CAPITAL LETTER O WITH TILDE +00D6;N # LATIN CAPITAL LETTER O WITH DIAERESIS +00D7;A # MULTIPLICATION SIGN +00D8;A # LATIN CAPITAL LETTER O WITH STROKE +00D9;N # LATIN CAPITAL LETTER U WITH GRAVE +00DA;N # LATIN CAPITAL LETTER U WITH ACUTE +00DB;N # LATIN CAPITAL LETTER U WITH CIRCUMFLEX +00DC;N # LATIN CAPITAL LETTER U WITH DIAERESIS +00DD;N # LATIN CAPITAL LETTER Y WITH ACUTE +00DE;A # LATIN CAPITAL LETTER THORN +00DF;A # LATIN SMALL LETTER SHARP S +00E0;A # LATIN SMALL LETTER A WITH GRAVE +00E1;A # LATIN SMALL LETTER A WITH ACUTE +00E2;N # LATIN SMALL LETTER A WITH CIRCUMFLEX +00E3;N # LATIN SMALL LETTER A WITH TILDE +00E4;N # LATIN SMALL LETTER A WITH DIAERESIS +00E5;N # LATIN SMALL LETTER A WITH RING ABOVE +00E6;A # LATIN SMALL LETTER AE +00E7;N # LATIN SMALL LETTER C WITH CEDILLA +00E8;A # LATIN SMALL LETTER E WITH GRAVE +00E9;A # LATIN SMALL LETTER E WITH ACUTE +00EA;A # LATIN SMALL LETTER E WITH CIRCUMFLEX +00EB;N # LATIN SMALL LETTER E WITH DIAERESIS +00EC;A # LATIN SMALL LETTER I WITH GRAVE +00ED;A # LATIN SMALL LETTER I WITH ACUTE +00EE;N # LATIN SMALL LETTER I WITH CIRCUMFLEX +00EF;N # LATIN SMALL LETTER I WITH DIAERESIS +00F0;A # LATIN SMALL LETTER ETH +00F1;N # LATIN SMALL LETTER N WITH TILDE +00F2;A # LATIN SMALL LETTER O WITH GRAVE +00F3;A # LATIN SMALL LETTER O WITH ACUTE +00F4;N # LATIN SMALL LETTER O WITH CIRCUMFLEX +00F5;N # LATIN SMALL LETTER O WITH TILDE +00F6;N # LATIN SMALL LETTER O WITH DIAERESIS +00F7;A # DIVISION SIGN +00F8;A # LATIN SMALL LETTER O WITH STROKE +00F9;A # LATIN SMALL LETTER U WITH GRAVE +00FA;A # LATIN SMALL LETTER U WITH ACUTE +00FB;N # LATIN SMALL LETTER U WITH CIRCUMFLEX +00FC;A # LATIN SMALL LETTER U WITH DIAERESIS +00FD;N # LATIN SMALL LETTER Y WITH ACUTE +00FE;A # LATIN SMALL LETTER THORN +00FF;N # LATIN SMALL LETTER Y WITH DIAERESIS +0100;N # LATIN CAPITAL LETTER A WITH MACRON +0101;A # LATIN SMALL LETTER A WITH MACRON +0102;N # LATIN CAPITAL LETTER A WITH BREVE +0103;N # LATIN SMALL LETTER A WITH BREVE +0104;N # LATIN CAPITAL LETTER A WITH OGONEK +0105;N # LATIN SMALL LETTER A WITH OGONEK +0106;N # LATIN CAPITAL LETTER C WITH ACUTE +0107;N # LATIN SMALL LETTER C WITH ACUTE +0108;N # LATIN CAPITAL LETTER C WITH CIRCUMFLEX +0109;N # LATIN SMALL LETTER C WITH CIRCUMFLEX +010A;N # LATIN CAPITAL LETTER C WITH DOT ABOVE +010B;N # LATIN SMALL LETTER C WITH DOT ABOVE +010C;N # LATIN CAPITAL LETTER C WITH CARON +010D;N # LATIN SMALL LETTER C WITH CARON +010E;N # LATIN CAPITAL LETTER D WITH CARON +010F;N # LATIN SMALL LETTER D WITH CARON +0110;N # LATIN CAPITAL LETTER D WITH STROKE +0111;A # LATIN SMALL LETTER D WITH STROKE +0112;N # LATIN CAPITAL LETTER E WITH MACRON +0113;A # LATIN SMALL LETTER E WITH MACRON +0114;N # LATIN CAPITAL LETTER E WITH BREVE +0115;N # LATIN SMALL LETTER E WITH BREVE +0116;N # LATIN CAPITAL LETTER E WITH DOT ABOVE +0117;N # LATIN SMALL LETTER E WITH DOT ABOVE +0118;N # LATIN CAPITAL LETTER E WITH OGONEK +0119;N # LATIN SMALL LETTER E WITH OGONEK +011A;N # LATIN CAPITAL LETTER E WITH CARON +011B;A # LATIN SMALL LETTER E WITH CARON +011C;N # LATIN CAPITAL LETTER G WITH CIRCUMFLEX +011D;N # LATIN SMALL LETTER G WITH CIRCUMFLEX +011E;N # LATIN CAPITAL LETTER G WITH BREVE +011F;N # LATIN SMALL LETTER G WITH BREVE +0120;N # LATIN CAPITAL LETTER G WITH DOT ABOVE +0121;N # LATIN SMALL LETTER G WITH DOT ABOVE +0122;N # LATIN CAPITAL LETTER G WITH CEDILLA +0123;N # LATIN SMALL LETTER G WITH CEDILLA +0124;N # LATIN CAPITAL LETTER H WITH CIRCUMFLEX +0125;N # LATIN SMALL LETTER H WITH CIRCUMFLEX +0126;A # LATIN CAPITAL LETTER H WITH STROKE +0127;A # LATIN SMALL LETTER H WITH STROKE +0128;N # LATIN CAPITAL LETTER I WITH TILDE +0129;N # LATIN SMALL LETTER I WITH TILDE +012A;N # LATIN CAPITAL LETTER I WITH MACRON +012B;A # LATIN SMALL LETTER I WITH MACRON +012C;N # LATIN CAPITAL LETTER I WITH BREVE +012D;N # LATIN SMALL LETTER I WITH BREVE +012E;N # LATIN CAPITAL LETTER I WITH OGONEK +012F;N # LATIN SMALL LETTER I WITH OGONEK +0130;N # LATIN CAPITAL LETTER I WITH DOT ABOVE +0131;A # LATIN SMALL LETTER DOTLESS I +0132;A # LATIN CAPITAL LIGATURE IJ +0133;A # LATIN SMALL LIGATURE IJ +0134;N # LATIN CAPITAL LETTER J WITH CIRCUMFLEX +0135;N # LATIN SMALL LETTER J WITH CIRCUMFLEX +0136;N # LATIN CAPITAL LETTER K WITH CEDILLA +0137;N # LATIN SMALL LETTER K WITH CEDILLA +0138;A # LATIN SMALL LETTER KRA +0139;N # LATIN CAPITAL LETTER L WITH ACUTE +013A;N # LATIN SMALL LETTER L WITH ACUTE +013B;N # LATIN CAPITAL LETTER L WITH CEDILLA +013C;N # LATIN SMALL LETTER L WITH CEDILLA +013D;N # LATIN CAPITAL LETTER L WITH CARON +013E;N # LATIN SMALL LETTER L WITH CARON +013F;A # LATIN CAPITAL LETTER L WITH MIDDLE DOT +0140;A # LATIN SMALL LETTER L WITH MIDDLE DOT +0141;A # LATIN CAPITAL LETTER L WITH STROKE +0142;A # LATIN SMALL LETTER L WITH STROKE +0143;N # LATIN CAPITAL LETTER N WITH ACUTE +0144;A # LATIN SMALL LETTER N WITH ACUTE +0145;N # LATIN CAPITAL LETTER N WITH CEDILLA +0146;N # LATIN SMALL LETTER N WITH CEDILLA +0147;N # LATIN CAPITAL LETTER N WITH CARON +0148;A # LATIN SMALL LETTER N WITH CARON +0149;A # LATIN SMALL LETTER N PRECEDED BY APOSTROPHE +014A;A # LATIN CAPITAL LETTER ENG +014B;A # LATIN SMALL LETTER ENG +014C;N # LATIN CAPITAL LETTER O WITH MACRON +014D;A # LATIN SMALL LETTER O WITH MACRON +014E;N # LATIN CAPITAL LETTER O WITH BREVE +014F;N # LATIN SMALL LETTER O WITH BREVE +0150;N # LATIN CAPITAL LETTER O WITH DOUBLE ACUTE +0151;N # LATIN SMALL LETTER O WITH DOUBLE ACUTE +0152;A # LATIN CAPITAL LIGATURE OE +0153;A # LATIN SMALL LIGATURE OE +0154;N # LATIN CAPITAL LETTER R WITH ACUTE +0155;N # LATIN SMALL LETTER R WITH ACUTE +0156;N # LATIN CAPITAL LETTER R WITH CEDILLA +0157;N # LATIN SMALL LETTER R WITH CEDILLA +0158;N # LATIN CAPITAL LETTER R WITH CARON +0159;N # LATIN SMALL LETTER R WITH CARON +015A;N # LATIN CAPITAL LETTER S WITH ACUTE +015B;N # LATIN SMALL LETTER S WITH ACUTE +015C;N # LATIN CAPITAL LETTER S WITH CIRCUMFLEX +015D;N # LATIN SMALL LETTER S WITH CIRCUMFLEX +015E;N # LATIN CAPITAL LETTER S WITH CEDILLA +015F;N # LATIN SMALL LETTER S WITH CEDILLA +0160;N # LATIN CAPITAL LETTER S WITH CARON +0161;N # LATIN SMALL LETTER S WITH CARON +0162;N # LATIN CAPITAL LETTER T WITH CEDILLA +0163;N # LATIN SMALL LETTER T WITH CEDILLA +0164;N # LATIN CAPITAL LETTER T WITH CARON +0165;N # LATIN SMALL LETTER T WITH CARON +0166;A # LATIN CAPITAL LETTER T WITH STROKE +0167;A # LATIN SMALL LETTER T WITH STROKE +0168;N # LATIN CAPITAL LETTER U WITH TILDE +0169;N # LATIN SMALL LETTER U WITH TILDE +016A;N # LATIN CAPITAL LETTER U WITH MACRON +016B;A # LATIN SMALL LETTER U WITH MACRON +016C;N # LATIN CAPITAL LETTER U WITH BREVE +016D;N # LATIN SMALL LETTER U WITH BREVE +016E;N # LATIN CAPITAL LETTER U WITH RING ABOVE +016F;N # LATIN SMALL LETTER U WITH RING ABOVE +0170;N # LATIN CAPITAL LETTER U WITH DOUBLE ACUTE +0171;N # LATIN SMALL LETTER U WITH DOUBLE ACUTE +0172;N # LATIN CAPITAL LETTER U WITH OGONEK +0173;N # LATIN SMALL LETTER U WITH OGONEK +0174;N # LATIN CAPITAL LETTER W WITH CIRCUMFLEX +0175;N # LATIN SMALL LETTER W WITH CIRCUMFLEX +0176;N # LATIN CAPITAL LETTER Y WITH CIRCUMFLEX +0177;N # LATIN SMALL LETTER Y WITH CIRCUMFLEX +0178;N # LATIN CAPITAL LETTER Y WITH DIAERESIS +0179;N # LATIN CAPITAL LETTER Z WITH ACUTE +017A;N # LATIN SMALL LETTER Z WITH ACUTE +017B;N # LATIN CAPITAL LETTER Z WITH DOT ABOVE +017C;N # LATIN SMALL LETTER Z WITH DOT ABOVE +017D;N # LATIN CAPITAL LETTER Z WITH CARON +017E;N # LATIN SMALL LETTER Z WITH CARON +017F;N # LATIN SMALL LETTER LONG S +0180;N # LATIN SMALL LETTER B WITH STROKE +0181;N # LATIN CAPITAL LETTER B WITH HOOK +0182;N # LATIN CAPITAL LETTER B WITH TOPBAR +0183;N # LATIN SMALL LETTER B WITH TOPBAR +0184;N # LATIN CAPITAL LETTER TONE SIX +0185;N # LATIN SMALL LETTER TONE SIX +0186;N # LATIN CAPITAL LETTER OPEN O +0187;N # LATIN CAPITAL LETTER C WITH HOOK +0188;N # LATIN SMALL LETTER C WITH HOOK +0189;N # LATIN CAPITAL LETTER AFRICAN D +018A;N # LATIN CAPITAL LETTER D WITH HOOK +018B;N # LATIN CAPITAL LETTER D WITH TOPBAR +018C;N # LATIN SMALL LETTER D WITH TOPBAR +018D;N # LATIN SMALL LETTER TURNED DELTA +018E;N # LATIN CAPITAL LETTER REVERSED E +018F;N # LATIN CAPITAL LETTER SCHWA +0190;N # LATIN CAPITAL LETTER OPEN E +0191;N # LATIN CAPITAL LETTER F WITH HOOK +0192;N # LATIN SMALL LETTER F WITH HOOK +0193;N # LATIN CAPITAL LETTER G WITH HOOK +0194;N # LATIN CAPITAL LETTER GAMMA +0195;N # LATIN SMALL LETTER HV +0196;N # LATIN CAPITAL LETTER IOTA +0197;N # LATIN CAPITAL LETTER I WITH STROKE +0198;N # LATIN CAPITAL LETTER K WITH HOOK +0199;N # LATIN SMALL LETTER K WITH HOOK +019A;N # LATIN SMALL LETTER L WITH BAR +019B;N # LATIN SMALL LETTER LAMBDA WITH STROKE +019C;N # LATIN CAPITAL LETTER TURNED M +019D;N # LATIN CAPITAL LETTER N WITH LEFT HOOK +019E;N # LATIN SMALL LETTER N WITH LONG RIGHT LEG +019F;N # LATIN CAPITAL LETTER O WITH MIDDLE TILDE +01A0;N # LATIN CAPITAL LETTER O WITH HORN +01A1;N # LATIN SMALL LETTER O WITH HORN +01A2;N # LATIN CAPITAL LETTER OI +01A3;N # LATIN SMALL LETTER OI +01A4;N # LATIN CAPITAL LETTER P WITH HOOK +01A5;N # LATIN SMALL LETTER P WITH HOOK +01A6;N # LATIN LETTER YR +01A7;N # LATIN CAPITAL LETTER TONE TWO +01A8;N # LATIN SMALL LETTER TONE TWO +01A9;N # LATIN CAPITAL LETTER ESH +01AA;N # LATIN LETTER REVERSED ESH LOOP +01AB;N # LATIN SMALL LETTER T WITH PALATAL HOOK +01AC;N # LATIN CAPITAL LETTER T WITH HOOK +01AD;N # LATIN SMALL LETTER T WITH HOOK +01AE;N # LATIN CAPITAL LETTER T WITH RETROFLEX HOOK +01AF;N # LATIN CAPITAL LETTER U WITH HORN +01B0;N # LATIN SMALL LETTER U WITH HORN +01B1;N # LATIN CAPITAL LETTER UPSILON +01B2;N # LATIN CAPITAL LETTER V WITH HOOK +01B3;N # LATIN CAPITAL LETTER Y WITH HOOK +01B4;N # LATIN SMALL LETTER Y WITH HOOK +01B5;N # LATIN CAPITAL LETTER Z WITH STROKE +01B6;N # LATIN SMALL LETTER Z WITH STROKE +01B7;N # LATIN CAPITAL LETTER EZH +01B8;N # LATIN CAPITAL LETTER EZH REVERSED +01B9;N # LATIN SMALL LETTER EZH REVERSED +01BA;N # LATIN SMALL LETTER EZH WITH TAIL +01BB;N # LATIN LETTER TWO WITH STROKE +01BC;N # LATIN CAPITAL LETTER TONE FIVE +01BD;N # LATIN SMALL LETTER TONE FIVE +01BE;N # LATIN LETTER INVERTED GLOTTAL STOP WITH STROKE +01BF;N # LATIN LETTER WYNN +01C0;N # LATIN LETTER DENTAL CLICK +01C1;N # LATIN LETTER LATERAL CLICK +01C2;N # LATIN LETTER ALVEOLAR CLICK +01C3;N # LATIN LETTER RETROFLEX CLICK +01C4;N # LATIN CAPITAL LETTER DZ WITH CARON +01C5;N # LATIN CAPITAL LETTER D WITH SMALL LETTER Z WITH CARON +01C6;N # LATIN SMALL LETTER DZ WITH CARON +01C7;N # LATIN CAPITAL LETTER LJ +01C8;N # LATIN CAPITAL LETTER L WITH SMALL LETTER J +01C9;N # LATIN SMALL LETTER LJ +01CA;N # LATIN CAPITAL LETTER NJ +01CB;N # LATIN CAPITAL LETTER N WITH SMALL LETTER J +01CC;N # LATIN SMALL LETTER NJ +01CD;N # LATIN CAPITAL LETTER A WITH CARON +01CE;A # LATIN SMALL LETTER A WITH CARON +01CF;N # LATIN CAPITAL LETTER I WITH CARON +01D0;A # LATIN SMALL LETTER I WITH CARON +01D1;N # LATIN CAPITAL LETTER O WITH CARON +01D2;A # LATIN SMALL LETTER O WITH CARON +01D3;N # LATIN CAPITAL LETTER U WITH CARON +01D4;A # LATIN SMALL LETTER U WITH CARON +01D5;N # LATIN CAPITAL LETTER U WITH DIAERESIS AND MACRON +01D6;A # LATIN SMALL LETTER U WITH DIAERESIS AND MACRON +01D7;N # LATIN CAPITAL LETTER U WITH DIAERESIS AND ACUTE +01D8;A # LATIN SMALL LETTER U WITH DIAERESIS AND ACUTE +01D9;N # LATIN CAPITAL LETTER U WITH DIAERESIS AND CARON +01DA;A # LATIN SMALL LETTER U WITH DIAERESIS AND CARON +01DB;N # LATIN CAPITAL LETTER U WITH DIAERESIS AND GRAVE +01DC;A # LATIN SMALL LETTER U WITH DIAERESIS AND GRAVE +01DD;N # LATIN SMALL LETTER TURNED E +01DE;N # LATIN CAPITAL LETTER A WITH DIAERESIS AND MACRON +01DF;N # LATIN SMALL LETTER A WITH DIAERESIS AND MACRON +01E0;N # LATIN CAPITAL LETTER A WITH DOT ABOVE AND MACRON +01E1;N # LATIN SMALL LETTER A WITH DOT ABOVE AND MACRON +01E2;N # LATIN CAPITAL LETTER AE WITH MACRON +01E3;N # LATIN SMALL LETTER AE WITH MACRON +01E4;N # LATIN CAPITAL LETTER G WITH STROKE +01E5;N # LATIN SMALL LETTER G WITH STROKE +01E6;N # LATIN CAPITAL LETTER G WITH CARON +01E7;N # LATIN SMALL LETTER G WITH CARON +01E8;N # LATIN CAPITAL LETTER K WITH CARON +01E9;N # LATIN SMALL LETTER K WITH CARON +01EA;N # LATIN CAPITAL LETTER O WITH OGONEK +01EB;N # LATIN SMALL LETTER O WITH OGONEK +01EC;N # LATIN CAPITAL LETTER O WITH OGONEK AND MACRON +01ED;N # LATIN SMALL LETTER O WITH OGONEK AND MACRON +01EE;N # LATIN CAPITAL LETTER EZH WITH CARON +01EF;N # LATIN SMALL LETTER EZH WITH CARON +01F0;N # LATIN SMALL LETTER J WITH CARON +01F1;N # LATIN CAPITAL LETTER DZ +01F2;N # LATIN CAPITAL LETTER D WITH SMALL LETTER Z +01F3;N # LATIN SMALL LETTER DZ +01F4;N # LATIN CAPITAL LETTER G WITH ACUTE +01F5;N # LATIN SMALL LETTER G WITH ACUTE +01F6;N # LATIN CAPITAL LETTER HWAIR +01F7;N # LATIN CAPITAL LETTER WYNN +01F8;N # LATIN CAPITAL LETTER N WITH GRAVE +01F9;N # LATIN SMALL LETTER N WITH GRAVE +01FA;N # LATIN CAPITAL LETTER A WITH RING ABOVE AND ACUTE +01FB;N # LATIN SMALL LETTER A WITH RING ABOVE AND ACUTE +01FC;N # LATIN CAPITAL LETTER AE WITH ACUTE +01FD;N # LATIN SMALL LETTER AE WITH ACUTE +01FE;N # LATIN CAPITAL LETTER O WITH STROKE AND ACUTE +01FF;N # LATIN SMALL LETTER O WITH STROKE AND ACUTE +0200;N # LATIN CAPITAL LETTER A WITH DOUBLE GRAVE +0201;N # LATIN SMALL LETTER A WITH DOUBLE GRAVE +0202;N # LATIN CAPITAL LETTER A WITH INVERTED BREVE +0203;N # LATIN SMALL LETTER A WITH INVERTED BREVE +0204;N # LATIN CAPITAL LETTER E WITH DOUBLE GRAVE +0205;N # LATIN SMALL LETTER E WITH DOUBLE GRAVE +0206;N # LATIN CAPITAL LETTER E WITH INVERTED BREVE +0207;N # LATIN SMALL LETTER E WITH INVERTED BREVE +0208;N # LATIN CAPITAL LETTER I WITH DOUBLE GRAVE +0209;N # LATIN SMALL LETTER I WITH DOUBLE GRAVE +020A;N # LATIN CAPITAL LETTER I WITH INVERTED BREVE +020B;N # LATIN SMALL LETTER I WITH INVERTED BREVE +020C;N # LATIN CAPITAL LETTER O WITH DOUBLE GRAVE +020D;N # LATIN SMALL LETTER O WITH DOUBLE GRAVE +020E;N # LATIN CAPITAL LETTER O WITH INVERTED BREVE +020F;N # LATIN SMALL LETTER O WITH INVERTED BREVE +0210;N # LATIN CAPITAL LETTER R WITH DOUBLE GRAVE +0211;N # LATIN SMALL LETTER R WITH DOUBLE GRAVE +0212;N # LATIN CAPITAL LETTER R WITH INVERTED BREVE +0213;N # LATIN SMALL LETTER R WITH INVERTED BREVE +0214;N # LATIN CAPITAL LETTER U WITH DOUBLE GRAVE +0215;N # LATIN SMALL LETTER U WITH DOUBLE GRAVE +0216;N # LATIN CAPITAL LETTER U WITH INVERTED BREVE +0217;N # LATIN SMALL LETTER U WITH INVERTED BREVE +0218;N # LATIN CAPITAL LETTER S WITH COMMA BELOW +0219;N # LATIN SMALL LETTER S WITH COMMA BELOW +021A;N # LATIN CAPITAL LETTER T WITH COMMA BELOW +021B;N # LATIN SMALL LETTER T WITH COMMA BELOW +021C;N # LATIN CAPITAL LETTER YOGH +021D;N # LATIN SMALL LETTER YOGH +021E;N # LATIN CAPITAL LETTER H WITH CARON +021F;N # LATIN SMALL LETTER H WITH CARON +0220;N # LATIN CAPITAL LETTER N WITH LONG RIGHT LEG +0221;N # LATIN SMALL LETTER D WITH CURL +0222;N # LATIN CAPITAL LETTER OU +0223;N # LATIN SMALL LETTER OU +0224;N # LATIN CAPITAL LETTER Z WITH HOOK +0225;N # LATIN SMALL LETTER Z WITH HOOK +0226;N # LATIN CAPITAL LETTER A WITH DOT ABOVE +0227;N # LATIN SMALL LETTER A WITH DOT ABOVE +0228;N # LATIN CAPITAL LETTER E WITH CEDILLA +0229;N # LATIN SMALL LETTER E WITH CEDILLA +022A;N # LATIN CAPITAL LETTER O WITH DIAERESIS AND MACRON +022B;N # LATIN SMALL LETTER O WITH DIAERESIS AND MACRON +022C;N # LATIN CAPITAL LETTER O WITH TILDE AND MACRON +022D;N # LATIN SMALL LETTER O WITH TILDE AND MACRON +022E;N # LATIN CAPITAL LETTER O WITH DOT ABOVE +022F;N # LATIN SMALL LETTER O WITH DOT ABOVE +0230;N # LATIN CAPITAL LETTER O WITH DOT ABOVE AND MACRON +0231;N # LATIN SMALL LETTER O WITH DOT ABOVE AND MACRON +0232;N # LATIN CAPITAL LETTER Y WITH MACRON +0233;N # LATIN SMALL LETTER Y WITH MACRON +0234;N # LATIN SMALL LETTER L WITH CURL +0235;N # LATIN SMALL LETTER N WITH CURL +0236;N # LATIN SMALL LETTER T WITH CURL +0237;N # LATIN SMALL LETTER DOTLESS J +0238;N # LATIN SMALL LETTER DB DIGRAPH +0239;N # LATIN SMALL LETTER QP DIGRAPH +023A;N # LATIN CAPITAL LETTER A WITH STROKE +023B;N # LATIN CAPITAL LETTER C WITH STROKE +023C;N # LATIN SMALL LETTER C WITH STROKE +023D;N # LATIN CAPITAL LETTER L WITH BAR +023E;N # LATIN CAPITAL LETTER T WITH DIAGONAL STROKE +023F;N # LATIN SMALL LETTER S WITH SWASH TAIL +0240;N # LATIN SMALL LETTER Z WITH SWASH TAIL +0241;N # LATIN CAPITAL LETTER GLOTTAL STOP +0250;N # LATIN SMALL LETTER TURNED A +0251;A # LATIN SMALL LETTER ALPHA +0252;N # LATIN SMALL LETTER TURNED ALPHA +0253;N # LATIN SMALL LETTER B WITH HOOK +0254;N # LATIN SMALL LETTER OPEN O +0255;N # LATIN SMALL LETTER C WITH CURL +0256;N # LATIN SMALL LETTER D WITH TAIL +0257;N # LATIN SMALL LETTER D WITH HOOK +0258;N # LATIN SMALL LETTER REVERSED E +0259;N # LATIN SMALL LETTER SCHWA +025A;N # LATIN SMALL LETTER SCHWA WITH HOOK +025B;N # LATIN SMALL LETTER OPEN E +025C;N # LATIN SMALL LETTER REVERSED OPEN E +025D;N # LATIN SMALL LETTER REVERSED OPEN E WITH HOOK +025E;N # LATIN SMALL LETTER CLOSED REVERSED OPEN E +025F;N # LATIN SMALL LETTER DOTLESS J WITH STROKE +0260;N # LATIN SMALL LETTER G WITH HOOK +0261;A # LATIN SMALL LETTER SCRIPT G +0262;N # LATIN LETTER SMALL CAPITAL G +0263;N # LATIN SMALL LETTER GAMMA +0264;N # LATIN SMALL LETTER RAMS HORN +0265;N # LATIN SMALL LETTER TURNED H +0266;N # LATIN SMALL LETTER H WITH HOOK +0267;N # LATIN SMALL LETTER HENG WITH HOOK +0268;N # LATIN SMALL LETTER I WITH STROKE +0269;N # LATIN SMALL LETTER IOTA +026A;N # LATIN LETTER SMALL CAPITAL I +026B;N # LATIN SMALL LETTER L WITH MIDDLE TILDE +026C;N # LATIN SMALL LETTER L WITH BELT +026D;N # LATIN SMALL LETTER L WITH RETROFLEX HOOK +026E;N # LATIN SMALL LETTER LEZH +026F;N # LATIN SMALL LETTER TURNED M +0270;N # LATIN SMALL LETTER TURNED M WITH LONG LEG +0271;N # LATIN SMALL LETTER M WITH HOOK +0272;N # LATIN SMALL LETTER N WITH LEFT HOOK +0273;N # LATIN SMALL LETTER N WITH RETROFLEX HOOK +0274;N # LATIN LETTER SMALL CAPITAL N +0275;N # LATIN SMALL LETTER BARRED O +0276;N # LATIN LETTER SMALL CAPITAL OE +0277;N # LATIN SMALL LETTER CLOSED OMEGA +0278;N # LATIN SMALL LETTER PHI +0279;N # LATIN SMALL LETTER TURNED R +027A;N # LATIN SMALL LETTER TURNED R WITH LONG LEG +027B;N # LATIN SMALL LETTER TURNED R WITH HOOK +027C;N # LATIN SMALL LETTER R WITH LONG LEG +027D;N # LATIN SMALL LETTER R WITH TAIL +027E;N # LATIN SMALL LETTER R WITH FISHHOOK +027F;N # LATIN SMALL LETTER REVERSED R WITH FISHHOOK +0280;N # LATIN LETTER SMALL CAPITAL R +0281;N # LATIN LETTER SMALL CAPITAL INVERTED R +0282;N # LATIN SMALL LETTER S WITH HOOK +0283;N # LATIN SMALL LETTER ESH +0284;N # LATIN SMALL LETTER DOTLESS J WITH STROKE AND HOOK +0285;N # LATIN SMALL LETTER SQUAT REVERSED ESH +0286;N # LATIN SMALL LETTER ESH WITH CURL +0287;N # LATIN SMALL LETTER TURNED T +0288;N # LATIN SMALL LETTER T WITH RETROFLEX HOOK +0289;N # LATIN SMALL LETTER U BAR +028A;N # LATIN SMALL LETTER UPSILON +028B;N # LATIN SMALL LETTER V WITH HOOK +028C;N # LATIN SMALL LETTER TURNED V +028D;N # LATIN SMALL LETTER TURNED W +028E;N # LATIN SMALL LETTER TURNED Y +028F;N # LATIN LETTER SMALL CAPITAL Y +0290;N # LATIN SMALL LETTER Z WITH RETROFLEX HOOK +0291;N # LATIN SMALL LETTER Z WITH CURL +0292;N # LATIN SMALL LETTER EZH +0293;N # LATIN SMALL LETTER EZH WITH CURL +0294;N # LATIN LETTER GLOTTAL STOP +0295;N # LATIN LETTER PHARYNGEAL VOICED FRICATIVE +0296;N # LATIN LETTER INVERTED GLOTTAL STOP +0297;N # LATIN LETTER STRETCHED C +0298;N # LATIN LETTER BILABIAL CLICK +0299;N # LATIN LETTER SMALL CAPITAL B +029A;N # LATIN SMALL LETTER CLOSED OPEN E +029B;N # LATIN LETTER SMALL CAPITAL G WITH HOOK +029C;N # LATIN LETTER SMALL CAPITAL H +029D;N # LATIN SMALL LETTER J WITH CROSSED-TAIL +029E;N # LATIN SMALL LETTER TURNED K +029F;N # LATIN LETTER SMALL CAPITAL L +02A0;N # LATIN SMALL LETTER Q WITH HOOK +02A1;N # LATIN LETTER GLOTTAL STOP WITH STROKE +02A2;N # LATIN LETTER REVERSED GLOTTAL STOP WITH STROKE +02A3;N # LATIN SMALL LETTER DZ DIGRAPH +02A4;N # LATIN SMALL LETTER DEZH DIGRAPH +02A5;N # LATIN SMALL LETTER DZ DIGRAPH WITH CURL +02A6;N # LATIN SMALL LETTER TS DIGRAPH +02A7;N # LATIN SMALL LETTER TESH DIGRAPH +02A8;N # LATIN SMALL LETTER TC DIGRAPH WITH CURL +02A9;N # LATIN SMALL LETTER FENG DIGRAPH +02AA;N # LATIN SMALL LETTER LS DIGRAPH +02AB;N # LATIN SMALL LETTER LZ DIGRAPH +02AC;N # LATIN LETTER BILABIAL PERCUSSIVE +02AD;N # LATIN LETTER BIDENTAL PERCUSSIVE +02AE;N # LATIN SMALL LETTER TURNED H WITH FISHHOOK +02AF;N # LATIN SMALL LETTER TURNED H WITH FISHHOOK AND TAIL +02B0;N # MODIFIER LETTER SMALL H +02B1;N # MODIFIER LETTER SMALL H WITH HOOK +02B2;N # MODIFIER LETTER SMALL J +02B3;N # MODIFIER LETTER SMALL R +02B4;N # MODIFIER LETTER SMALL TURNED R +02B5;N # MODIFIER LETTER SMALL TURNED R WITH HOOK +02B6;N # MODIFIER LETTER SMALL CAPITAL INVERTED R +02B7;N # MODIFIER LETTER SMALL W +02B8;N # MODIFIER LETTER SMALL Y +02B9;N # MODIFIER LETTER PRIME +02BA;N # MODIFIER LETTER DOUBLE PRIME +02BB;N # MODIFIER LETTER TURNED COMMA +02BC;N # MODIFIER LETTER APOSTROPHE +02BD;N # MODIFIER LETTER REVERSED COMMA +02BE;N # MODIFIER LETTER RIGHT HALF RING +02BF;N # MODIFIER LETTER LEFT HALF RING +02C0;N # MODIFIER LETTER GLOTTAL STOP +02C1;N # MODIFIER LETTER REVERSED GLOTTAL STOP +02C2;N # MODIFIER LETTER LEFT ARROWHEAD +02C3;N # MODIFIER LETTER RIGHT ARROWHEAD +02C4;A # MODIFIER LETTER UP ARROWHEAD +02C5;N # MODIFIER LETTER DOWN ARROWHEAD +02C6;N # MODIFIER LETTER CIRCUMFLEX ACCENT +02C7;A # CARON +02C8;N # MODIFIER LETTER VERTICAL LINE +02C9;A # MODIFIER LETTER MACRON +02CA;A # MODIFIER LETTER ACUTE ACCENT +02CB;A # MODIFIER LETTER GRAVE ACCENT +02CC;N # MODIFIER LETTER LOW VERTICAL LINE +02CD;A # MODIFIER LETTER LOW MACRON +02CE;N # MODIFIER LETTER LOW GRAVE ACCENT +02CF;N # MODIFIER LETTER LOW ACUTE ACCENT +02D0;A # MODIFIER LETTER TRIANGULAR COLON +02D1;N # MODIFIER LETTER HALF TRIANGULAR COLON +02D2;N # MODIFIER LETTER CENTRED RIGHT HALF RING +02D3;N # MODIFIER LETTER CENTRED LEFT HALF RING +02D4;N # MODIFIER LETTER UP TACK +02D5;N # MODIFIER LETTER DOWN TACK +02D6;N # MODIFIER LETTER PLUS SIGN +02D7;N # MODIFIER LETTER MINUS SIGN +02D8;A # BREVE +02D9;A # DOT ABOVE +02DA;A # RING ABOVE +02DB;A # OGONEK +02DC;N # SMALL TILDE +02DD;A # DOUBLE ACUTE ACCENT +02DE;N # MODIFIER LETTER RHOTIC HOOK +02DF;A # MODIFIER LETTER CROSS ACCENT +02E0;N # MODIFIER LETTER SMALL GAMMA +02E1;N # MODIFIER LETTER SMALL L +02E2;N # MODIFIER LETTER SMALL S +02E3;N # MODIFIER LETTER SMALL X +02E4;N # MODIFIER LETTER SMALL REVERSED GLOTTAL STOP +02E5;N # MODIFIER LETTER EXTRA-HIGH TONE BAR +02E6;N # MODIFIER LETTER HIGH TONE BAR +02E7;N # MODIFIER LETTER MID TONE BAR +02E8;N # MODIFIER LETTER LOW TONE BAR +02E9;N # MODIFIER LETTER EXTRA-LOW TONE BAR +02EA;N # MODIFIER LETTER YIN DEPARTING TONE MARK +02EB;N # MODIFIER LETTER YANG DEPARTING TONE MARK +02EC;N # MODIFIER LETTER VOICING +02ED;N # MODIFIER LETTER UNASPIRATED +02EE;N # MODIFIER LETTER DOUBLE APOSTROPHE +02EF;N # MODIFIER LETTER LOW DOWN ARROWHEAD +02F0;N # MODIFIER LETTER LOW UP ARROWHEAD +02F1;N # MODIFIER LETTER LOW LEFT ARROWHEAD +02F2;N # MODIFIER LETTER LOW RIGHT ARROWHEAD +02F3;N # MODIFIER LETTER LOW RING +02F4;N # MODIFIER LETTER MIDDLE GRAVE ACCENT +02F5;N # MODIFIER LETTER MIDDLE DOUBLE GRAVE ACCENT +02F6;N # MODIFIER LETTER MIDDLE DOUBLE ACUTE ACCENT +02F7;N # MODIFIER LETTER LOW TILDE +02F8;N # MODIFIER LETTER RAISED COLON +02F9;N # MODIFIER LETTER BEGIN HIGH TONE +02FA;N # MODIFIER LETTER END HIGH TONE +02FB;N # MODIFIER LETTER BEGIN LOW TONE +02FC;N # MODIFIER LETTER END LOW TONE +02FD;N # MODIFIER LETTER SHELF +02FE;N # MODIFIER LETTER OPEN SHELF +02FF;N # MODIFIER LETTER LOW LEFT ARROW +0300;A # COMBINING GRAVE ACCENT +0301;A # COMBINING ACUTE ACCENT +0302;A # COMBINING CIRCUMFLEX ACCENT +0303;A # COMBINING TILDE +0304;A # COMBINING MACRON +0305;A # COMBINING OVERLINE +0306;A # COMBINING BREVE +0307;A # COMBINING DOT ABOVE +0308;A # COMBINING DIAERESIS +0309;A # COMBINING HOOK ABOVE +030A;A # COMBINING RING ABOVE +030B;A # COMBINING DOUBLE ACUTE ACCENT +030C;A # COMBINING CARON +030D;A # COMBINING VERTICAL LINE ABOVE +030E;A # COMBINING DOUBLE VERTICAL LINE ABOVE +030F;A # COMBINING DOUBLE GRAVE ACCENT +0310;A # COMBINING CANDRABINDU +0311;A # COMBINING INVERTED BREVE +0312;A # COMBINING TURNED COMMA ABOVE +0313;A # COMBINING COMMA ABOVE +0314;A # COMBINING REVERSED COMMA ABOVE +0315;A # COMBINING COMMA ABOVE RIGHT +0316;A # COMBINING GRAVE ACCENT BELOW +0317;A # COMBINING ACUTE ACCENT BELOW +0318;A # COMBINING LEFT TACK BELOW +0319;A # COMBINING RIGHT TACK BELOW +031A;A # COMBINING LEFT ANGLE ABOVE +031B;A # COMBINING HORN +031C;A # COMBINING LEFT HALF RING BELOW +031D;A # COMBINING UP TACK BELOW +031E;A # COMBINING DOWN TACK BELOW +031F;A # COMBINING PLUS SIGN BELOW +0320;A # COMBINING MINUS SIGN BELOW +0321;A # COMBINING PALATALIZED HOOK BELOW +0322;A # COMBINING RETROFLEX HOOK BELOW +0323;A # COMBINING DOT BELOW +0324;A # COMBINING DIAERESIS BELOW +0325;A # COMBINING RING BELOW +0326;A # COMBINING COMMA BELOW +0327;A # COMBINING CEDILLA +0328;A # COMBINING OGONEK +0329;A # COMBINING VERTICAL LINE BELOW +032A;A # COMBINING BRIDGE BELOW +032B;A # COMBINING INVERTED DOUBLE ARCH BELOW +032C;A # COMBINING CARON BELOW +032D;A # COMBINING CIRCUMFLEX ACCENT BELOW +032E;A # COMBINING BREVE BELOW +032F;A # COMBINING INVERTED BREVE BELOW +0330;A # COMBINING TILDE BELOW +0331;A # COMBINING MACRON BELOW +0332;A # COMBINING LOW LINE +0333;A # COMBINING DOUBLE LOW LINE +0334;A # COMBINING TILDE OVERLAY +0335;A # COMBINING SHORT STROKE OVERLAY +0336;A # COMBINING LONG STROKE OVERLAY +0337;A # COMBINING SHORT SOLIDUS OVERLAY +0338;A # COMBINING LONG SOLIDUS OVERLAY +0339;A # COMBINING RIGHT HALF RING BELOW +033A;A # COMBINING INVERTED BRIDGE BELOW +033B;A # COMBINING SQUARE BELOW +033C;A # COMBINING SEAGULL BELOW +033D;A # COMBINING X ABOVE +033E;A # COMBINING VERTICAL TILDE +033F;A # COMBINING DOUBLE OVERLINE +0340;A # COMBINING GRAVE TONE MARK +0341;A # COMBINING ACUTE TONE MARK +0342;A # COMBINING GREEK PERISPOMENI +0343;A # COMBINING GREEK KORONIS +0344;A # COMBINING GREEK DIALYTIKA TONOS +0345;A # COMBINING GREEK YPOGEGRAMMENI +0346;A # COMBINING BRIDGE ABOVE +0347;A # COMBINING EQUALS SIGN BELOW +0348;A # COMBINING DOUBLE VERTICAL LINE BELOW +0349;A # COMBINING LEFT ANGLE BELOW +034A;A # COMBINING NOT TILDE ABOVE +034B;A # COMBINING HOMOTHETIC ABOVE +034C;A # COMBINING ALMOST EQUAL TO ABOVE +034D;A # COMBINING LEFT RIGHT ARROW BELOW +034E;A # COMBINING UPWARDS ARROW BELOW +034F;A # COMBINING GRAPHEME JOINER +0350;A # COMBINING RIGHT ARROWHEAD ABOVE +0351;A # COMBINING LEFT HALF RING ABOVE +0352;A # COMBINING FERMATA +0353;A # COMBINING X BELOW +0354;A # COMBINING LEFT ARROWHEAD BELOW +0355;A # COMBINING RIGHT ARROWHEAD BELOW +0356;A # COMBINING RIGHT ARROWHEAD AND UP ARROWHEAD BELOW +0357;A # COMBINING RIGHT HALF RING ABOVE +0358;A # COMBINING DOT ABOVE RIGHT +0359;A # COMBINING ASTERISK BELOW +035A;A # COMBINING DOUBLE RING BELOW +035B;A # COMBINING ZIGZAG ABOVE +035C;A # COMBINING DOUBLE BREVE BELOW +035D;A # COMBINING DOUBLE BREVE +035E;A # COMBINING DOUBLE MACRON +035F;A # COMBINING DOUBLE MACRON BELOW +0360;A # COMBINING DOUBLE TILDE +0361;A # COMBINING DOUBLE INVERTED BREVE +0362;A # COMBINING DOUBLE RIGHTWARDS ARROW BELOW +0363;A # COMBINING LATIN SMALL LETTER A +0364;A # COMBINING LATIN SMALL LETTER E +0365;A # COMBINING LATIN SMALL LETTER I +0366;A # COMBINING LATIN SMALL LETTER O +0367;A # COMBINING LATIN SMALL LETTER U +0368;A # COMBINING LATIN SMALL LETTER C +0369;A # COMBINING LATIN SMALL LETTER D +036A;A # COMBINING LATIN SMALL LETTER H +036B;A # COMBINING LATIN SMALL LETTER M +036C;A # COMBINING LATIN SMALL LETTER R +036D;A # COMBINING LATIN SMALL LETTER T +036E;A # COMBINING LATIN SMALL LETTER V +036F;A # COMBINING LATIN SMALL LETTER X +0374;N # GREEK NUMERAL SIGN +0375;N # GREEK LOWER NUMERAL SIGN +037A;N # GREEK YPOGEGRAMMENI +037E;N # GREEK QUESTION MARK +0384;N # GREEK TONOS +0385;N # GREEK DIALYTIKA TONOS +0386;N # GREEK CAPITAL LETTER ALPHA WITH TONOS +0387;N # GREEK ANO TELEIA +0388;N # GREEK CAPITAL LETTER EPSILON WITH TONOS +0389;N # GREEK CAPITAL LETTER ETA WITH TONOS +038A;N # GREEK CAPITAL LETTER IOTA WITH TONOS +038C;N # GREEK CAPITAL LETTER OMICRON WITH TONOS +038E;N # GREEK CAPITAL LETTER UPSILON WITH TONOS +038F;N # GREEK CAPITAL LETTER OMEGA WITH TONOS +0390;N # GREEK SMALL LETTER IOTA WITH DIALYTIKA AND TONOS +0391;A # GREEK CAPITAL LETTER ALPHA +0392;A # GREEK CAPITAL LETTER BETA +0393;A # GREEK CAPITAL LETTER GAMMA +0394;A # GREEK CAPITAL LETTER DELTA +0395;A # GREEK CAPITAL LETTER EPSILON +0396;A # GREEK CAPITAL LETTER ZETA +0397;A # GREEK CAPITAL LETTER ETA +0398;A # GREEK CAPITAL LETTER THETA +0399;A # GREEK CAPITAL LETTER IOTA +039A;A # GREEK CAPITAL LETTER KAPPA +039B;A # GREEK CAPITAL LETTER LAMDA +039C;A # GREEK CAPITAL LETTER MU +039D;A # GREEK CAPITAL LETTER NU +039E;A # GREEK CAPITAL LETTER XI +039F;A # GREEK CAPITAL LETTER OMICRON +03A0;A # GREEK CAPITAL LETTER PI +03A1;A # GREEK CAPITAL LETTER RHO +03A3;A # GREEK CAPITAL LETTER SIGMA +03A4;A # GREEK CAPITAL LETTER TAU +03A5;A # GREEK CAPITAL LETTER UPSILON +03A6;A # GREEK CAPITAL LETTER PHI +03A7;A # GREEK CAPITAL LETTER CHI +03A8;A # GREEK CAPITAL LETTER PSI +03A9;A # GREEK CAPITAL LETTER OMEGA +03AA;N # GREEK CAPITAL LETTER IOTA WITH DIALYTIKA +03AB;N # GREEK CAPITAL LETTER UPSILON WITH DIALYTIKA +03AC;N # GREEK SMALL LETTER ALPHA WITH TONOS +03AD;N # GREEK SMALL LETTER EPSILON WITH TONOS +03AE;N # GREEK SMALL LETTER ETA WITH TONOS +03AF;N # GREEK SMALL LETTER IOTA WITH TONOS +03B0;N # GREEK SMALL LETTER UPSILON WITH DIALYTIKA AND TONOS +03B1;A # GREEK SMALL LETTER ALPHA +03B2;A # GREEK SMALL LETTER BETA +03B3;A # GREEK SMALL LETTER GAMMA +03B4;A # GREEK SMALL LETTER DELTA +03B5;A # GREEK SMALL LETTER EPSILON +03B6;A # GREEK SMALL LETTER ZETA +03B7;A # GREEK SMALL LETTER ETA +03B8;A # GREEK SMALL LETTER THETA +03B9;A # GREEK SMALL LETTER IOTA +03BA;A # GREEK SMALL LETTER KAPPA +03BB;A # GREEK SMALL LETTER LAMDA +03BC;A # GREEK SMALL LETTER MU +03BD;A # GREEK SMALL LETTER NU +03BE;A # GREEK SMALL LETTER XI +03BF;A # GREEK SMALL LETTER OMICRON +03C0;A # GREEK SMALL LETTER PI +03C1;A # GREEK SMALL LETTER RHO +03C2;N # GREEK SMALL LETTER FINAL SIGMA +03C3;A # GREEK SMALL LETTER SIGMA +03C4;A # GREEK SMALL LETTER TAU +03C5;A # GREEK SMALL LETTER UPSILON +03C6;A # GREEK SMALL LETTER PHI +03C7;A # GREEK SMALL LETTER CHI +03C8;A # GREEK SMALL LETTER PSI +03C9;A # GREEK SMALL LETTER OMEGA +03CA;N # GREEK SMALL LETTER IOTA WITH DIALYTIKA +03CB;N # GREEK SMALL LETTER UPSILON WITH DIALYTIKA +03CC;N # GREEK SMALL LETTER OMICRON WITH TONOS +03CD;N # GREEK SMALL LETTER UPSILON WITH TONOS +03CE;N # GREEK SMALL LETTER OMEGA WITH TONOS +03D0;N # GREEK BETA SYMBOL +03D1;N # GREEK THETA SYMBOL +03D2;N # GREEK UPSILON WITH HOOK SYMBOL +03D3;N # GREEK UPSILON WITH ACUTE AND HOOK SYMBOL +03D4;N # GREEK UPSILON WITH DIAERESIS AND HOOK SYMBOL +03D5;N # GREEK PHI SYMBOL +03D6;N # GREEK PI SYMBOL +03D7;N # GREEK KAI SYMBOL +03D8;N # GREEK LETTER ARCHAIC KOPPA +03D9;N # GREEK SMALL LETTER ARCHAIC KOPPA +03DA;N # GREEK LETTER STIGMA +03DB;N # GREEK SMALL LETTER STIGMA +03DC;N # GREEK LETTER DIGAMMA +03DD;N # GREEK SMALL LETTER DIGAMMA +03DE;N # GREEK LETTER KOPPA +03DF;N # GREEK SMALL LETTER KOPPA +03E0;N # GREEK LETTER SAMPI +03E1;N # GREEK SMALL LETTER SAMPI +03E2;N # COPTIC CAPITAL LETTER SHEI +03E3;N # COPTIC SMALL LETTER SHEI +03E4;N # COPTIC CAPITAL LETTER FEI +03E5;N # COPTIC SMALL LETTER FEI +03E6;N # COPTIC CAPITAL LETTER KHEI +03E7;N # COPTIC SMALL LETTER KHEI +03E8;N # COPTIC CAPITAL LETTER HORI +03E9;N # COPTIC SMALL LETTER HORI +03EA;N # COPTIC CAPITAL LETTER GANGIA +03EB;N # COPTIC SMALL LETTER GANGIA +03EC;N # COPTIC CAPITAL LETTER SHIMA +03ED;N # COPTIC SMALL LETTER SHIMA +03EE;N # COPTIC CAPITAL LETTER DEI +03EF;N # COPTIC SMALL LETTER DEI +03F0;N # GREEK KAPPA SYMBOL +03F1;N # GREEK RHO SYMBOL +03F2;N # GREEK LUNATE SIGMA SYMBOL +03F3;N # GREEK LETTER YOT +03F4;N # GREEK CAPITAL THETA SYMBOL +03F5;N # GREEK LUNATE EPSILON SYMBOL +03F6;N # GREEK REVERSED LUNATE EPSILON SYMBOL +03F7;N # GREEK CAPITAL LETTER SHO +03F8;N # GREEK SMALL LETTER SHO +03F9;N # GREEK CAPITAL LUNATE SIGMA SYMBOL +03FA;N # GREEK CAPITAL LETTER SAN +03FB;N # GREEK SMALL LETTER SAN +03FC;N # GREEK RHO WITH STROKE SYMBOL +03FD;N # GREEK CAPITAL REVERSED LUNATE SIGMA SYMBOL +03FE;N # GREEK CAPITAL DOTTED LUNATE SIGMA SYMBOL +03FF;N # GREEK CAPITAL REVERSED DOTTED LUNATE SIGMA SYMBOL +0400;N # CYRILLIC CAPITAL LETTER IE WITH GRAVE +0401;A # CYRILLIC CAPITAL LETTER IO +0402;N # CYRILLIC CAPITAL LETTER DJE +0403;N # CYRILLIC CAPITAL LETTER GJE +0404;N # CYRILLIC CAPITAL LETTER UKRAINIAN IE +0405;N # CYRILLIC CAPITAL LETTER DZE +0406;N # CYRILLIC CAPITAL LETTER BYELORUSSIAN-UKRAINIAN I +0407;N # CYRILLIC CAPITAL LETTER YI +0408;N # CYRILLIC CAPITAL LETTER JE +0409;N # CYRILLIC CAPITAL LETTER LJE +040A;N # CYRILLIC CAPITAL LETTER NJE +040B;N # CYRILLIC CAPITAL LETTER TSHE +040C;N # CYRILLIC CAPITAL LETTER KJE +040D;N # CYRILLIC CAPITAL LETTER I WITH GRAVE +040E;N # CYRILLIC CAPITAL LETTER SHORT U +040F;N # CYRILLIC CAPITAL LETTER DZHE +0410;A # CYRILLIC CAPITAL LETTER A +0411;A # CYRILLIC CAPITAL LETTER BE +0412;A # CYRILLIC CAPITAL LETTER VE +0413;A # CYRILLIC CAPITAL LETTER GHE +0414;A # CYRILLIC CAPITAL LETTER DE +0415;A # CYRILLIC CAPITAL LETTER IE +0416;A # CYRILLIC CAPITAL LETTER ZHE +0417;A # CYRILLIC CAPITAL LETTER ZE +0418;A # CYRILLIC CAPITAL LETTER I +0419;A # CYRILLIC CAPITAL LETTER SHORT I +041A;A # CYRILLIC CAPITAL LETTER KA +041B;A # CYRILLIC CAPITAL LETTER EL +041C;A # CYRILLIC CAPITAL LETTER EM +041D;A # CYRILLIC CAPITAL LETTER EN +041E;A # CYRILLIC CAPITAL LETTER O +041F;A # CYRILLIC CAPITAL LETTER PE +0420;A # CYRILLIC CAPITAL LETTER ER +0421;A # CYRILLIC CAPITAL LETTER ES +0422;A # CYRILLIC CAPITAL LETTER TE +0423;A # CYRILLIC CAPITAL LETTER U +0424;A # CYRILLIC CAPITAL LETTER EF +0425;A # CYRILLIC CAPITAL LETTER HA +0426;A # CYRILLIC CAPITAL LETTER TSE +0427;A # CYRILLIC CAPITAL LETTER CHE +0428;A # CYRILLIC CAPITAL LETTER SHA +0429;A # CYRILLIC CAPITAL LETTER SHCHA +042A;A # CYRILLIC CAPITAL LETTER HARD SIGN +042B;A # CYRILLIC CAPITAL LETTER YERU +042C;A # CYRILLIC CAPITAL LETTER SOFT SIGN +042D;A # CYRILLIC CAPITAL LETTER E +042E;A # CYRILLIC CAPITAL LETTER YU +042F;A # CYRILLIC CAPITAL LETTER YA +0430;A # CYRILLIC SMALL LETTER A +0431;A # CYRILLIC SMALL LETTER BE +0432;A # CYRILLIC SMALL LETTER VE +0433;A # CYRILLIC SMALL LETTER GHE +0434;A # CYRILLIC SMALL LETTER DE +0435;A # CYRILLIC SMALL LETTER IE +0436;A # CYRILLIC SMALL LETTER ZHE +0437;A # CYRILLIC SMALL LETTER ZE +0438;A # CYRILLIC SMALL LETTER I +0439;A # CYRILLIC SMALL LETTER SHORT I +043A;A # CYRILLIC SMALL LETTER KA +043B;A # CYRILLIC SMALL LETTER EL +043C;A # CYRILLIC SMALL LETTER EM +043D;A # CYRILLIC SMALL LETTER EN +043E;A # CYRILLIC SMALL LETTER O +043F;A # CYRILLIC SMALL LETTER PE +0440;A # CYRILLIC SMALL LETTER ER +0441;A # CYRILLIC SMALL LETTER ES +0442;A # CYRILLIC SMALL LETTER TE +0443;A # CYRILLIC SMALL LETTER U +0444;A # CYRILLIC SMALL LETTER EF +0445;A # CYRILLIC SMALL LETTER HA +0446;A # CYRILLIC SMALL LETTER TSE +0447;A # CYRILLIC SMALL LETTER CHE +0448;A # CYRILLIC SMALL LETTER SHA +0449;A # CYRILLIC SMALL LETTER SHCHA +044A;A # CYRILLIC SMALL LETTER HARD SIGN +044B;A # CYRILLIC SMALL LETTER YERU +044C;A # CYRILLIC SMALL LETTER SOFT SIGN +044D;A # CYRILLIC SMALL LETTER E +044E;A # CYRILLIC SMALL LETTER YU +044F;A # CYRILLIC SMALL LETTER YA +0450;N # CYRILLIC SMALL LETTER IE WITH GRAVE +0451;A # CYRILLIC SMALL LETTER IO +0452;N # CYRILLIC SMALL LETTER DJE +0453;N # CYRILLIC SMALL LETTER GJE +0454;N # CYRILLIC SMALL LETTER UKRAINIAN IE +0455;N # CYRILLIC SMALL LETTER DZE +0456;N # CYRILLIC SMALL LETTER BYELORUSSIAN-UKRAINIAN I +0457;N # CYRILLIC SMALL LETTER YI +0458;N # CYRILLIC SMALL LETTER JE +0459;N # CYRILLIC SMALL LETTER LJE +045A;N # CYRILLIC SMALL LETTER NJE +045B;N # CYRILLIC SMALL LETTER TSHE +045C;N # CYRILLIC SMALL LETTER KJE +045D;N # CYRILLIC SMALL LETTER I WITH GRAVE +045E;N # CYRILLIC SMALL LETTER SHORT U +045F;N # CYRILLIC SMALL LETTER DZHE +0460;N # CYRILLIC CAPITAL LETTER OMEGA +0461;N # CYRILLIC SMALL LETTER OMEGA +0462;N # CYRILLIC CAPITAL LETTER YAT +0463;N # CYRILLIC SMALL LETTER YAT +0464;N # CYRILLIC CAPITAL LETTER IOTIFIED E +0465;N # CYRILLIC SMALL LETTER IOTIFIED E +0466;N # CYRILLIC CAPITAL LETTER LITTLE YUS +0467;N # CYRILLIC SMALL LETTER LITTLE YUS +0468;N # CYRILLIC CAPITAL LETTER IOTIFIED LITTLE YUS +0469;N # CYRILLIC SMALL LETTER IOTIFIED LITTLE YUS +046A;N # CYRILLIC CAPITAL LETTER BIG YUS +046B;N # CYRILLIC SMALL LETTER BIG YUS +046C;N # CYRILLIC CAPITAL LETTER IOTIFIED BIG YUS +046D;N # CYRILLIC SMALL LETTER IOTIFIED BIG YUS +046E;N # CYRILLIC CAPITAL LETTER KSI +046F;N # CYRILLIC SMALL LETTER KSI +0470;N # CYRILLIC CAPITAL LETTER PSI +0471;N # CYRILLIC SMALL LETTER PSI +0472;N # CYRILLIC CAPITAL LETTER FITA +0473;N # CYRILLIC SMALL LETTER FITA +0474;N # CYRILLIC CAPITAL LETTER IZHITSA +0475;N # CYRILLIC SMALL LETTER IZHITSA +0476;N # CYRILLIC CAPITAL LETTER IZHITSA WITH DOUBLE GRAVE ACCENT +0477;N # CYRILLIC SMALL LETTER IZHITSA WITH DOUBLE GRAVE ACCENT +0478;N # CYRILLIC CAPITAL LETTER UK +0479;N # CYRILLIC SMALL LETTER UK +047A;N # CYRILLIC CAPITAL LETTER ROUND OMEGA +047B;N # CYRILLIC SMALL LETTER ROUND OMEGA +047C;N # CYRILLIC CAPITAL LETTER OMEGA WITH TITLO +047D;N # CYRILLIC SMALL LETTER OMEGA WITH TITLO +047E;N # CYRILLIC CAPITAL LETTER OT +047F;N # CYRILLIC SMALL LETTER OT +0480;N # CYRILLIC CAPITAL LETTER KOPPA +0481;N # CYRILLIC SMALL LETTER KOPPA +0482;N # CYRILLIC THOUSANDS SIGN +0483;N # COMBINING CYRILLIC TITLO +0484;N # COMBINING CYRILLIC PALATALIZATION +0485;N # COMBINING CYRILLIC DASIA PNEUMATA +0486;N # COMBINING CYRILLIC PSILI PNEUMATA +0488;N # COMBINING CYRILLIC HUNDRED THOUSANDS SIGN +0489;N # COMBINING CYRILLIC MILLIONS SIGN +048A;N # CYRILLIC CAPITAL LETTER SHORT I WITH TAIL +048B;N # CYRILLIC SMALL LETTER SHORT I WITH TAIL +048C;N # CYRILLIC CAPITAL LETTER SEMISOFT SIGN +048D;N # CYRILLIC SMALL LETTER SEMISOFT SIGN +048E;N # CYRILLIC CAPITAL LETTER ER WITH TICK +048F;N # CYRILLIC SMALL LETTER ER WITH TICK +0490;N # CYRILLIC CAPITAL LETTER GHE WITH UPTURN +0491;N # CYRILLIC SMALL LETTER GHE WITH UPTURN +0492;N # CYRILLIC CAPITAL LETTER GHE WITH STROKE +0493;N # CYRILLIC SMALL LETTER GHE WITH STROKE +0494;N # CYRILLIC CAPITAL LETTER GHE WITH MIDDLE HOOK +0495;N # CYRILLIC SMALL LETTER GHE WITH MIDDLE HOOK +0496;N # CYRILLIC CAPITAL LETTER ZHE WITH DESCENDER +0497;N # CYRILLIC SMALL LETTER ZHE WITH DESCENDER +0498;N # CYRILLIC CAPITAL LETTER ZE WITH DESCENDER +0499;N # CYRILLIC SMALL LETTER ZE WITH DESCENDER +049A;N # CYRILLIC CAPITAL LETTER KA WITH DESCENDER +049B;N # CYRILLIC SMALL LETTER KA WITH DESCENDER +049C;N # CYRILLIC CAPITAL LETTER KA WITH VERTICAL STROKE +049D;N # CYRILLIC SMALL LETTER KA WITH VERTICAL STROKE +049E;N # CYRILLIC CAPITAL LETTER KA WITH STROKE +049F;N # CYRILLIC SMALL LETTER KA WITH STROKE +04A0;N # CYRILLIC CAPITAL LETTER BASHKIR KA +04A1;N # CYRILLIC SMALL LETTER BASHKIR KA +04A2;N # CYRILLIC CAPITAL LETTER EN WITH DESCENDER +04A3;N # CYRILLIC SMALL LETTER EN WITH DESCENDER +04A4;N # CYRILLIC CAPITAL LIGATURE EN GHE +04A5;N # CYRILLIC SMALL LIGATURE EN GHE +04A6;N # CYRILLIC CAPITAL LETTER PE WITH MIDDLE HOOK +04A7;N # CYRILLIC SMALL LETTER PE WITH MIDDLE HOOK +04A8;N # CYRILLIC CAPITAL LETTER ABKHASIAN HA +04A9;N # CYRILLIC SMALL LETTER ABKHASIAN HA +04AA;N # CYRILLIC CAPITAL LETTER ES WITH DESCENDER +04AB;N # CYRILLIC SMALL LETTER ES WITH DESCENDER +04AC;N # CYRILLIC CAPITAL LETTER TE WITH DESCENDER +04AD;N # CYRILLIC SMALL LETTER TE WITH DESCENDER +04AE;N # CYRILLIC CAPITAL LETTER STRAIGHT U +04AF;N # CYRILLIC SMALL LETTER STRAIGHT U +04B0;N # CYRILLIC CAPITAL LETTER STRAIGHT U WITH STROKE +04B1;N # CYRILLIC SMALL LETTER STRAIGHT U WITH STROKE +04B2;N # CYRILLIC CAPITAL LETTER HA WITH DESCENDER +04B3;N # CYRILLIC SMALL LETTER HA WITH DESCENDER +04B4;N # CYRILLIC CAPITAL LIGATURE TE TSE +04B5;N # CYRILLIC SMALL LIGATURE TE TSE +04B6;N # CYRILLIC CAPITAL LETTER CHE WITH DESCENDER +04B7;N # CYRILLIC SMALL LETTER CHE WITH DESCENDER +04B8;N # CYRILLIC CAPITAL LETTER CHE WITH VERTICAL STROKE +04B9;N # CYRILLIC SMALL LETTER CHE WITH VERTICAL STROKE +04BA;N # CYRILLIC CAPITAL LETTER SHHA +04BB;N # CYRILLIC SMALL LETTER SHHA +04BC;N # CYRILLIC CAPITAL LETTER ABKHASIAN CHE +04BD;N # CYRILLIC SMALL LETTER ABKHASIAN CHE +04BE;N # CYRILLIC CAPITAL LETTER ABKHASIAN CHE WITH DESCENDER +04BF;N # CYRILLIC SMALL LETTER ABKHASIAN CHE WITH DESCENDER +04C0;N # CYRILLIC LETTER PALOCHKA +04C1;N # CYRILLIC CAPITAL LETTER ZHE WITH BREVE +04C2;N # CYRILLIC SMALL LETTER ZHE WITH BREVE +04C3;N # CYRILLIC CAPITAL LETTER KA WITH HOOK +04C4;N # CYRILLIC SMALL LETTER KA WITH HOOK +04C5;N # CYRILLIC CAPITAL LETTER EL WITH TAIL +04C6;N # CYRILLIC SMALL LETTER EL WITH TAIL +04C7;N # CYRILLIC CAPITAL LETTER EN WITH HOOK +04C8;N # CYRILLIC SMALL LETTER EN WITH HOOK +04C9;N # CYRILLIC CAPITAL LETTER EN WITH TAIL +04CA;N # CYRILLIC SMALL LETTER EN WITH TAIL +04CB;N # CYRILLIC CAPITAL LETTER KHAKASSIAN CHE +04CC;N # CYRILLIC SMALL LETTER KHAKASSIAN CHE +04CD;N # CYRILLIC CAPITAL LETTER EM WITH TAIL +04CE;N # CYRILLIC SMALL LETTER EM WITH TAIL +04D0;N # CYRILLIC CAPITAL LETTER A WITH BREVE +04D1;N # CYRILLIC SMALL LETTER A WITH BREVE +04D2;N # CYRILLIC CAPITAL LETTER A WITH DIAERESIS +04D3;N # CYRILLIC SMALL LETTER A WITH DIAERESIS +04D4;N # CYRILLIC CAPITAL LIGATURE A IE +04D5;N # CYRILLIC SMALL LIGATURE A IE +04D6;N # CYRILLIC CAPITAL LETTER IE WITH BREVE +04D7;N # CYRILLIC SMALL LETTER IE WITH BREVE +04D8;N # CYRILLIC CAPITAL LETTER SCHWA +04D9;N # CYRILLIC SMALL LETTER SCHWA +04DA;N # CYRILLIC CAPITAL LETTER SCHWA WITH DIAERESIS +04DB;N # CYRILLIC SMALL LETTER SCHWA WITH DIAERESIS +04DC;N # CYRILLIC CAPITAL LETTER ZHE WITH DIAERESIS +04DD;N # CYRILLIC SMALL LETTER ZHE WITH DIAERESIS +04DE;N # CYRILLIC CAPITAL LETTER ZE WITH DIAERESIS +04DF;N # CYRILLIC SMALL LETTER ZE WITH DIAERESIS +04E0;N # CYRILLIC CAPITAL LETTER ABKHASIAN DZE +04E1;N # CYRILLIC SMALL LETTER ABKHASIAN DZE +04E2;N # CYRILLIC CAPITAL LETTER I WITH MACRON +04E3;N # CYRILLIC SMALL LETTER I WITH MACRON +04E4;N # CYRILLIC CAPITAL LETTER I WITH DIAERESIS +04E5;N # CYRILLIC SMALL LETTER I WITH DIAERESIS +04E6;N # CYRILLIC CAPITAL LETTER O WITH DIAERESIS +04E7;N # CYRILLIC SMALL LETTER O WITH DIAERESIS +04E8;N # CYRILLIC CAPITAL LETTER BARRED O +04E9;N # CYRILLIC SMALL LETTER BARRED O +04EA;N # CYRILLIC CAPITAL LETTER BARRED O WITH DIAERESIS +04EB;N # CYRILLIC SMALL LETTER BARRED O WITH DIAERESIS +04EC;N # CYRILLIC CAPITAL LETTER E WITH DIAERESIS +04ED;N # CYRILLIC SMALL LETTER E WITH DIAERESIS +04EE;N # CYRILLIC CAPITAL LETTER U WITH MACRON +04EF;N # CYRILLIC SMALL LETTER U WITH MACRON +04F0;N # CYRILLIC CAPITAL LETTER U WITH DIAERESIS +04F1;N # CYRILLIC SMALL LETTER U WITH DIAERESIS +04F2;N # CYRILLIC CAPITAL LETTER U WITH DOUBLE ACUTE +04F3;N # CYRILLIC SMALL LETTER U WITH DOUBLE ACUTE +04F4;N # CYRILLIC CAPITAL LETTER CHE WITH DIAERESIS +04F5;N # CYRILLIC SMALL LETTER CHE WITH DIAERESIS +04F6;N # CYRILLIC CAPITAL LETTER GHE WITH DESCENDER +04F7;N # CYRILLIC SMALL LETTER GHE WITH DESCENDER +04F8;N # CYRILLIC CAPITAL LETTER YERU WITH DIAERESIS +04F9;N # CYRILLIC SMALL LETTER YERU WITH DIAERESIS +0500;N # CYRILLIC CAPITAL LETTER KOMI DE +0501;N # CYRILLIC SMALL LETTER KOMI DE +0502;N # CYRILLIC CAPITAL LETTER KOMI DJE +0503;N # CYRILLIC SMALL LETTER KOMI DJE +0504;N # CYRILLIC CAPITAL LETTER KOMI ZJE +0505;N # CYRILLIC SMALL LETTER KOMI ZJE +0506;N # CYRILLIC CAPITAL LETTER KOMI DZJE +0507;N # CYRILLIC SMALL LETTER KOMI DZJE +0508;N # CYRILLIC CAPITAL LETTER KOMI LJE +0509;N # CYRILLIC SMALL LETTER KOMI LJE +050A;N # CYRILLIC CAPITAL LETTER KOMI NJE +050B;N # CYRILLIC SMALL LETTER KOMI NJE +050C;N # CYRILLIC CAPITAL LETTER KOMI SJE +050D;N # CYRILLIC SMALL LETTER KOMI SJE +050E;N # CYRILLIC CAPITAL LETTER KOMI TJE +050F;N # CYRILLIC SMALL LETTER KOMI TJE +0531;N # ARMENIAN CAPITAL LETTER AYB +0532;N # ARMENIAN CAPITAL LETTER BEN +0533;N # ARMENIAN CAPITAL LETTER GIM +0534;N # ARMENIAN CAPITAL LETTER DA +0535;N # ARMENIAN CAPITAL LETTER ECH +0536;N # ARMENIAN CAPITAL LETTER ZA +0537;N # ARMENIAN CAPITAL LETTER EH +0538;N # ARMENIAN CAPITAL LETTER ET +0539;N # ARMENIAN CAPITAL LETTER TO +053A;N # ARMENIAN CAPITAL LETTER ZHE +053B;N # ARMENIAN CAPITAL LETTER INI +053C;N # ARMENIAN CAPITAL LETTER LIWN +053D;N # ARMENIAN CAPITAL LETTER XEH +053E;N # ARMENIAN CAPITAL LETTER CA +053F;N # ARMENIAN CAPITAL LETTER KEN +0540;N # ARMENIAN CAPITAL LETTER HO +0541;N # ARMENIAN CAPITAL LETTER JA +0542;N # ARMENIAN CAPITAL LETTER GHAD +0543;N # ARMENIAN CAPITAL LETTER CHEH +0544;N # ARMENIAN CAPITAL LETTER MEN +0545;N # ARMENIAN CAPITAL LETTER YI +0546;N # ARMENIAN CAPITAL LETTER NOW +0547;N # ARMENIAN CAPITAL LETTER SHA +0548;N # ARMENIAN CAPITAL LETTER VO +0549;N # ARMENIAN CAPITAL LETTER CHA +054A;N # ARMENIAN CAPITAL LETTER PEH +054B;N # ARMENIAN CAPITAL LETTER JHEH +054C;N # ARMENIAN CAPITAL LETTER RA +054D;N # ARMENIAN CAPITAL LETTER SEH +054E;N # ARMENIAN CAPITAL LETTER VEW +054F;N # ARMENIAN CAPITAL LETTER TIWN +0550;N # ARMENIAN CAPITAL LETTER REH +0551;N # ARMENIAN CAPITAL LETTER CO +0552;N # ARMENIAN CAPITAL LETTER YIWN +0553;N # ARMENIAN CAPITAL LETTER PIWR +0554;N # ARMENIAN CAPITAL LETTER KEH +0555;N # ARMENIAN CAPITAL LETTER OH +0556;N # ARMENIAN CAPITAL LETTER FEH +0559;N # ARMENIAN MODIFIER LETTER LEFT HALF RING +055A;N # ARMENIAN APOSTROPHE +055B;N # ARMENIAN EMPHASIS MARK +055C;N # ARMENIAN EXCLAMATION MARK +055D;N # ARMENIAN COMMA +055E;N # ARMENIAN QUESTION MARK +055F;N # ARMENIAN ABBREVIATION MARK +0561;N # ARMENIAN SMALL LETTER AYB +0562;N # ARMENIAN SMALL LETTER BEN +0563;N # ARMENIAN SMALL LETTER GIM +0564;N # ARMENIAN SMALL LETTER DA +0565;N # ARMENIAN SMALL LETTER ECH +0566;N # ARMENIAN SMALL LETTER ZA +0567;N # ARMENIAN SMALL LETTER EH +0568;N # ARMENIAN SMALL LETTER ET +0569;N # ARMENIAN SMALL LETTER TO +056A;N # ARMENIAN SMALL LETTER ZHE +056B;N # ARMENIAN SMALL LETTER INI +056C;N # ARMENIAN SMALL LETTER LIWN +056D;N # ARMENIAN SMALL LETTER XEH +056E;N # ARMENIAN SMALL LETTER CA +056F;N # ARMENIAN SMALL LETTER KEN +0570;N # ARMENIAN SMALL LETTER HO +0571;N # ARMENIAN SMALL LETTER JA +0572;N # ARMENIAN SMALL LETTER GHAD +0573;N # ARMENIAN SMALL LETTER CHEH +0574;N # ARMENIAN SMALL LETTER MEN +0575;N # ARMENIAN SMALL LETTER YI +0576;N # ARMENIAN SMALL LETTER NOW +0577;N # ARMENIAN SMALL LETTER SHA +0578;N # ARMENIAN SMALL LETTER VO +0579;N # ARMENIAN SMALL LETTER CHA +057A;N # ARMENIAN SMALL LETTER PEH +057B;N # ARMENIAN SMALL LETTER JHEH +057C;N # ARMENIAN SMALL LETTER RA +057D;N # ARMENIAN SMALL LETTER SEH +057E;N # ARMENIAN SMALL LETTER VEW +057F;N # ARMENIAN SMALL LETTER TIWN +0580;N # ARMENIAN SMALL LETTER REH +0581;N # ARMENIAN SMALL LETTER CO +0582;N # ARMENIAN SMALL LETTER YIWN +0583;N # ARMENIAN SMALL LETTER PIWR +0584;N # ARMENIAN SMALL LETTER KEH +0585;N # ARMENIAN SMALL LETTER OH +0586;N # ARMENIAN SMALL LETTER FEH +0587;N # ARMENIAN SMALL LIGATURE ECH YIWN +0589;N # ARMENIAN FULL STOP +058A;N # ARMENIAN HYPHEN +0591;N # HEBREW ACCENT ETNAHTA +0592;N # HEBREW ACCENT SEGOL +0593;N # HEBREW ACCENT SHALSHELET +0594;N # HEBREW ACCENT ZAQEF QATAN +0595;N # HEBREW ACCENT ZAQEF GADOL +0596;N # HEBREW ACCENT TIPEHA +0597;N # HEBREW ACCENT REVIA +0598;N # HEBREW ACCENT ZARQA +0599;N # HEBREW ACCENT PASHTA +059A;N # HEBREW ACCENT YETIV +059B;N # HEBREW ACCENT TEVIR +059C;N # HEBREW ACCENT GERESH +059D;N # HEBREW ACCENT GERESH MUQDAM +059E;N # HEBREW ACCENT GERSHAYIM +059F;N # HEBREW ACCENT QARNEY PARA +05A0;N # HEBREW ACCENT TELISHA GEDOLA +05A1;N # HEBREW ACCENT PAZER +05A2;N # HEBREW ACCENT ATNAH HAFUKH +05A3;N # HEBREW ACCENT MUNAH +05A4;N # HEBREW ACCENT MAHAPAKH +05A5;N # HEBREW ACCENT MERKHA +05A6;N # HEBREW ACCENT MERKHA KEFULA +05A7;N # HEBREW ACCENT DARGA +05A8;N # HEBREW ACCENT QADMA +05A9;N # HEBREW ACCENT TELISHA QETANA +05AA;N # HEBREW ACCENT YERAH BEN YOMO +05AB;N # HEBREW ACCENT OLE +05AC;N # HEBREW ACCENT ILUY +05AD;N # HEBREW ACCENT DEHI +05AE;N # HEBREW ACCENT ZINOR +05AF;N # HEBREW MARK MASORA CIRCLE +05B0;N # HEBREW POINT SHEVA +05B1;N # HEBREW POINT HATAF SEGOL +05B2;N # HEBREW POINT HATAF PATAH +05B3;N # HEBREW POINT HATAF QAMATS +05B4;N # HEBREW POINT HIRIQ +05B5;N # HEBREW POINT TSERE +05B6;N # HEBREW POINT SEGOL +05B7;N # HEBREW POINT PATAH +05B8;N # HEBREW POINT QAMATS +05B9;N # HEBREW POINT HOLAM +05BB;N # HEBREW POINT QUBUTS +05BC;N # HEBREW POINT DAGESH OR MAPIQ +05BD;N # HEBREW POINT METEG +05BE;N # HEBREW PUNCTUATION MAQAF +05BF;N # HEBREW POINT RAFE +05C0;N # HEBREW PUNCTUATION PASEQ +05C1;N # HEBREW POINT SHIN DOT +05C2;N # HEBREW POINT SIN DOT +05C3;N # HEBREW PUNCTUATION SOF PASUQ +05C4;N # HEBREW MARK UPPER DOT +05C5;N # HEBREW MARK LOWER DOT +05C6;N # HEBREW PUNCTUATION NUN HAFUKHA +05C7;N # HEBREW POINT QAMATS QATAN +05D0;N # HEBREW LETTER ALEF +05D1;N # HEBREW LETTER BET +05D2;N # HEBREW LETTER GIMEL +05D3;N # HEBREW LETTER DALET +05D4;N # HEBREW LETTER HE +05D5;N # HEBREW LETTER VAV +05D6;N # HEBREW LETTER ZAYIN +05D7;N # HEBREW LETTER HET +05D8;N # HEBREW LETTER TET +05D9;N # HEBREW LETTER YOD +05DA;N # HEBREW LETTER FINAL KAF +05DB;N # HEBREW LETTER KAF +05DC;N # HEBREW LETTER LAMED +05DD;N # HEBREW LETTER FINAL MEM +05DE;N # HEBREW LETTER MEM +05DF;N # HEBREW LETTER FINAL NUN +05E0;N # HEBREW LETTER NUN +05E1;N # HEBREW LETTER SAMEKH +05E2;N # HEBREW LETTER AYIN +05E3;N # HEBREW LETTER FINAL PE +05E4;N # HEBREW LETTER PE +05E5;N # HEBREW LETTER FINAL TSADI +05E6;N # HEBREW LETTER TSADI +05E7;N # HEBREW LETTER QOF +05E8;N # HEBREW LETTER RESH +05E9;N # HEBREW LETTER SHIN +05EA;N # HEBREW LETTER TAV +05F0;N # HEBREW LIGATURE YIDDISH DOUBLE VAV +05F1;N # HEBREW LIGATURE YIDDISH VAV YOD +05F2;N # HEBREW LIGATURE YIDDISH DOUBLE YOD +05F3;N # HEBREW PUNCTUATION GERESH +05F4;N # HEBREW PUNCTUATION GERSHAYIM +0600;N # ARABIC NUMBER SIGN +0601;N # ARABIC SIGN SANAH +0602;N # ARABIC FOOTNOTE MARKER +0603;N # ARABIC SIGN SAFHA +060B;N # AFGHANI SIGN +060C;N # ARABIC COMMA +060D;N # ARABIC DATE SEPARATOR +060E;N # ARABIC POETIC VERSE SIGN +060F;N # ARABIC SIGN MISRA +0610;N # ARABIC SIGN SALLALLAHOU ALAYHE WASSALLAM +0611;N # ARABIC SIGN ALAYHE ASSALLAM +0612;N # ARABIC SIGN RAHMATULLAH ALAYHE +0613;N # ARABIC SIGN RADI ALLAHOU ANHU +0614;N # ARABIC SIGN TAKHALLUS +0615;N # ARABIC SMALL HIGH TAH +061B;N # ARABIC SEMICOLON +061E;N # ARABIC TRIPLE DOT PUNCTUATION MARK +061F;N # ARABIC QUESTION MARK +0621;N # ARABIC LETTER HAMZA +0622;N # ARABIC LETTER ALEF WITH ... [truncated message content] |
From: <fwi...@us...> - 2008-08-31 00:31:38
|
Revision: 5275 http://jython.svn.sourceforge.net/jython/?rev=5275&view=rev Author: fwierzbicki Date: 2008-08-31 00:31:36 +0000 (Sun, 31 Aug 2008) Log Message: ----------- Fixes #1116 -- dotted_attr was calling itself, which does not make sense with +=. 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 2008-08-30 18:39:59 UTC (rev 5274) +++ trunk/jython/grammar/Python.g 2008-08-31 00:31:36 UTC (rev 5275) @@ -309,8 +309,8 @@ //not in CPython's Grammar file dotted_attr returns [exprType etype] : n1=NAME - ( (DOT n2+=dotted_attr)+ { $etype = actions.makeDottedAttr($n1, $n2); } - | { $etype = new Name($NAME, $NAME.text, expr_contextType.Load); } + ( (DOT n2+=NAME)+ { $etype = actions.makeDottedAttr($n1, $n2); } + | { $etype = new Name($n1, $n1.text, expr_contextType.Load); } ) ; Modified: trunk/jython/src/org/python/antlr/GrammarActions.java =================================================================== --- trunk/jython/src/org/python/antlr/GrammarActions.java 2008-08-30 18:39:59 UTC (rev 5274) +++ trunk/jython/src/org/python/antlr/GrammarActions.java 2008-08-31 00:31:36 UTC (rev 5275) @@ -212,8 +212,8 @@ exprType makeDottedAttr(Token nameToken, List attrs) { exprType current = new Name(nameToken, nameToken.getText(), expr_contextType.Load); - for (int i=attrs.size() - 1; i > -1; i--) { - Token t = ((PythonTree)attrs.get(i)).token; + for (Object o: attrs) { + Token t = (Token)o; current = new Attribute(t, current, t.getText(), expr_contextType.Load); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2008-09-01 04:21:35
|
Revision: 5278 http://jython.svn.sourceforge.net/jython/?rev=5278&view=rev Author: fwierzbicki Date: 2008-09-01 04:21:27 +0000 (Mon, 01 Sep 2008) Log Message: ----------- Check for EOF in file_input. Comment cleanup. Modified Paths: -------------- trunk/jython/grammar/Python.g trunk/jython/src/org/python/antlr/PythonTokenSource.java Modified: trunk/jython/grammar/Python.g =================================================================== --- trunk/jython/grammar/Python.g 2008-09-01 04:03:21 UTC (rev 5277) +++ trunk/jython/grammar/Python.g 2008-09-01 04:21:27 UTC (rev 5278) @@ -288,7 +288,7 @@ } : (NEWLINE | stmt {stypes.addAll($stmt.stypes);} - )* { + )* EOF { mtype = new Module($file_input.start, actions.makeStmts(stypes)); } ; Modified: trunk/jython/src/org/python/antlr/PythonTokenSource.java =================================================================== --- trunk/jython/src/org/python/antlr/PythonTokenSource.java 2008-09-01 04:03:21 UTC (rev 5277) +++ trunk/jython/src/org/python/antlr/PythonTokenSource.java 2008-09-01 04:21:27 UTC (rev 5278) @@ -324,7 +324,6 @@ return buf.toString(); } - //FIXME: needed this for the Antlr 3.1b interface change. public String getSourceName() { return filename; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2008-09-04 16:57:33
|
Revision: 5288 http://jython.svn.sourceforge.net/jython/?rev=5288&view=rev Author: fwierzbicki Date: 2008-09-04 16:57:30 +0000 (Thu, 04 Sep 2008) Log Message: ----------- Fix for some offset problems -- the biggest one being dedents now take on the offset values of the previous token. Modified Paths: -------------- trunk/jython/grammar/Python.g trunk/jython/src/org/python/antlr/PythonTokenSource.java trunk/jython/src/org/python/antlr/PythonTreeAdaptor.java Modified: trunk/jython/grammar/Python.g =================================================================== --- trunk/jython/grammar/Python.g 2008-09-03 15:24:20 UTC (rev 5287) +++ trunk/jython/grammar/Python.g 2008-09-04 16:57:30 UTC (rev 5288) @@ -284,6 +284,12 @@ List stypes = new ArrayList(); } @after { + if (!stypes.isEmpty()) { + //The EOF token messes up the end offsets, so set them manually. + PythonTree stop = (PythonTree)stypes.get(stypes.size() -1); + mtype.setCharStopIndex(stop.getCharStopIndex()); + mtype.setTokenStopIndex(stop.getTokenStopIndex()); + } $file_input.tree = mtype; } : (NEWLINE Modified: trunk/jython/src/org/python/antlr/PythonTokenSource.java =================================================================== --- trunk/jython/src/org/python/antlr/PythonTokenSource.java 2008-09-03 15:24:20 UTC (rev 5287) +++ trunk/jython/src/org/python/antlr/PythonTokenSource.java 2008-09-04 16:57:30 UTC (rev 5288) @@ -157,14 +157,18 @@ stream.consume(); if (t.getType() == Token.EOF) { + Token prev = stream.LT(-1); if (!inSingle) { - Token prev = stream.LT(-1); if (prev == null || prev.getType() != PythonLexer.NEWLINE) { generateNewline(t); } } - - handleDedents(-1, (CommonToken)t); + if (prev != null) { + ((CommonToken)t).setStopIndex(((CommonToken)prev).getStopIndex()); + handleDedents(-1, (CommonToken)prev); + } else { + handleDedents(-1, (CommonToken)t); + } enqueue(t); } else if (t.getType() == PythonLexer.NEWLINE) { // save NEWLINE in the queue @@ -203,7 +207,12 @@ handleIndents(cpos, (CommonToken)t); } else if (cpos < lastIndent) { // they dedented - handleDedents(cpos, (CommonToken)t); + Token prev = stream.LT(-1); + if (prev != null) { + handleDedents(cpos, (CommonToken)prev); + } else { + handleDedents(cpos, (CommonToken)t); + } } if (t.getType() == Token.EOF && inSingle) { Modified: trunk/jython/src/org/python/antlr/PythonTreeAdaptor.java =================================================================== --- trunk/jython/src/org/python/antlr/PythonTreeAdaptor.java 2008-09-03 15:24:20 UTC (rev 5287) +++ trunk/jython/src/org/python/antlr/PythonTreeAdaptor.java 2008-09-04 16:57:30 UTC (rev 5288) @@ -12,6 +12,8 @@ if (t==null) { return; } + //System.out.println("setting boundries on '"+t+"' with start: '" + startToken + "' and '" + + // stopToken + "'"); int start = 0; int stop = 0; int startChar = 0; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2008-09-05 16:30:39
|
Revision: 5291 http://jython.svn.sourceforge.net/jython/?rev=5291&view=rev Author: fwierzbicki Date: 2008-09-05 16:30:36 +0000 (Fri, 05 Sep 2008) Log Message: ----------- Broke test_traceback.py in my last commit. This fixes it again. Modified Paths: -------------- trunk/jython/grammar/Python.g trunk/jython/src/org/python/antlr/PythonTokenSource.java Modified: trunk/jython/grammar/Python.g =================================================================== --- trunk/jython/grammar/Python.g 2008-09-05 16:21:55 UTC (rev 5290) +++ trunk/jython/grammar/Python.g 2008-09-05 16:30:36 UTC (rev 5291) @@ -286,10 +286,14 @@ @after { if (!stypes.isEmpty()) { //The EOF token messes up the end offsets, so set them manually. + //XXX: this may no longer be true now that PythonTokenSource is + // adjusting EOF offsets -- but needs testing before I remove + // this. PythonTree stop = (PythonTree)stypes.get(stypes.size() -1); mtype.setCharStopIndex(stop.getCharStopIndex()); mtype.setTokenStopIndex(stop.getTokenStopIndex()); } + $file_input.tree = mtype; } : (NEWLINE @@ -1778,6 +1782,8 @@ CommonToken c = new CommonToken(LEADING_WS,new String(indentation)); c.setLine(input.getLine()); c.setCharPositionInLine(input.getCharPositionInLine()); + c.setStartIndex(input.index() - 1); + c.setStopIndex(input.index() - 1); emit(c); // kill trailing newline if present and then ignore if (newlines != 0) { @@ -1793,7 +1799,12 @@ for (int i=0; i<newlines; i++) { nls[i] = '\n'; } - emit(new CommonToken(NEWLINE,new String(nls))); + CommonToken c = new CommonToken(NEWLINE,new String(nls)); + c.setLine(input.getLine()); + c.setCharPositionInLine(input.getCharPositionInLine()); + c.setStartIndex(input.index() - 1); + c.setStopIndex(input.index() - 1); + emit(c); } } ) Modified: trunk/jython/src/org/python/antlr/PythonTokenSource.java =================================================================== --- trunk/jython/src/org/python/antlr/PythonTokenSource.java 2008-09-05 16:21:55 UTC (rev 5290) +++ trunk/jython/src/org/python/antlr/PythonTokenSource.java 2008-09-05 16:30:36 UTC (rev 5291) @@ -152,23 +152,25 @@ tokens.addElement(newline); } + private void handleEOF(CommonToken eof, CommonToken prev) { + if (prev != null) { + eof.setStopIndex(prev.getStopIndex()); + } + } + protected void insertImaginaryIndentDedentTokens() { Token t = stream.LT(1); stream.consume(); if (t.getType() == Token.EOF) { Token prev = stream.LT(-1); + handleEOF((CommonToken)t, (CommonToken)prev); if (!inSingle) { if (prev == null || prev.getType() != PythonLexer.NEWLINE) { generateNewline(t); } } - if (prev != null) { - ((CommonToken)t).setStopIndex(((CommonToken)prev).getStopIndex()); - handleDedents(-1, (CommonToken)prev); - } else { - handleDedents(-1, (CommonToken)t); - } + handleDedents(-1, (CommonToken)t); enqueue(t); } else if (t.getType() == PythonLexer.NEWLINE) { // save NEWLINE in the queue @@ -186,6 +188,7 @@ // compute cpos as the char pos of next non-WS token in line int cpos = t.getCharPositionInLine(); // column dictates indent/dedent if (t.getType() == Token.EOF) { + handleEOF((CommonToken)t, (CommonToken)newline); cpos = -1; // pretend EOF always happens at left edge } else if (t.getType() == PythonLexer.LEADING_WS) { @@ -207,8 +210,7 @@ handleIndents(cpos, (CommonToken)t); } else if (cpos < lastIndent) { // they dedented - Token prev = stream.LT(-1); - handleDedents(cpos, (CommonToken)newline); + handleDedents(cpos, (CommonToken)t); } if (t.getType() == Token.EOF && inSingle) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
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. |
From: <fwi...@us...> - 2008-09-07 05:57:30
|
Revision: 5301 http://jython.svn.sourceforge.net/jython/?rev=5301&view=rev Author: fwierzbicki Date: 2008-09-07 05:57:26 +0000 (Sun, 07 Sep 2008) Log Message: ----------- Committing Nicholas Riley's patch after getting test_ast.py to work. See http://bugs.jython.org/issue1758279. Modified Paths: -------------- trunk/jython/Lib/test/test_ast.py trunk/jython/Lib/test/test_class_jy.py trunk/jython/src/org/python/core/PyJavaClass.java Modified: trunk/jython/Lib/test/test_ast.py =================================================================== --- trunk/jython/Lib/test/test_ast.py 2008-09-06 23:20:46 UTC (rev 5300) +++ trunk/jython/Lib/test/test_ast.py 2008-09-07 05:57:26 UTC (rev 5301) @@ -5,12 +5,12 @@ def get_class_name(t): result = t.__class__.__name__ if os.name.startswith('java'): - if result in ("org.python.antlr.ast.expr_contextType", - "org.python.antlr.ast.boolopType", - "org.python.antlr.ast.unaryopType", - "org.python.antlr.ast.cmpopType", - "org.python.antlr.ast.operatorType"): - result = str(t) + if result in ("expr_contextType", + "boolopType", + "unaryopType", + "cmpopType", + "operatorType"): + result = t.name() else: result = result.split(".")[-1] if result.endswith("Type"): Modified: trunk/jython/Lib/test/test_class_jy.py =================================================================== --- trunk/jython/Lib/test/test_class_jy.py 2008-09-06 23:20:46 UTC (rev 5300) +++ trunk/jython/Lib/test/test_class_jy.py 2008-09-07 05:57:26 UTC (rev 5301) @@ -273,12 +273,29 @@ self.assert_(isinstance(retro, OldStyle)) +class JavaClassNamingTestCase(unittest.TestCase): + """ + Tests for PyJavaClass naming. + """ + + def test_java_class_name(self): + """ + The __name__ and __module__ attributes of Java classes should be set + according to the same convention that Python uses. + """ + from java.lang import String + self.assertEqual(String.__name__, "String") + self.assertEqual(String.__module__, "java.lang") + + + def test_main(): test_support.run_unittest(ClassGeneralTestCase, ClassNamelessModuleTestCase, BrokenNameTestCase, ClassLocalsTestCase, - IsDescendentTestCase) + IsDescendentTestCase, + JavaClassNamingTestCase) if __name__ == "__main__": Modified: trunk/jython/src/org/python/core/PyJavaClass.java =================================================================== --- trunk/jython/src/org/python/core/PyJavaClass.java 2008-09-06 23:20:46 UTC (rev 5300) +++ trunk/jython/src/org/python/core/PyJavaClass.java 2008-09-07 05:57:26 UTC (rev 5301) @@ -75,8 +75,30 @@ init(c); } - protected PyJavaClass(String name,PackageManager mgr) { - __name__ = name; + public String __module__; + /** + * Set the full name of this class. + */ + private void setName(String name) { + int dotIndex = name.lastIndexOf("."); + if (dotIndex == -1) { + __name__ = name; + __module__ = ""; + } else { + __name__ = name.substring(name.lastIndexOf(".")+1, name.length()); + __module__ = name.substring(0, name.lastIndexOf(".")); + } + } + + private String fullName() { + if (__module__ == "") + return __name__; + else + return __module__ + "." + __name__; + } + + protected PyJavaClass(String name, PackageManager mgr) { + setName(name); this.__mgr__ = mgr; } @@ -97,7 +119,7 @@ } private static final void initLazy(PyJavaClass jc) { - Class c = jc.__mgr__.findClass(null,jc.__name__,"lazy java class"); + Class c = jc.__mgr__.findClass(null,jc.fullName(),"lazy java class"); check_lazy_allowed(c); // xxx jc.init(c); tbl.putCanonical(jc.proxyClass,jc); @@ -209,7 +231,7 @@ private void init(Class c) { proxyClass = c; - __name__ = c.getName(); + setName(c.getName()); } /** @@ -761,6 +783,8 @@ } if (name == "__name__") return new PyString(__name__); + if (name == "__module__") + return new PyString(__module__); if (name == "__bases__") { if (__bases__ == null) initialize(); @@ -851,11 +875,11 @@ if (PyObject.class.isAssignableFrom(proxyClass)) { if (Modifier.isAbstract(proxyClass.getModifiers())) { throw Py.TypeError("can't instantiate abstract class ("+ - __name__+")"); + fullName()+")"); } if (__init__ == null) { throw Py.TypeError("no public constructors for "+ - __name__); + fullName()); } return __init__.make(args,keywords); } @@ -871,7 +895,19 @@ return super.__tojava__(c); } + public int __cmp__(PyObject other) { + if (!(other instanceof PyJavaClass)) { + return -2; + } + int c = fullName().compareTo(((PyJavaClass) other).fullName()); + return c < 0 ? -1 : c > 0 ? 1 : 0; + } + + public PyString __str__() { + return new PyString(fullName()); + } + public String toString() { - return "<jclass "+__name__+" "+Py.idstr(this)+">"; + return "<jclass "+fullName()+" "+Py.idstr(this)+">"; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2008-09-10 18:36:19
|
Revision: 5313 http://jython.svn.sourceforge.net/jython/?rev=5313&view=rev Author: fwierzbicki Date: 2008-09-10 18:36:16 +0000 (Wed, 10 Sep 2008) Log Message: ----------- Make it possible to get error nodes into the spots that are now casting to exprType. 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 2008-09-10 13:05:27 UTC (rev 5312) +++ trunk/jython/grammar/Python.g 2008-09-10 18:36:16 UTC (rev 5313) @@ -312,7 +312,7 @@ $eval_input.tree = mtype; } : LEADING_WS? (NEWLINE)* testlist[expr_contextType.Load] (NEWLINE)* EOF { - mtype = new Expression($eval_input.start, (exprType)$testlist.tree); + mtype = new Expression($eval_input.start, actions.makeExpr($testlist.tree)); } ; @@ -424,7 +424,7 @@ } : fpdef[expr_contextType.Param] (ASSIGN test[expr_contextType.Load])? { - $etype = (exprType)$fpdef.tree; + $etype = actions.makeExpr($fpdef.tree); if ($ASSIGN != null) { defaults.add($test.tree); } else if (!defaults.isEmpty()) { @@ -462,7 +462,7 @@ //fpdef: NAME | '(' fplist ')' fpdef[expr_contextType ctype] @after { - actions.checkAssign((exprType)$fpdef.tree); + actions.checkAssign(actions.makeExpr($fpdef.tree)); } : NAME -> ^(NAME<Name>[$NAME, $NAME.text, ctype]) @@ -529,31 +529,31 @@ : ((testlist[null] augassign) => lhs=testlist[expr_contextType.AugStore] ( (aay=augassign y1=yield_expr { - actions.checkAssign((exprType)$lhs.tree); - stype = new AugAssign($lhs.tree, (exprType)$lhs.tree, $aay.op, (exprType)$y1.tree); + actions.checkAssign(actions.makeExpr($lhs.tree)); + stype = new AugAssign($lhs.tree, actions.makeExpr($lhs.tree), $aay.op, actions.makeExpr($y1.tree)); } ) | (aat=augassign rhs=testlist[expr_contextType.Load] { - actions.checkAssign((exprType)$lhs.tree); - stype = new AugAssign($lhs.tree, (exprType)$lhs.tree, $aat.op, (exprType)$rhs.tree); + actions.checkAssign(actions.makeExpr($lhs.tree)); + stype = new AugAssign($lhs.tree, actions.makeExpr($lhs.tree), $aat.op, actions.makeExpr($rhs.tree)); } ) ) | (testlist[null] ASSIGN) => lhs=testlist[expr_contextType.Store] ( | ((at=ASSIGN t+=testlist[expr_contextType.Store])+ - -> ^(ASSIGN<Assign>[$lhs.start, actions.makeAssignTargets((exprType)$lhs.tree, $t), + -> ^(ASSIGN<Assign>[$lhs.start, actions.makeAssignTargets(actions.makeExpr($lhs.tree), $t), actions.makeAssignValue($t)]) ) | ((ay=ASSIGN y2+=yield_expr)+ - -> ^(ASSIGN<Assign>[$lhs.start, actions.makeAssignTargets((exprType)$lhs.tree, $y2), + -> ^(ASSIGN<Assign>[$lhs.start, actions.makeAssignTargets(actions.makeExpr($lhs.tree), $y2), actions.makeAssignValue($y2)]) ) ) | lhs=testlist[expr_contextType.Load] { - stype = new Expr($lhs.start, (exprType)$lhs.tree); + stype = new Expr($lhs.start, actions.makeExpr($lhs.tree)); } ) ; @@ -582,7 +582,7 @@ (t1=printlist -> ^(PRINT<Print>[$PRINT, null, actions.makeExprs($t1.elts), $t1.newline]) | RIGHTSHIFT t2=printlist2 - -> ^(PRINT<Print>[$PRINT, (exprType)$t2.elts.get(0), actions.makeExprs($t2.elts, 1), $t2.newline]) + -> ^(PRINT<Print>[$PRINT, actions.makeExpr($t2.elts.get(0)), actions.makeExprs($t2.elts, 1), $t2.newline]) | -> ^(PRINT<Print>[$PRINT, null, new exprType[0\], false]) ) @@ -666,7 +666,7 @@ return_stmt : RETURN (testlist[expr_contextType.Load] - -> ^(RETURN<Return>[$RETURN, (exprType)$testlist.tree]) + -> ^(RETURN<Return>[$RETURN, actions.makeExpr($testlist.tree)]) | -> ^(RETURN<Return>[$RETURN, null]) ) @@ -674,14 +674,14 @@ //yield_stmt: yield_expr yield_stmt - : yield_expr -> ^(YIELD<Expr>[$yield_expr.start, (exprType)$yield_expr.tree]) + : yield_expr -> ^(YIELD<Expr>[$yield_expr.start, actions.makeExpr($yield_expr.tree)]) ; //raise_stmt: 'raise' [test [',' test [',' test]]] raise_stmt : RAISE (t1=test[expr_contextType.Load] (COMMA t2=test[expr_contextType.Load] (COMMA t3=test[expr_contextType.Load])?)?)? - -> ^(RAISE<Raise>[$RAISE, (exprType)$t1.tree, (exprType)$t2.tree, (exprType)$t3.tree]) + -> ^(RAISE<Raise>[$RAISE, actions.makeExpr($t1.tree), actions.makeExpr($t2.tree), actions.makeExpr($t3.tree)]) ; //import_stmt: import_name | import_from @@ -774,14 +774,14 @@ : EXEC expr[expr_contextType.Load] (IN t1=test[expr_contextType.Load] (COMMA t2=test[expr_contextType.Load])?)? { - stype = new Exec($EXEC, (exprType)$expr.tree, (exprType)$t1.tree, (exprType)$t2.tree); + stype = new Exec($EXEC, actions.makeExpr($expr.tree), actions.makeExpr($t1.tree), actions.makeExpr($t2.tree)); } ; //assert_stmt: 'assert' test [',' test] assert_stmt : ASSERT t1=test[expr_contextType.Load] (COMMA t2=test[expr_contextType.Load])? - -> ^(ASSERT<Assert>[$ASSERT, (exprType)$t1.tree, (exprType)$t2.tree]) + -> ^(ASSERT<Assert>[$ASSERT, actions.makeExpr($t1.tree), actions.makeExpr($t2.tree)]) ; //compound_stmt: if_stmt | while_stmt | for_stmt | try_stmt | funcdef | classdef @@ -799,14 +799,14 @@ if_stmt : IF test[expr_contextType.Load] COLON ifsuite=suite elifs+=elif_clause* (ORELSE COLON elsesuite=suite)? - -> ^(IF<If>[$IF, (exprType)$test.tree, actions.makeStmts($ifsuite.stypes), + -> ^(IF<If>[$IF, actions.makeExpr($test.tree), actions.makeStmts($ifsuite.stypes), actions.makeElses($elsesuite.stypes, $elifs)]) ; //not in CPython's Grammar file elif_clause : ELIF test[expr_contextType.Load] COLON suite - -> ^(ELIF<If>[$test.start, (exprType)$test.tree, actions.makeStmts($suite.stypes), new stmtType[0\]]) + -> ^(ELIF<If>[$test.start, actions.makeExpr($test.tree), actions.makeStmts($suite.stypes), new stmtType[0\]]) ; //while_stmt: 'while' test ':' suite ['else' ':' suite] @@ -819,7 +819,7 @@ } : WHILE test[expr_contextType.Load] COLON s1=suite (ORELSE COLON s2=suite)? { - stype = actions.makeWhile($WHILE, (exprType)$test.tree, $s1.stypes, $s2.stypes); + stype = actions.makeWhile($WHILE, actions.makeExpr($test.tree), $s1.stypes, $s2.stypes); } ; @@ -834,7 +834,7 @@ : FOR exprlist[expr_contextType.Store] IN testlist[expr_contextType.Load] COLON s1=suite (ORELSE COLON s2=suite)? { - stype = actions.makeFor($FOR, $exprlist.etype, (exprType)$testlist.tree, $s1.stypes, $s2.stypes); + stype = actions.makeFor($FOR, $exprlist.etype, actions.makeExpr($testlist.tree), $s1.stypes, $s2.stypes); } ; @@ -872,7 +872,7 @@ } : WITH test[expr_contextType.Load] (with_var)? COLON suite { - stype = new With($WITH, (exprType)$test.tree, $with_var.etype, + stype = new With($WITH, actions.makeExpr($test.tree), $with_var.etype, actions.makeStmts($suite.stypes)); } ; @@ -881,14 +881,14 @@ with_var returns [exprType etype] : (AS | NAME) expr[expr_contextType.Store] { - $etype = (exprType)$expr.tree; + $etype = actions.makeExpr($expr.tree); } ; //except_clause: 'except' [test [',' test]] except_clause : EXCEPT (t1=test[expr_contextType.Load] (COMMA t2=test[expr_contextType.Store])?)? COLON suite - -> ^(EXCEPT<excepthandlerType>[$EXCEPT, (exprType)$t1.tree, (exprType)$t2.tree, + -> ^(EXCEPT<excepthandlerType>[$EXCEPT, actions.makeExpr($t1.tree), actions.makeExpr($t2.tree), actions.makeStmts($suite.stypes), $EXCEPT.getLine(), $EXCEPT.getCharPositionInLine()]) ; @@ -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>[$o1.start, (exprType)$o2.tree, (exprType)$o1.tree, (exprType)$e.tree]) + -> ^(IF<IfExp>[$o1.start, actions.makeExpr($o2.tree), actions.makeExpr($o1.tree), actions.makeExpr($e.tree)]) | -> or_test ) @@ -953,7 +953,7 @@ //not_test: 'not' not_test | comparison not_test[expr_contextType ctype] : NOT nt=not_test[ctype] - -> ^(NOT<UnaryOp>[$NOT, unaryopType.Not, (exprType)$nt.tree]) + -> ^(NOT<UnaryOp>[$NOT, unaryopType.Not, actions.makeExpr($nt.tree)]) | comparison[ctype] ; @@ -964,7 +964,7 @@ } @after { if (!cmps.isEmpty()) { - $comparison.tree = new Compare($left.start, (exprType)$left.tree, actions.makeCmpOps(cmps), + $comparison.tree = new Compare($left.start, actions.makeExpr($left.tree), actions.makeCmpOps(cmps), actions.makeExprs($right)); } } @@ -1123,7 +1123,7 @@ : PLUS p=factor {$etype = new UnaryOp($PLUS, unaryopType.UAdd, $p.etype);} | MINUS m=factor {$etype = actions.negate($MINUS, $m.etype);} | TILDE t=factor {$etype = new UnaryOp($TILDE, unaryopType.Invert, $t.etype);} - | power {$etype = (exprType)$power.tree;} + | power {$etype = actions.makeExpr($power.tree);} ; //power: atom trailer* ['**' factor] @@ -1134,7 +1134,7 @@ : atom (t+=trailer[$atom.start, $atom.tree])* (options {greedy=true;}:d=DOUBLESTAR factor)? { //XXX: This could be better. - $etype = (exprType)$atom.tree; + $etype = actions.makeExpr($atom.tree); if ($t != null) { for(Object o : $t) { if ($etype instanceof Context) { @@ -1194,7 +1194,7 @@ ) RCURLY | lb=BACKQUOTE testlist[expr_contextType.Load] rb=BACKQUOTE - -> ^(BACKQUOTE<Repr>[$lb, (exprType)$testlist.tree]) + -> ^(BACKQUOTE<Repr>[$lb, actions.makeExpr($testlist.tree)]) | NAME -> ^(NAME<Name>[$NAME, $NAME.text, $expr::ctype]) | INT @@ -1224,7 +1224,7 @@ Collections.reverse(gens); comprehensionType[] c = (comprehensionType[])gens.toArray(new comprehensionType[gens.size()]); - etype = new ListComp($listmaker.start, (exprType)$t.get(0), c); + etype = new ListComp($listmaker.start, actions.makeExpr($t.get(0)), c); } | (options {greedy=true;}:COMMA t+=test[$expr::ctype])* { @@ -1254,11 +1254,11 @@ { Collections.reverse(gens); comprehensionType[] c = (comprehensionType[])gens.toArray(new comprehensionType[gens.size()]); - exprType e = (exprType)$t.get(0); + exprType e = actions.makeExpr($t.get(0)); if (e instanceof Context) { ((Context)e).setContext(expr_contextType.Load); } - etype = new GeneratorExp($testlist_gexp.start, (exprType)$t.get(0), c); + etype = new GeneratorExp($testlist_gexp.start, actions.makeExpr($t.get(0)), c); } ) ) @@ -1278,7 +1278,7 @@ if (a == null) { a = new argumentsType($LAMBDA, new exprType[0], null, null, new exprType[0]); } - etype = new Lambda($LAMBDA, a, (exprType)$test.tree); + etype = new Lambda($LAMBDA, a, actions.makeExpr($test.tree)); } ; @@ -1286,16 +1286,16 @@ trailer [Token begin, PythonTree tree] : LPAREN (arglist - -> ^(LPAREN<Call>[$begin, (exprType)$tree, actions.makeExprs($arglist.args), + -> ^(LPAREN<Call>[$begin, actions.makeExpr($tree), actions.makeExprs($arglist.args), actions.makeKeywords($arglist.keywords), $arglist.starargs, $arglist.kwargs]) | - -> ^(LPAREN<Call>[$begin, (exprType)$tree, new exprType[0\], new keywordType[0\], null, null]) + -> ^(LPAREN<Call>[$begin, actions.makeExpr($tree), new exprType[0\], new keywordType[0\], null, null]) ) RPAREN | LBRACK subscriptlist[$begin] RBRACK - -> ^(LBRACK<Subscript>[$begin, (exprType)$tree, (sliceType)$subscriptlist.tree, $expr::ctype]) + -> ^(LBRACK<Subscript>[$begin, actions.makeExpr($tree), (sliceType)$subscriptlist.tree, $expr::ctype]) | DOT attr - -> ^(DOT<Attribute>[$begin, (exprType)$tree, $attr.text, $expr::ctype]) + -> ^(DOT<Attribute>[$begin, actions.makeExpr($tree), $attr.text, $expr::ctype]) ; //subscriptlist: subscript (',' subscript)* [','] @@ -1332,7 +1332,7 @@ $sltype = actions.makeSubscript(null, $c2, $upper2.tree, $sliceop.tree); } | test[expr_contextType.Load] - -> ^(LPAREN<Index>[$test.start, (exprType)$test.tree]) + -> ^(LPAREN<Index>[$test.start, actions.makeExpr($test.tree)]) ; //sliceop: ':' [test] @@ -1351,7 +1351,7 @@ } | expr[ctype] { - $etype = (exprType)$expr.tree; + $etype = actions.makeExpr($expr.tree); } ; @@ -1393,7 +1393,7 @@ } : CLASS NAME (LPAREN testlist[expr_contextType.Load]? RPAREN)? COLON suite { - stype = new ClassDef($CLASS, actions.cantBeNone($NAME), actions.makeBases((exprType)$testlist.tree), + stype = new ClassDef($CLASS, actions.cantBeNone($NAME), actions.makeBases(actions.makeExpr($testlist.tree)), actions.makeStmts($suite.stypes)); } ; @@ -1417,17 +1417,17 @@ } $args=arguments; $keywords=kws; - $starargs=(exprType)$s.tree; - $kwargs=(exprType)$k.tree; + $starargs=actions.makeExpr($s.tree); + $kwargs=actions.makeExpr($k.tree); } | STAR s=test[expr_contextType.Load] (COMMA DOUBLESTAR k=test[expr_contextType.Load])? { - $starargs=(exprType)$s.tree; - $kwargs=(exprType)$k.tree; + $starargs=actions.makeExpr($s.tree); + $kwargs=actions.makeExpr($k.tree); } | DOUBLESTAR k=test[expr_contextType.Load] { - $kwargs=(exprType)$k.tree; + $kwargs=actions.makeExpr($k.tree); } ; @@ -1436,7 +1436,7 @@ : t1=test[expr_contextType.Load] ((ASSIGN t2=test[expr_contextType.Load]) { - $kws.add(new exprType[]{(exprType)$t1.tree, (exprType)$t2.tree}); + $kws.add(new exprType[]{actions.makeExpr($t1.tree), actions.makeExpr($t2.tree)}); } | gen_for[$gens] { @@ -1446,7 +1446,7 @@ $genarg = true; Collections.reverse($gens); comprehensionType[] c = (comprehensionType[])$gens.toArray(new comprehensionType[$gens.size()]); - arguments.add(new GeneratorExp($t1.start, (exprType)$t1.tree, c)); + arguments.add(new GeneratorExp($t1.start, actions.makeExpr($t1.tree), c)); } | { if (kws.size() > 0) { @@ -1475,7 +1475,7 @@ } else { e = new exprType[0]; } - gens.add(new comprehensionType($FOR, $exprlist.etype, (exprType)$testlist.tree, e)); + gens.add(new comprehensionType($FOR, $exprlist.etype, actions.makeExpr($testlist.tree), e)); } ; @@ -1483,7 +1483,7 @@ list_if[List gens] returns [exprType etype] : IF test[expr_contextType.Load] (list_iter[gens])? { - $etype = (exprType)$test.tree; + $etype = actions.makeExpr($test.tree); } ; @@ -1506,7 +1506,7 @@ } else { e = new exprType[0]; } - gens.add(new comprehensionType($FOR, $exprlist.etype, (exprType)$or_test.tree, e)); + gens.add(new comprehensionType($FOR, $exprlist.etype, actions.makeExpr($or_test.tree), e)); } ; @@ -1514,14 +1514,14 @@ gen_if[List gens] returns [exprType etype] : IF test[expr_contextType.Load] gen_iter[gens]? { - $etype = (exprType)$test.tree; + $etype = actions.makeExpr($test.tree); } ; //yield_expr: 'yield' [testlist] yield_expr : YIELD testlist[expr_contextType.Load]? - -> ^(YIELD<Yield>[$YIELD, (exprType)$testlist.tree]) + -> ^(YIELD<Yield>[$YIELD, actions.makeExpr($testlist.tree)]) ; AS : 'as' ; Modified: trunk/jython/src/org/python/antlr/GrammarActions.java =================================================================== --- trunk/jython/src/org/python/antlr/GrammarActions.java 2008-09-10 13:05:27 UTC (rev 5312) +++ trunk/jython/src/org/python/antlr/GrammarActions.java 2008-09-10 18:36:16 UTC (rev 5313) @@ -151,6 +151,17 @@ errorHandler.error("Generator expression must be parenthesized if not sole argument", t); } + exprType makeExpr(Object o) { + if (o instanceof exprType) { + return (exprType)o; + } + if (o instanceof PythonTree) { + return errorHandler.errorExpr((PythonTree)o); + } + return null; + } + + exprType[] makeExprs(List exprs) { return makeExprs(exprs, 0); } @@ -280,7 +291,7 @@ checkAssign(lhs); e[0] = lhs; for(int i=0;i<rhs.size() - 1;i++) { - exprType r = (exprType)rhs.get(i); + exprType r = makeExpr(rhs.get(i)); checkAssign(r); e[i + 1] = r; } @@ -288,7 +299,7 @@ } exprType makeAssignValue(List rhs) { - exprType value = (exprType)rhs.get(rhs.size() -1); + exprType value = makeExpr(rhs.get(rhs.size() -1)); recurseSetContext(value, expr_contextType.Load); return value; } @@ -654,18 +665,18 @@ exprType e = null; exprType o = null; if (lower != null) { - s = (exprType)lower; + s = makeExpr(lower); } if (colon != null) { isSlice = true; if (upper != null) { - e = (exprType)upper; + e = makeExpr(upper); } } if (sliceop != null) { isSlice = true; if (sliceop != null) { - o = (exprType)sliceop; + o = makeExpr(sliceop); } else { o = new Name(sliceop, "None", expr_contextType.Load); } @@ -702,18 +713,18 @@ } BinOp makeBinOp(PythonTree left, operatorType op, List rights) { - BinOp current = new BinOp(left, (exprType)left, op, (exprType)rights.get(0)); + BinOp current = new BinOp(left, makeExpr(left), op, makeExpr(rights.get(0))); for (int i = 1; i< rights.size(); i++) { - exprType right = (exprType)rights.get(i); + exprType right = makeExpr(rights.get(i)); current = new BinOp(left, current, op, right); } return current; } BinOp makeBinOp(PythonTree left, List ops, List rights) { - BinOp current = new BinOp(left, (exprType)left, (operatorType)ops.get(0), (exprType)rights.get(0)); + BinOp current = new BinOp(left, makeExpr(left), (operatorType)ops.get(0), makeExpr(rights.get(0))); for (int i = 1; i< rights.size(); i++) { - exprType right = (exprType)rights.get(i); + exprType right = makeExpr(rights.get(i)); operatorType op = (operatorType)ops.get(i); current = new BinOp(left, current, op, right); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2008-09-11 19:48:37
|
Revision: 5320 http://jython.svn.sourceforge.net/jython/?rev=5320&view=rev Author: fwierzbicki Date: 2008-09-11 19:48:35 +0000 (Thu, 11 Sep 2008) Log Message: ----------- Transform if/elif/else into the correct If nodes in the grammar file instead of as a code post-processing step. 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 2008-09-11 01:33:39 UTC (rev 5319) +++ trunk/jython/grammar/Python.g 2008-09-11 19:48:35 UTC (rev 5320) @@ -797,18 +797,31 @@ //if_stmt: 'if' test ':' suite ('elif' test ':' suite)* ['else' ':' suite] if_stmt - : IF test[expr_contextType.Load] COLON ifsuite=suite elifs+=elif_clause* - (ORELSE COLON elsesuite=suite)? + : IF test[expr_contextType.Load] COLON ifsuite=suite elif_clause[$test.start]? -> ^(IF<If>[$IF, actions.makeExpr($test.tree), actions.makeStmts($ifsuite.stypes), - actions.makeElses($elsesuite.stypes, $elifs)]) + actions.makeElse($elif_clause.stypes, $elif_clause.tree)]) ; //not in CPython's Grammar file -elif_clause - : ELIF test[expr_contextType.Load] COLON suite - -> ^(ELIF<If>[$test.start, actions.makeExpr($test.tree), actions.makeStmts($suite.stypes), new stmtType[0\]]) +elif_clause [Token iftest] returns [List stypes] + : else_clause { + $stypes = $else_clause.stypes; + } + | ELIF test[expr_contextType.Load] COLON suite + (e2=elif_clause[$iftest] + -> ^(ELIF<If>[$iftest, actions.makeExpr($test.tree), actions.makeStmts($suite.stypes), actions.makeElse($e2.stypes, $e2.tree)]) + | + -> ^(ELIF<If>[$iftest, actions.makeExpr($test.tree), actions.makeStmts($suite.stypes), new stmtType[0\]]) + ) ; +//not in CPython's Grammar file +else_clause returns [List stypes] + : ORELSE COLON elsesuite=suite { + $stypes = $suite.stypes; + } + ; + //while_stmt: 'while' test ':' suite ['else' ':' suite] while_stmt @init { Modified: trunk/jython/src/org/python/antlr/GrammarActions.java =================================================================== --- trunk/jython/src/org/python/antlr/GrammarActions.java 2008-09-11 01:33:39 UTC (rev 5319) +++ trunk/jython/src/org/python/antlr/GrammarActions.java 2008-09-11 19:48:35 UTC (rev 5320) @@ -182,18 +182,13 @@ return new exprType[0]; } - stmtType[] makeElses(List elseSuite, List elifs) { - stmtType[] o; - o = makeStmts(elseSuite); - if (elifs != null) { - ListIterator iter = elifs.listIterator(elifs.size()); - while (iter.hasPrevious()) { - If elif = (If)iter.previous(); - elif.orelse = o; - o = new stmtType[]{elif}; - } + stmtType[] makeElse(List elseSuite, PythonTree elif) { + if (elseSuite != null) { + return makeStmts(elseSuite); + } else if (elif == null) { + return new stmtType[0]; } - return o; + return new stmtType[]{(stmtType)elif}; } stmtType[] makeStmts(PythonTree t) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2008-09-18 12:07:38
|
Revision: 5339 http://jython.svn.sourceforge.net/jython/?rev=5339&view=rev Author: fwierzbicki Date: 2008-09-18 19:07:35 +0000 (Thu, 18 Sep 2008) Log Message: ----------- Fixed another eof/whitespace parsing issue from Django. Turned all of these problems into a new test: test_eof_jy.py. Modified Paths: -------------- trunk/jython/grammar/Python.g trunk/jython/src/org/python/antlr/PythonTokenSource.java Added Paths: ----------- trunk/jython/Lib/test/eof_fodder1.py trunk/jython/Lib/test/eof_fodder2.py trunk/jython/Lib/test/eof_fodder3.py trunk/jython/Lib/test/eof_fodder4.py trunk/jython/Lib/test/eof_fodder5.py trunk/jython/Lib/test/eof_fodder6.py trunk/jython/Lib/test/test_eof_jy.py Added: trunk/jython/Lib/test/eof_fodder1.py =================================================================== --- trunk/jython/Lib/test/eof_fodder1.py (rev 0) +++ trunk/jython/Lib/test/eof_fodder1.py 2008-09-18 19:07:35 UTC (rev 5339) @@ -0,0 +1,3 @@ +def d(): + def e(): + pass \ No newline at end of file Added: trunk/jython/Lib/test/eof_fodder2.py =================================================================== --- trunk/jython/Lib/test/eof_fodder2.py (rev 0) +++ trunk/jython/Lib/test/eof_fodder2.py 2008-09-18 19:07:35 UTC (rev 5339) @@ -0,0 +1,4 @@ +def f(): + def g(): + pass + \ No newline at end of file Added: trunk/jython/Lib/test/eof_fodder3.py =================================================================== --- trunk/jython/Lib/test/eof_fodder3.py (rev 0) +++ trunk/jython/Lib/test/eof_fodder3.py 2008-09-18 19:07:35 UTC (rev 5339) @@ -0,0 +1,4 @@ +def f(): + def g(): + pass + Added: trunk/jython/Lib/test/eof_fodder5.py =================================================================== --- trunk/jython/Lib/test/eof_fodder5.py (rev 0) +++ trunk/jython/Lib/test/eof_fodder5.py 2008-09-18 19:07:35 UTC (rev 5339) @@ -0,0 +1,3 @@ +def f(): + pass +# just a comment \ No newline at end of file Added: trunk/jython/Lib/test/eof_fodder6.py =================================================================== --- trunk/jython/Lib/test/eof_fodder6.py (rev 0) +++ trunk/jython/Lib/test/eof_fodder6.py 2008-09-18 19:07:35 UTC (rev 5339) @@ -0,0 +1,5 @@ +def f(): + def g(): + pass + + \ No newline at end of file Added: trunk/jython/Lib/test/test_eof_jy.py =================================================================== --- trunk/jython/Lib/test/test_eof_jy.py (rev 0) +++ trunk/jython/Lib/test/test_eof_jy.py 2008-09-18 19:07:35 UTC (rev 5339) @@ -0,0 +1,55 @@ +import unittest +from test import test_support + +class TestEof(unittest.TestCase): + """ + Oddities originally found in Django involving whitespace and newlines or + lack thereof at the end of files. I can't use __builtin__.compile() + because newlines get added and hide these problems, so I have opted to + import Python files containing these oddities. + """ + + def test_indented_no_newline(self): + try: + import eof_fodder1 + except ImportError, cause: + self.fail(cause) + + def test_trailing_ws_no_newline(self): + try: + import eof_fodder2 + except ImportError, cause: + self.fail(cause) + + def test_trailing_ws(self): + try: + import eof_fodder3 + except ImportError, cause: + self.fail(cause) + + def test_empty(self): + try: + import eof_fodder4 + except ImportError, cause: + self.fail(cause) + + def test_just_a_comment_no_newline(self): + try: + import eof_fodder5 + except ImportError, cause: + self.fail(cause) + + def test_junky_ws_after_indent(self): + try: + import eof_fodder6 + except ImportError, cause: + self.fail(cause) + +#============================================================================== + +def test_main(verbose=None): + test_classes = [TestEof] + test_support.run_unittest(*test_classes) + +if __name__ == "__main__": + test_main(verbose=True) Modified: trunk/jython/grammar/Python.g =================================================================== --- trunk/jython/grammar/Python.g 2008-09-17 22:37:23 UTC (rev 5338) +++ trunk/jython/grammar/Python.g 2008-09-18 19:07:35 UTC (rev 5339) @@ -1785,7 +1785,7 @@ )+ ( ('\r')? '\n' {newlines++; } )* { - if (input.LA(1) != -1) { + if (input.LA(1) != -1 || newlines == 0) { // make a string of n spaces where n is column number - 1 char[] indentation = new char[spaces]; for (int i=0; i<spaces; i++) { Modified: trunk/jython/src/org/python/antlr/PythonTokenSource.java =================================================================== --- trunk/jython/src/org/python/antlr/PythonTokenSource.java 2008-09-17 22:37:23 UTC (rev 5338) +++ trunk/jython/src/org/python/antlr/PythonTokenSource.java 2008-09-18 19:07:35 UTC (rev 5339) @@ -167,11 +167,18 @@ Token prev = stream.LT(-1); handleEOF((CommonToken)t, (CommonToken)prev); if (!inSingle) { - if (prev == null || prev.getType() != PythonLexer.NEWLINE) { + if (prev == null) { generateNewline(t); + } else if (prev.getType() == PythonLexer.LEADING_WS) { + handleDedents(-1, (CommonToken)t); + generateNewline(t); + } else if (prev.getType() != PythonLexer.NEWLINE) { + generateNewline(t); + handleDedents(-1, (CommonToken)t); } + } else { + handleDedents(-1, (CommonToken)t); } - handleDedents(-1, (CommonToken)t); enqueue(t); } else if (t.getType() == PythonLexer.NEWLINE) { // save NEWLINE in the queue This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2008-09-18 12:37:21
|
Revision: 5340 http://jython.svn.sourceforge.net/jython/?rev=5340&view=rev Author: fwierzbicki Date: 2008-09-18 19:37:19 +0000 (Thu, 18 Sep 2008) Log Message: ----------- Unicode ast node is a kludge from long ago whose time has passed. I forgot to remove it when I unified str node handling in the parser. Modified Paths: -------------- trunk/jython/ast/Python.asdl trunk/jython/src/org/python/antlr/ast/VisitorBase.java trunk/jython/src/org/python/antlr/ast/VisitorIF.java Removed Paths: ------------- trunk/jython/src/org/python/antlr/ast/Unicode.java Modified: trunk/jython/ast/Python.asdl =================================================================== --- trunk/jython/ast/Python.asdl 2008-09-18 19:07:35 UTC (rev 5339) +++ trunk/jython/ast/Python.asdl 2008-09-18 19:37:19 UTC (rev 5340) @@ -68,7 +68,6 @@ | Repr(expr value) | Num(object n) -- a number as a PyObject. | Str(string s) -- need to specify raw, unicode, etc? - | Unicode(string s) -- need to specify raw, unicode, etc? -- other literals? bools? -- the following expression can appear in assignment context Deleted: trunk/jython/src/org/python/antlr/ast/Unicode.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/Unicode.java 2008-09-18 19:07:35 UTC (rev 5339) +++ trunk/jython/src/org/python/antlr/ast/Unicode.java 2008-09-18 19:37:19 UTC (rev 5340) @@ -1,57 +0,0 @@ -// Autogenerated AST node -package org.python.antlr.ast; -import org.python.antlr.PythonTree; -import org.antlr.runtime.CommonToken; -import org.antlr.runtime.Token; -import java.io.DataOutputStream; -import java.io.IOException; - -public class Unicode extends exprType { - public Object s; - - public static final String[] _fields = new String[] {"s"}; - - public Unicode(Token token, Object s) { - super(token); - this.s = s; - } - - public Unicode(int ttype, Token token, Object s) { - super(ttype, token); - this.s = s; - } - - public Unicode(PythonTree tree, Object s) { - super(tree); - this.s = s; - } - - public String toString() { - return "Unicode"; - } - - public String toStringTree() { - StringBuffer sb = new StringBuffer("Unicode("); - sb.append("s="); - sb.append(dumpThis(s)); - sb.append(","); - sb.append(")"); - return sb.toString(); - } - - public <R> R accept(VisitorIF<R> visitor) throws Exception { - return visitor.visitUnicode(this); - } - - public void traverse(VisitorIF visitor) throws Exception { - } - - public int getLineno() { - return getLine(); - } - - public int getCol_offset() { - return getCharPositionInLine(); - } - -} Modified: trunk/jython/src/org/python/antlr/ast/VisitorBase.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/VisitorBase.java 2008-09-18 19:07:35 UTC (rev 5339) +++ trunk/jython/src/org/python/antlr/ast/VisitorBase.java 2008-09-18 19:37:19 UTC (rev 5340) @@ -251,12 +251,6 @@ return ret; } - public R visitUnicode(Unicode node) throws Exception { - R ret = unhandled_node(node); - traverse(node); - return ret; - } - public R visitAttribute(Attribute node) throws Exception { R ret = unhandled_node(node); traverse(node); Modified: trunk/jython/src/org/python/antlr/ast/VisitorIF.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/VisitorIF.java 2008-09-18 19:07:35 UTC (rev 5339) +++ trunk/jython/src/org/python/antlr/ast/VisitorIF.java 2008-09-18 19:37:19 UTC (rev 5340) @@ -43,7 +43,6 @@ public R visitRepr(Repr node) throws Exception; public R visitNum(Num node) throws Exception; public R visitStr(Str node) throws Exception; - public R visitUnicode(Unicode node) throws Exception; public R visitAttribute(Attribute node) throws Exception; public R visitSubscript(Subscript node) throws Exception; public R visitName(Name node) throws Exception; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <le...@us...> - 2008-09-20 02:08:41
|
Revision: 5341 http://jython.svn.sourceforge.net/jython/?rev=5341&view=rev Author: leosoto Date: 2008-09-20 02:08:34 +0000 (Sat, 20 Sep 2008) Log Message: ----------- PyType now exposes __repr__ and __str__ as documented on <http://wiki.python.org/jython/JythonDeveloperGuide/ImplementingStrAndRepr>. This fixes #1131 Modified Paths: -------------- trunk/jython/Lib/test/test_class_jy.py trunk/jython/src/org/python/core/PyType.java Modified: trunk/jython/Lib/test/test_class_jy.py =================================================================== --- trunk/jython/Lib/test/test_class_jy.py 2008-09-18 19:37:19 UTC (rev 5340) +++ trunk/jython/Lib/test/test_class_jy.py 2008-09-20 02:08:34 UTC (rev 5341) @@ -298,7 +298,18 @@ class Bar(object): self.assertEqual(__module__, module_name) +class ClassMetaclassRepr(unittest.TestCase): + """Verifies #1131 is fixed""" + def test_repr_with_metaclass(self): + class FooMetaclass(type): + def __new__(cls, name, bases, attrs): + return super(FooMetaclass, cls).__new__(cls, name, bases, attrs) + class Foo(object): + __metaclass__ = FooMetaclass + self.assertEqual("<class '%s.Foo'>" % __name__, repr(Foo)) + + def test_main(): test_support.run_unittest(ClassGeneralTestCase, ClassNamelessModuleTestCase, @@ -307,6 +318,7 @@ IsDescendentTestCase, JavaClassNamingTestCase, ClassDefinesDunderModule, + ClassMetaclassRepr, ) Modified: trunk/jython/src/org/python/core/PyType.java =================================================================== --- trunk/jython/src/org/python/core/PyType.java 2008-09-18 19:37:19 UTC (rev 5340) +++ trunk/jython/src/org/python/core/PyType.java 2008-09-20 02:08:34 UTC (rev 5341) @@ -1344,7 +1344,8 @@ return numSlots; } - public String toString() { + @ExposedMethod(names = {"__repr__", "__str__"}) + public String type_toString() { String kind; if (!builtin) { kind = "class"; @@ -1358,6 +1359,10 @@ return String.format("<%s '%s'>", kind, getName()); } + public String toString() { + return type_toString(); + } + /** * Raises AttributeError on type objects. The message differs from * PyObject#noAttributeError, to mimic CPython behaviour. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2008-09-24 21:05:45
|
Revision: 5345 http://jython.svn.sourceforge.net/jython/?rev=5345&view=rev Author: fwierzbicki Date: 2008-09-24 21:05:39 +0000 (Wed, 24 Sep 2008) Log Message: ----------- Switched PythonPartial.g from being a "grammar" to being a "parser grammar", plus some additional related cleanup. This fixes all of the missing Token warnings. Thanks to Terrance Parr for suggesting this fix. Modified Paths: -------------- trunk/jython/grammar/PythonPartial.g trunk/jython/src/org/python/core/ParserFacade.java trunk/jython/tests/java/org/python/antlr/PythonPartialTester.java Modified: trunk/jython/grammar/PythonPartial.g =================================================================== --- trunk/jython/grammar/PythonPartial.g 2008-09-24 19:56:28 UTC (rev 5344) +++ trunk/jython/grammar/PythonPartial.g 2008-09-24 21:05:39 UTC (rev 5345) @@ -62,7 +62,7 @@ * an indent but no dedent. */ -grammar PythonPartial; +parser grammar PythonPartial; options { tokenVocab=Python; @@ -124,67 +124,6 @@ } } - -@lexer::header { -package org.python.antlr; -} - -@lexer::members { -/** Handles context-sensitive lexing of implicit line joining such as - * the case where newline is ignored in cases like this: - * a = [3, - * 4] - */ -int implicitLineJoiningLevel = 0; -int startPos=-1; -public boolean eofWhileNested = false; - public Token nextToken() { - while (true) { - state.token = null; - state.channel = Token.DEFAULT_CHANNEL; - state.tokenStartCharIndex = input.index(); - state.tokenStartCharPositionInLine = input.getCharPositionInLine(); - state.tokenStartLine = input.getLine(); - state.text = null; - if ( input.LA(1)==CharStream.EOF ) { - if (implicitLineJoiningLevel > 0) { - eofWhileNested = true; - } - return Token.EOF_TOKEN; - } - try { - mTokens(); - if ( state.token==null ) { - emit(); - } - else if ( state.token==Token.SKIP_TOKEN ) { - continue; - } - return state.token; - } - catch (RecognitionException re) { - throw new ParseException("failed partial", re); - } - } - } - - public void reportError(RecognitionException e) { - System.err.print("[LEXER REPORTING] "); - // if we've already reported an error and have not matched a token - // yet successfully, don't report any errors. - if ( state.errorRecovery ) { - System.err.print("[SPURIOUS] "); - return; - } - state.syntaxErrors++; // don't count spurious - state.errorRecovery = true; - - displayRecognitionError(this.getTokenNames(), e); - } - - -} - single_input : NEWLINE | simple_stmt | compound_stmt NEWLINE? Modified: trunk/jython/src/org/python/core/ParserFacade.java =================================================================== --- trunk/jython/src/org/python/core/ParserFacade.java 2008-09-24 19:56:28 UTC (rev 5344) +++ trunk/jython/src/org/python/core/ParserFacade.java 2008-09-24 21:05:39 UTC (rev 5345) @@ -26,7 +26,7 @@ import org.python.antlr.PythonTree; import org.python.antlr.PythonTree; import org.python.antlr.PythonLexer; -import org.python.antlr.PythonPartialParser; +import org.python.antlr.PythonPartial; import org.python.antlr.PythonTokenSource; import org.python.antlr.ast.modType; import org.python.core.io.StreamIO; @@ -172,7 +172,7 @@ CommonTokenStream tokens = new CommonTokenStream(lexer); PythonTokenSource indentedSource = new PythonTokenSource(tokens, filename); tokens = new CommonTokenStream(indentedSource); - PythonPartialParser parser = new PythonPartialParser(tokens); + PythonPartial parser = new PythonPartial(tokens); if (kind.equals("single")) { parser.single_input(); } else if (kind.equals("eval")) { Modified: trunk/jython/tests/java/org/python/antlr/PythonPartialTester.java =================================================================== --- trunk/jython/tests/java/org/python/antlr/PythonPartialTester.java 2008-09-24 19:56:28 UTC (rev 5344) +++ trunk/jython/tests/java/org/python/antlr/PythonPartialTester.java 2008-09-24 21:05:39 UTC (rev 5345) @@ -19,7 +19,7 @@ //PythonTokenSource indentedSource = new PythonTokenSource(tokens); PythonTokenSource indentedSource = new PythonTokenSource(tokens, "<test>"); tokens = new CommonTokenStream(indentedSource); - PythonPartialParser parser = new PythonPartialParser(tokens); + PythonPartial parser = new PythonPartial(tokens); parser.single_input(); System.out.println("SUCCEED"); } catch (ParseException e) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2008-10-01 02:01:37
|
Revision: 5353 http://jython.svn.sourceforge.net/jython/?rev=5353&view=rev Author: fwierzbicki Date: 2008-10-01 02:01:33 +0000 (Wed, 01 Oct 2008) Log Message: ----------- Added castSlice and castSlices to allow optional error nodes for sliceType. Also renamed makeExpr(s) and makeStmt(s) to castExpr(s) and castStmt(s). 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 2008-09-26 17:01:58 UTC (rev 5352) +++ trunk/jython/grammar/Python.g 2008-10-01 02:01:33 UTC (rev 5353) @@ -251,7 +251,9 @@ errorHandler.reportError(this, nva); errorHandler.recover(this, nva); // throw out current char and try again } catch (FailedPredicateException fp) { - //XXX: added this for failed STRINGPART + //XXX: added this for failed STRINGPART -- the FailedPredicateException + // hides a NoViableAltException. This should be the only + // FailedPredicateException that gets thrown by the lexer. errorHandler.reportError(this, fp); errorHandler.recover(this, fp); // throw out current char and try again } catch (RecognitionException re) { @@ -274,10 +276,10 @@ mtype = new Interactive($single_input.start, new stmtType[0]); } | simple_stmt NEWLINE* EOF { - mtype = new Interactive($single_input.start, actions.makeStmts($simple_stmt.stypes)); + mtype = new Interactive($single_input.start, actions.castStmts($simple_stmt.stypes)); } | compound_stmt NEWLINE+ EOF { - mtype = new Interactive($single_input.start, actions.makeStmts($compound_stmt.tree)); + mtype = new Interactive($single_input.start, actions.castStmts($compound_stmt.tree)); } ; @@ -303,7 +305,7 @@ : (NEWLINE | stmt {stypes.addAll($stmt.stypes);} )* EOF { - mtype = new Module($file_input.start, actions.makeStmts(stypes)); + mtype = new Module($file_input.start, actions.castStmts(stypes)); } ; @@ -316,7 +318,7 @@ $eval_input.tree = mtype; } : LEADING_WS? (NEWLINE)* testlist[expr_contextType.Load] (NEWLINE)* EOF { - mtype = new Expression($eval_input.start, actions.makeExpr($testlist.tree)); + mtype = new Expression($eval_input.start, actions.castExpr($testlist.tree)); } ; @@ -428,7 +430,7 @@ } : fpdef[expr_contextType.Param] (ASSIGN test[expr_contextType.Load])? { - $etype = actions.makeExpr($fpdef.tree); + $etype = actions.castExpr($fpdef.tree); if ($ASSIGN != null) { defaults.add($test.tree); } else if (!defaults.isEmpty()) { @@ -466,12 +468,12 @@ //fpdef: NAME | '(' fplist ')' fpdef[expr_contextType ctype] @after { - actions.checkAssign(actions.makeExpr($fpdef.tree)); + actions.checkAssign(actions.castExpr($fpdef.tree)); } : NAME -> ^(NAME<Name>[$NAME, $NAME.text, ctype]) | (LPAREN fpdef[null] COMMA) => LPAREN fplist RPAREN - -> ^(LPAREN<Tuple>[$fplist.start, actions.makeExprs($fplist.etypes), expr_contextType.Store]) + -> ^(LPAREN<Tuple>[$fplist.start, actions.castExprs($fplist.etypes), expr_contextType.Store]) | LPAREN fplist RPAREN -> fplist ; @@ -533,31 +535,31 @@ : ((testlist[null] augassign) => lhs=testlist[expr_contextType.AugStore] ( (aay=augassign y1=yield_expr { - actions.checkAssign(actions.makeExpr($lhs.tree)); - stype = new AugAssign($lhs.tree, actions.makeExpr($lhs.tree), $aay.op, actions.makeExpr($y1.tree)); + actions.checkAssign(actions.castExpr($lhs.tree)); + stype = new AugAssign($lhs.tree, actions.castExpr($lhs.tree), $aay.op, actions.castExpr($y1.tree)); } ) | (aat=augassign rhs=testlist[expr_contextType.Load] { - actions.checkAssign(actions.makeExpr($lhs.tree)); - stype = new AugAssign($lhs.tree, actions.makeExpr($lhs.tree), $aat.op, actions.makeExpr($rhs.tree)); + actions.checkAssign(actions.castExpr($lhs.tree)); + stype = new AugAssign($lhs.tree, actions.castExpr($lhs.tree), $aat.op, actions.castExpr($rhs.tree)); } ) ) | (testlist[null] ASSIGN) => lhs=testlist[expr_contextType.Store] ( | ((at=ASSIGN t+=testlist[expr_contextType.Store])+ - -> ^(ASSIGN<Assign>[$lhs.start, actions.makeAssignTargets(actions.makeExpr($lhs.tree), $t), + -> ^(ASSIGN<Assign>[$lhs.start, actions.makeAssignTargets(actions.castExpr($lhs.tree), $t), actions.makeAssignValue($t)]) ) | ((ay=ASSIGN y2+=yield_expr)+ - -> ^(ASSIGN<Assign>[$lhs.start, actions.makeAssignTargets(actions.makeExpr($lhs.tree), $y2), + -> ^(ASSIGN<Assign>[$lhs.start, actions.makeAssignTargets(actions.castExpr($lhs.tree), $y2), actions.makeAssignValue($y2)]) ) ) | lhs=testlist[expr_contextType.Load] { - stype = new Expr($lhs.start, actions.makeExpr($lhs.tree)); + stype = new Expr($lhs.start, actions.castExpr($lhs.tree)); } ) ; @@ -584,9 +586,9 @@ print_stmt : PRINT (t1=printlist - -> ^(PRINT<Print>[$PRINT, null, actions.makeExprs($t1.elts), $t1.newline]) + -> ^(PRINT<Print>[$PRINT, null, actions.castExprs($t1.elts), $t1.newline]) | RIGHTSHIFT t2=printlist2 - -> ^(PRINT<Print>[$PRINT, actions.makeExpr($t2.elts.get(0)), actions.makeExprs($t2.elts, 1), $t2.newline]) + -> ^(PRINT<Print>[$PRINT, actions.castExpr($t2.elts.get(0)), actions.castExprs($t2.elts, 1), $t2.newline]) | -> ^(PRINT<Print>[$PRINT, null, new exprType[0\], false]) ) @@ -636,7 +638,7 @@ //del_stmt: 'del' exprlist del_stmt : DELETE del_list - -> ^(DELETE<Delete>[$DELETE, actions.makeExprs($del_list.etypes)]) + -> ^(DELETE<Delete>[$DELETE, actions.castExprs($del_list.etypes)]) ; //pass_stmt: 'pass' @@ -670,7 +672,7 @@ return_stmt : RETURN (testlist[expr_contextType.Load] - -> ^(RETURN<Return>[$RETURN, actions.makeExpr($testlist.tree)]) + -> ^(RETURN<Return>[$RETURN, actions.castExpr($testlist.tree)]) | -> ^(RETURN<Return>[$RETURN, null]) ) @@ -678,14 +680,14 @@ //yield_stmt: yield_expr yield_stmt - : yield_expr -> ^(YIELD<Expr>[$yield_expr.start, actions.makeExpr($yield_expr.tree)]) + : yield_expr -> ^(YIELD<Expr>[$yield_expr.start, actions.castExpr($yield_expr.tree)]) ; //raise_stmt: 'raise' [test [',' test [',' test]]] raise_stmt : RAISE (t1=test[expr_contextType.Load] (COMMA t2=test[expr_contextType.Load] (COMMA t3=test[expr_contextType.Load])?)?)? - -> ^(RAISE<Raise>[$RAISE, actions.makeExpr($t1.tree), actions.makeExpr($t2.tree), actions.makeExpr($t3.tree)]) + -> ^(RAISE<Raise>[$RAISE, actions.castExpr($t1.tree), actions.castExpr($t2.tree), actions.castExpr($t3.tree)]) ; //import_stmt: import_name | import_from @@ -778,14 +780,14 @@ : EXEC expr[expr_contextType.Load] (IN t1=test[expr_contextType.Load] (COMMA t2=test[expr_contextType.Load])?)? { - stype = new Exec($EXEC, actions.makeExpr($expr.tree), actions.makeExpr($t1.tree), actions.makeExpr($t2.tree)); + stype = new Exec($EXEC, actions.castExpr($expr.tree), actions.castExpr($t1.tree), actions.castExpr($t2.tree)); } ; //assert_stmt: 'assert' test [',' test] assert_stmt : ASSERT t1=test[expr_contextType.Load] (COMMA t2=test[expr_contextType.Load])? - -> ^(ASSERT<Assert>[$ASSERT, actions.makeExpr($t1.tree), actions.makeExpr($t2.tree)]) + -> ^(ASSERT<Assert>[$ASSERT, actions.castExpr($t1.tree), actions.castExpr($t2.tree)]) ; //compound_stmt: if_stmt | while_stmt | for_stmt | try_stmt | funcdef | classdef @@ -802,7 +804,7 @@ //if_stmt: 'if' test ':' suite ('elif' test ':' suite)* ['else' ':' suite] if_stmt : IF test[expr_contextType.Load] COLON ifsuite=suite elif_clause[$test.start]? - -> ^(IF<If>[$IF, actions.makeExpr($test.tree), actions.makeStmts($ifsuite.stypes), + -> ^(IF<If>[$IF, actions.castExpr($test.tree), actions.castStmts($ifsuite.stypes), actions.makeElse($elif_clause.stypes, $elif_clause.tree)]) ; @@ -813,9 +815,9 @@ } | ELIF test[expr_contextType.Load] COLON suite (e2=elif_clause[$iftest] - -> ^(ELIF<If>[$iftest, actions.makeExpr($test.tree), actions.makeStmts($suite.stypes), actions.makeElse($e2.stypes, $e2.tree)]) + -> ^(ELIF<If>[$iftest, actions.castExpr($test.tree), actions.castStmts($suite.stypes), actions.makeElse($e2.stypes, $e2.tree)]) | - -> ^(ELIF<If>[$iftest, actions.makeExpr($test.tree), actions.makeStmts($suite.stypes), new stmtType[0\]]) + -> ^(ELIF<If>[$iftest, actions.castExpr($test.tree), actions.castStmts($suite.stypes), new stmtType[0\]]) ) ; @@ -836,7 +838,7 @@ } : WHILE test[expr_contextType.Load] COLON s1=suite (ORELSE COLON s2=suite)? { - stype = actions.makeWhile($WHILE, actions.makeExpr($test.tree), $s1.stypes, $s2.stypes); + stype = actions.makeWhile($WHILE, actions.castExpr($test.tree), $s1.stypes, $s2.stypes); } ; @@ -851,7 +853,7 @@ : FOR exprlist[expr_contextType.Store] IN testlist[expr_contextType.Load] COLON s1=suite (ORELSE COLON s2=suite)? { - stype = actions.makeFor($FOR, $exprlist.etype, actions.makeExpr($testlist.tree), $s1.stypes, $s2.stypes); + stype = actions.makeFor($FOR, $exprlist.etype, actions.castExpr($testlist.tree), $s1.stypes, $s2.stypes); } ; @@ -889,8 +891,8 @@ } : WITH test[expr_contextType.Load] (with_var)? COLON suite { - stype = new With($WITH, actions.makeExpr($test.tree), $with_var.etype, - actions.makeStmts($suite.stypes)); + stype = new With($WITH, actions.castExpr($test.tree), $with_var.etype, + actions.castStmts($suite.stypes)); } ; @@ -898,15 +900,15 @@ with_var returns [exprType etype] : (AS | NAME) expr[expr_contextType.Store] { - $etype = actions.makeExpr($expr.tree); + $etype = actions.castExpr($expr.tree); } ; //except_clause: 'except' [test [',' test]] except_clause : EXCEPT (t1=test[expr_contextType.Load] (COMMA t2=test[expr_contextType.Store])?)? COLON suite - -> ^(EXCEPT<excepthandlerType>[$EXCEPT, actions.makeExpr($t1.tree), actions.makeExpr($t2.tree), - actions.makeStmts($suite.stypes), $EXCEPT.getLine(), $EXCEPT.getCharPositionInLine()]) + -> ^(EXCEPT<excepthandlerType>[$EXCEPT, actions.castExpr($t1.tree), actions.castExpr($t2.tree), + actions.castStmts($suite.stypes), $EXCEPT.getLine(), $EXCEPT.getCharPositionInLine()]) ; //suite: simple_stmt | NEWLINE INDENT stmt+ DEDENT @@ -930,7 +932,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>[$o1.start, actions.makeExpr($o2.tree), actions.makeExpr($o1.tree), actions.makeExpr($e.tree)]) + -> ^(IF<IfExp>[$o1.start, actions.castExpr($o2.tree), actions.castExpr($o1.tree), actions.castExpr($e.tree)]) | -> or_test ) @@ -970,7 +972,7 @@ //not_test: 'not' not_test | comparison not_test[expr_contextType ctype] : NOT nt=not_test[ctype] - -> ^(NOT<UnaryOp>[$NOT, unaryopType.Not, actions.makeExpr($nt.tree)]) + -> ^(NOT<UnaryOp>[$NOT, unaryopType.Not, actions.castExpr($nt.tree)]) | comparison[ctype] ; @@ -981,8 +983,8 @@ } @after { if (!cmps.isEmpty()) { - $comparison.tree = new Compare($left.start, actions.makeExpr($left.tree), actions.makeCmpOps(cmps), - actions.makeExprs($right)); + $comparison.tree = new Compare($left.start, actions.castExpr($left.tree), actions.makeCmpOps(cmps), + actions.castExprs($right)); } } : left=expr[ctype] @@ -1140,7 +1142,7 @@ : PLUS p=factor {$etype = new UnaryOp($PLUS, unaryopType.UAdd, $p.etype);} | MINUS m=factor {$etype = actions.negate($MINUS, $m.etype);} | TILDE t=factor {$etype = new UnaryOp($TILDE, unaryopType.Invert, $t.etype);} - | power {$etype = actions.makeExpr($power.tree);} + | power {$etype = actions.castExpr($power.tree);} ; //power: atom trailer* ['**' factor] @@ -1151,7 +1153,7 @@ : atom (t+=trailer[$atom.start, $atom.tree])* (options {greedy=true;}:d=DOUBLESTAR factor)? { //XXX: This could be better. - $etype = actions.makeExpr($atom.tree); + $etype = actions.castExpr($atom.tree); if ($t != null) { for(Object o : $t) { if ($etype instanceof Context) { @@ -1204,14 +1206,14 @@ RBRACK | LCURLY (dictmaker - -> ^(LCURLY<Dict>[$LCURLY, actions.makeExprs($dictmaker.keys), - actions.makeExprs($dictmaker.values)]) + -> ^(LCURLY<Dict>[$LCURLY, actions.castExprs($dictmaker.keys), + actions.castExprs($dictmaker.values)]) | -> ^(LCURLY<Dict>[$LCURLY, new exprType[0\], new exprType[0\]]) ) RCURLY | lb=BACKQUOTE testlist[expr_contextType.Load] rb=BACKQUOTE - -> ^(BACKQUOTE<Repr>[$lb, actions.makeExpr($testlist.tree)]) + -> ^(BACKQUOTE<Repr>[$lb, actions.castExpr($testlist.tree)]) | NAME -> ^(NAME<Name>[$NAME, $NAME.text, $expr::ctype]) | INT @@ -1241,11 +1243,11 @@ Collections.reverse(gens); comprehensionType[] c = (comprehensionType[])gens.toArray(new comprehensionType[gens.size()]); - etype = new ListComp($listmaker.start, actions.makeExpr($t.get(0)), c); + etype = new ListComp($listmaker.start, actions.castExpr($t.get(0)), c); } | (options {greedy=true;}:COMMA t+=test[$expr::ctype])* { - etype = new org.python.antlr.ast.List($lbrack, actions.makeExprs($t), $expr::ctype); + etype = new org.python.antlr.ast.List($lbrack, actions.castExprs($t), $expr::ctype); } ) (COMMA)? ; @@ -1264,18 +1266,18 @@ : t+=test[$expr::ctype] ( ((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]) + ^(COMMA<Tuple>[$testlist_gexp.start, actions.castExprs($t), $expr::ctype]) -> test ) | (gen_for[gens] { Collections.reverse(gens); comprehensionType[] c = (comprehensionType[])gens.toArray(new comprehensionType[gens.size()]); - exprType e = actions.makeExpr($t.get(0)); + exprType e = actions.castExpr($t.get(0)); if (e instanceof Context) { ((Context)e).setContext(expr_contextType.Load); } - etype = new GeneratorExp($testlist_gexp.start, actions.makeExpr($t.get(0)), c); + etype = new GeneratorExp($testlist_gexp.start, actions.castExpr($t.get(0)), c); } ) ) @@ -1295,7 +1297,7 @@ if (a == null) { a = new argumentsType($LAMBDA, new exprType[0], null, null, new exprType[0]); } - etype = new Lambda($LAMBDA, a, actions.makeExpr($test.tree)); + etype = new Lambda($LAMBDA, a, actions.castExpr($test.tree)); } ; @@ -1303,16 +1305,16 @@ trailer [Token begin, PythonTree tree] : LPAREN (arglist - -> ^(LPAREN<Call>[$begin, actions.makeExpr($tree), actions.makeExprs($arglist.args), + -> ^(LPAREN<Call>[$begin, actions.castExpr($tree), actions.castExprs($arglist.args), actions.makeKeywords($arglist.keywords), $arglist.starargs, $arglist.kwargs]) | - -> ^(LPAREN<Call>[$begin, actions.makeExpr($tree), new exprType[0\], new keywordType[0\], null, null]) + -> ^(LPAREN<Call>[$begin, actions.castExpr($tree), new exprType[0\], new keywordType[0\], null, null]) ) RPAREN | LBRACK subscriptlist[$begin] RBRACK - -> ^(LBRACK<Subscript>[$begin, actions.makeExpr($tree), (sliceType)$subscriptlist.tree, $expr::ctype]) + -> ^(LBRACK<Subscript>[$begin, actions.castExpr($tree), actions.castSlice($subscriptlist.tree), $expr::ctype]) | DOT attr - -> ^(DOT<Attribute>[$begin, actions.makeExpr($tree), $attr.text, $expr::ctype]) + -> ^(DOT<Attribute>[$begin, actions.castExpr($tree), $attr.text, $expr::ctype]) ; //subscriptlist: subscript (',' subscript)* [','] @@ -1349,7 +1351,7 @@ $sltype = actions.makeSubscript(null, $c2, $upper2.tree, $sliceop.tree); } | test[expr_contextType.Load] - -> ^(LPAREN<Index>[$test.start, actions.makeExpr($test.tree)]) + -> ^(LPAREN<Index>[$test.start, actions.castExpr($test.tree)]) ; //sliceop: ':' [test] @@ -1364,11 +1366,11 @@ exprlist[expr_contextType ctype] returns [exprType etype] : (expr[null] COMMA) => e+=expr[ctype] (options {k=2;}: COMMA e+=expr[ctype])* (COMMA)? { - $etype = new Tuple($exprlist.start, actions.makeExprs($e), ctype); + $etype = new Tuple($exprlist.start, actions.castExprs($e), ctype); } | expr[ctype] { - $etype = actions.makeExpr($expr.tree); + $etype = actions.castExpr($expr.tree); } ; @@ -1385,7 +1387,7 @@ testlist[expr_contextType ctype] : (test[null] COMMA) => t+=test[ctype] (options {k=2;}: COMMA t+=test[ctype])* (COMMA)? - -> ^(COMMA<Tuple>[$testlist.start, actions.makeExprs($t), ctype]) + -> ^(COMMA<Tuple>[$testlist.start, actions.castExprs($t), ctype]) | test[ctype] ; @@ -1410,8 +1412,8 @@ } : CLASS NAME (LPAREN testlist[expr_contextType.Load]? RPAREN)? COLON suite { - stype = new ClassDef($CLASS, actions.cantBeNone($NAME), actions.makeBases(actions.makeExpr($testlist.tree)), - actions.makeStmts($suite.stypes)); + stype = new ClassDef($CLASS, actions.cantBeNone($NAME), actions.makeBases(actions.castExpr($testlist.tree)), + actions.castStmts($suite.stypes)); } ; @@ -1434,17 +1436,17 @@ } $args=arguments; $keywords=kws; - $starargs=actions.makeExpr($s.tree); - $kwargs=actions.makeExpr($k.tree); + $starargs=actions.castExpr($s.tree); + $kwargs=actions.castExpr($k.tree); } | STAR s=test[expr_contextType.Load] (COMMA DOUBLESTAR k=test[expr_contextType.Load])? { - $starargs=actions.makeExpr($s.tree); - $kwargs=actions.makeExpr($k.tree); + $starargs=actions.castExpr($s.tree); + $kwargs=actions.castExpr($k.tree); } | DOUBLESTAR k=test[expr_contextType.Load] { - $kwargs=actions.makeExpr($k.tree); + $kwargs=actions.castExpr($k.tree); } ; @@ -1453,7 +1455,7 @@ : t1=test[expr_contextType.Load] ((ASSIGN t2=test[expr_contextType.Load]) { - $kws.add(new exprType[]{actions.makeExpr($t1.tree), actions.makeExpr($t2.tree)}); + $kws.add(new exprType[]{actions.castExpr($t1.tree), actions.castExpr($t2.tree)}); } | gen_for[$gens] { @@ -1463,7 +1465,7 @@ $genarg = true; Collections.reverse($gens); comprehensionType[] c = (comprehensionType[])$gens.toArray(new comprehensionType[$gens.size()]); - arguments.add(new GeneratorExp($t1.start, actions.makeExpr($t1.tree), c)); + arguments.add(new GeneratorExp($t1.start, actions.castExpr($t1.tree), c)); } | { if (kws.size() > 0) { @@ -1492,7 +1494,7 @@ } else { e = new exprType[0]; } - gens.add(new comprehensionType($FOR, $exprlist.etype, actions.makeExpr($testlist.tree), e)); + gens.add(new comprehensionType($FOR, $exprlist.etype, actions.castExpr($testlist.tree), e)); } ; @@ -1500,7 +1502,7 @@ list_if[List gens] returns [exprType etype] : IF test[expr_contextType.Load] (list_iter[gens])? { - $etype = actions.makeExpr($test.tree); + $etype = actions.castExpr($test.tree); } ; @@ -1523,7 +1525,7 @@ } else { e = new exprType[0]; } - gens.add(new comprehensionType($FOR, $exprlist.etype, actions.makeExpr($or_test.tree), e)); + gens.add(new comprehensionType($FOR, $exprlist.etype, actions.castExpr($or_test.tree), e)); } ; @@ -1531,14 +1533,14 @@ gen_if[List gens] returns [exprType etype] : IF test[expr_contextType.Load] gen_iter[gens]? { - $etype = actions.makeExpr($test.tree); + $etype = actions.castExpr($test.tree); } ; //yield_expr: 'yield' [testlist] yield_expr : YIELD testlist[expr_contextType.Load]? - -> ^(YIELD<Yield>[$YIELD, actions.makeExpr($testlist.tree)]) + -> ^(YIELD<Yield>[$YIELD, actions.castExpr($testlist.tree)]) ; AS : 'as' ; Modified: trunk/jython/src/org/python/antlr/GrammarActions.java =================================================================== --- trunk/jython/src/org/python/antlr/GrammarActions.java 2008-09-26 17:01:58 UTC (rev 5352) +++ trunk/jython/src/org/python/antlr/GrammarActions.java 2008-10-01 02:01:33 UTC (rev 5353) @@ -151,7 +151,7 @@ errorHandler.error("Generator expression must be parenthesized if not sole argument", t); } - exprType makeExpr(Object o) { + exprType castExpr(Object o) { if (o instanceof exprType) { return (exprType)o; } @@ -162,11 +162,11 @@ } - exprType[] makeExprs(List exprs) { - return makeExprs(exprs, 0); + exprType[] castExprs(List exprs) { + return castExprs(exprs, 0); } - exprType[] makeExprs(List exprs, int start) { + exprType[] castExprs(List exprs, int start) { if (exprs != null) { List<exprType> result = new ArrayList<exprType>(); for (int i=start; i<exprs.size(); i++) { @@ -184,14 +184,14 @@ stmtType[] makeElse(List elseSuite, PythonTree elif) { if (elseSuite != null) { - return makeStmts(elseSuite); + return castStmts(elseSuite); } else if (elif == null) { return new stmtType[0]; } return new stmtType[]{(stmtType)elif}; } - stmtType makeStmt(Object o) { + stmtType castStmt(Object o) { if (o instanceof stmtType) { return (stmtType)o; } else if (o instanceof PythonParser.stmt_return) { @@ -202,15 +202,15 @@ return null; } - stmtType[] makeStmts(PythonTree t) { + stmtType[] castStmts(PythonTree t) { return new stmtType[]{(stmtType)t}; } - stmtType[] makeStmts(List stmts) { + stmtType[] castStmts(List stmts) { if (stmts != null) { List<stmtType> result = new ArrayList<stmtType>(); for (Object o:stmts) { - result.add(makeStmt(o)); + result.add(castStmt(o)); } return (stmtType[])result.toArray(new stmtType[result.size()]); } @@ -231,8 +231,8 @@ if (test == null) { return errorHandler.errorStmt(new PythonTree(t)); } - stmtType[] o = makeStmts(orelse); - stmtType[] b = makeStmts(body); + stmtType[] o = castStmts(orelse); + stmtType[] b = castStmts(body); return new While(t, test, b, o); } @@ -242,27 +242,27 @@ } cantBeNone(target); - stmtType[] o = makeStmts(orelse); - stmtType[] b = makeStmts(body); + stmtType[] o = castStmts(orelse); + stmtType[] b = castStmts(body); return new For(t, target, iter, b, o); } stmtType makeTryExcept(Token t, List body, List handlers, List orelse, List finBody) { - stmtType[] b = makeStmts(body); + stmtType[] b = castStmts(body); excepthandlerType[] e = (excepthandlerType[])handlers.toArray(new excepthandlerType[handlers.size()]); - stmtType[] o = makeStmts(orelse); + stmtType[] o = castStmts(orelse); stmtType te = new TryExcept(t, b, e, o); if (finBody == null) { return te; } - stmtType[] f = makeStmts(finBody); + stmtType[] f = castStmts(finBody); stmtType[] mainBody = new stmtType[]{te}; return new TryFinally(t, mainBody, f); } TryFinally makeTryFinally(Token t, List body, List finBody) { - stmtType[] b = makeStmts(body); - stmtType[] f = makeStmts(finBody); + stmtType[] b = castStmts(body); + stmtType[] f = castStmts(finBody); return new TryFinally(t, b, f); } @@ -277,8 +277,8 @@ } else { a = new argumentsType(t, new exprType[0], null, null, new exprType[0]); } - stmtType[] s = makeStmts(funcStatements); - exprType[] d = makeExprs(decorators); + stmtType[] s = castStmts(funcStatements); + exprType[] d = castExprs(decorators); return new FunctionDef(t, nameToken.getText(), a, s, d); } @@ -287,7 +287,7 @@ checkAssign(lhs); e[0] = lhs; for(int i=0;i<rhs.size() - 1;i++) { - exprType r = makeExpr(rhs.get(i)); + exprType r = castExpr(rhs.get(i)); checkAssign(r); e[i + 1] = r; } @@ -295,7 +295,7 @@ } exprType makeAssignValue(List rhs) { - exprType value = makeExpr(rhs.get(rhs.size() -1)); + exprType value = castExpr(rhs.get(rhs.size() -1)); recurseSetContext(value, expr_contextType.Load); return value; } @@ -320,8 +320,8 @@ argumentsType makeArgumentsType(Token t, List params, Token snameToken, Token knameToken, List defaults) { - exprType[] p = makeExprs(params); - exprType[] d = makeExprs(defaults); + exprType[] p = castExprs(params); + exprType[] d = castExprs(defaults); String s; String k; if (snameToken == null) { @@ -338,7 +338,7 @@ } exprType[] extractArgs(List args) { - return makeExprs(args); + return castExprs(args); } keywordType[] makeKeywords(List args) { @@ -472,7 +472,7 @@ //FROM Walker: modType makeMod(PythonTree t, List stmts) { - stmtType[] s = makeStmts(stmts); + stmtType[] s = castStmts(stmts); return new Module(t, s); } @@ -481,7 +481,7 @@ } modType makeInteractive(PythonTree t, List stmts) { - stmtType[] s = makeStmts(stmts); + stmtType[] s = castStmts(stmts); return new Interactive(t, s); } @@ -490,16 +490,16 @@ return errorHandler.errorStmt(t); } cantBeNone(nameToken); - exprType[] b = makeExprs(bases); - stmtType[] s = makeStmts(body); + exprType[] b = castExprs(bases); + stmtType[] s = castStmts(body); return new ClassDef(t, nameToken.getText(), b, s); } argumentsType makeArgumentsType(PythonTree t, List params, PythonTree snameToken, PythonTree knameToken, List defaults) { - exprType[] p = makeExprs(params); - exprType[] d = makeExprs(defaults); + exprType[] p = castExprs(params); + exprType[] d = castExprs(defaults); String s; String k; if (snameToken == null) { @@ -516,22 +516,22 @@ } stmtType makeTryExcept(PythonTree t, List body, List handlers, List orelse, List finBody) { - stmtType[] b = makeStmts(body); + stmtType[] b = castStmts(body); excepthandlerType[] e = (excepthandlerType[])handlers.toArray(new excepthandlerType[handlers.size()]); - stmtType[] o = makeStmts(orelse); + stmtType[] o = castStmts(orelse); stmtType te = new TryExcept(t, b, e, o); if (finBody == null) { return te; } - stmtType[] f = makeStmts(finBody); + stmtType[] f = castStmts(finBody); stmtType[] mainBody = new stmtType[]{te}; return new TryFinally(t, mainBody, f); } TryFinally makeTryFinally(PythonTree t, List body, List finBody) { - stmtType[] b = makeStmts(body); - stmtType[] f = makeStmts(finBody); + stmtType[] b = castStmts(body); + stmtType[] f = castStmts(finBody); return new TryFinally(t, b, f); } @@ -539,8 +539,8 @@ if (test == null) { return errorHandler.errorStmt(t); } - stmtType[] o = makeStmts(orelse); - stmtType[] b = makeStmts(body); + stmtType[] o = castStmts(orelse); + stmtType[] b = castStmts(body); return new If(t, test, b, o); } @@ -548,8 +548,8 @@ if (test == null) { return errorHandler.errorStmt(t); } - stmtType[] o = makeStmts(orelse); - stmtType[] b = makeStmts(body); + stmtType[] o = castStmts(orelse); + stmtType[] b = castStmts(body); return new While(t, test, b, o); } @@ -558,8 +558,8 @@ return errorHandler.errorStmt(t); } cantBeNone(target); - stmtType[] o = makeStmts(orelse); - stmtType[] b = makeStmts(body); + stmtType[] o = castStmts(orelse); + stmtType[] b = castStmts(body); return new For(t, target, iter, b, o); } @@ -572,7 +572,7 @@ return errorHandler.errorExpr(new PythonTree(t)); } keywordType[] k = makeKeywords(keywords); - exprType[] a = makeExprs(args); + exprType[] a = castExprs(args); return new Call(t, func, a, k, starargs, kwargs); } @@ -661,18 +661,18 @@ exprType e = null; exprType o = null; if (lower != null) { - s = makeExpr(lower); + s = castExpr(lower); } if (colon != null) { isSlice = true; if (upper != null) { - e = makeExpr(upper); + e = castExpr(upper); } } if (sliceop != null) { isSlice = true; if (sliceop != null) { - o = makeExpr(sliceop); + o = castExpr(sliceop); } else { o = new Name(sliceop, "None", expr_contextType.Load); } @@ -705,28 +705,46 @@ List values = new ArrayList(); values.add(left); values.addAll(right); - return new BoolOp(left, op, makeExprs(values)); + return new BoolOp(left, op, castExprs(values)); } BinOp makeBinOp(PythonTree left, operatorType op, List rights) { - BinOp current = new BinOp(left, makeExpr(left), op, makeExpr(rights.get(0))); + BinOp current = new BinOp(left, castExpr(left), op, castExpr(rights.get(0))); for (int i = 1; i< rights.size(); i++) { - exprType right = makeExpr(rights.get(i)); + exprType right = castExpr(rights.get(i)); current = new BinOp(left, current, op, right); } return current; } BinOp makeBinOp(PythonTree left, List ops, List rights) { - BinOp current = new BinOp(left, makeExpr(left), (operatorType)ops.get(0), makeExpr(rights.get(0))); + BinOp current = new BinOp(left, castExpr(left), (operatorType)ops.get(0), castExpr(rights.get(0))); for (int i = 1; i< rights.size(); i++) { - exprType right = makeExpr(rights.get(i)); + exprType right = castExpr(rights.get(i)); operatorType op = (operatorType)ops.get(i); current = new BinOp(left, current, op, right); } return current; } + sliceType[] castSlices(List slices) { + if (slices != null) { + List<sliceType> result = new ArrayList<sliceType>(); + for (Object o:slices) { + result.add(castSlice(o)); + } + return (sliceType[])result.toArray(new sliceType[result.size()]); + } + return new sliceType[0]; + } + + sliceType castSlice(Object o) { + if (o instanceof sliceType) { + return (sliceType)o; + } + return errorHandler.errorSlice((PythonTree)o); + } + sliceType makeSliceType(Token begin, Token c1, Token c2, List sltypes) { boolean isTuple = false; if (c1 != null || c2 != null) { @@ -753,12 +771,12 @@ s = new Index(begin, t); } } else if (sltypes.size() == 1) { - s = (sliceType)sltypes.get(0); + s = castSlice(sltypes.get(0)); } else if (sltypes.size() != 0) { extslice = true; } if (extslice) { - sliceType[] st = (sliceType[])sltypes.toArray(new sliceType[sltypes.size()]); + sliceType[] st = castSlices(sltypes);//.toArray(new sliceType[sltypes.size()]); s = new ExtSlice(begin, st); } return s; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <zy...@us...> - 2008-10-06 03:13:20
|
Revision: 5360 http://jython.svn.sourceforge.net/jython/?rev=5360&view=rev Author: zyasoft Date: 2008-10-06 03:12:34 +0000 (Mon, 06 Oct 2008) Log Message: ----------- Removed older version of random.py in favor of CPythonLib's; added _random.getrandbits (in PyRandom); modified test_random so that it doesn't test implementation specific aspects of the random generator, since we actually use java.util.Random, not the Mersenne Twister. Modified Paths: -------------- trunk/jython/Lib/test/test_random.py trunk/jython/src/org/python/modules/random/PyRandom.java Removed Paths: ------------- trunk/jython/Lib/random.py Deleted: trunk/jython/Lib/random.py =================================================================== --- trunk/jython/Lib/random.py 2008-10-06 03:02:29 UTC (rev 5359) +++ trunk/jython/Lib/random.py 2008-10-06 03:12:34 UTC (rev 5360) @@ -1,880 +0,0 @@ -"""Random variable generators. - - integers - -------- - uniform within range - - sequences - --------- - pick random element - pick random sample - generate random permutation - - distributions on the real line: - ------------------------------ - uniform - normal (Gaussian) - lognormal - negative exponential - gamma - beta - pareto - Weibull - - distributions on the circle (angles 0 to 2pi) - --------------------------------------------- - circular uniform - von Mises - -General notes on the underlying Mersenne Twister core generator: - -* The period is 2**19937-1. -* It is one of the most extensively tested generators in existence -* Without a direct way to compute N steps forward, the - semantics of jumpahead(n) are weakened to simply jump - to another distant state and rely on the large period - to avoid overlapping sequences. -* The random() method is implemented in C, executes in - a single Python step, and is, therefore, threadsafe. - -""" -import time -from types import BuiltinMethodType as _BuiltinMethodType -from math import log as _log, exp as _exp, pi as _pi, e as _e -from math import sqrt as _sqrt, acos as _acos, cos as _cos, sin as _sin -from math import floor as _floor -from os import urandom as _urandom -from binascii import hexlify as _hexlify - - -__all__ = ["Random","seed","random","uniform","randint","choice","sample", - "randrange","shuffle","normalvariate","lognormvariate", - "cunifvariate","expovariate","vonmisesvariate","gammavariate", - "stdgamma","gauss","betavariate","paretovariate","weibullvariate", - "getstate","setstate","jumpahead", "WichmannHill"] - -NV_MAGICCONST = 4 * _exp(-0.5)/_sqrt(2.0) -TWOPI = 2.0*_pi -LOG4 = _log(4.0) -SG_MAGICCONST = 1.0 + _log(4.5) -BPF = 53 # Number of bits in a float -RECIP_BPF = 2**-BPF - -# Translated by Guido van Rossum from C source provided by -# Adrian Baddeley. Adapted by Raymond Hettinger for use with -# the Mersenne Twister core generator. - -import _random - -class Random(_random.Random): - """Random number generator base class used by bound module functions. - - Used to instantiate instances of Random to get generators that don't - share state. Especially useful for multi-threaded programs, creating - a different instance of Random for each thread, and using the jumpahead() - method to ensure that the generated sequences seen by each thread don't - overlap. - - Class Random can also be subclassed if you want to use a different basic - generator of your own devising: in that case, override the following - methods: random(), seed(), getstate(), setstate() and jumpahead(). - - """ - - VERSION = 2 # used by getstate/setstate - - def __init__(self, x=None): - """Initialize an instance. - - Optional argument x controls seeding, as for Random.seed(). - """ - - self.seed(x) - self.gauss_next = None - - def seed(self, a=None): - """Initialize internal state from hashable object. - - None or no argument seeds from current time. - - If a is not None or an int or long, hash(a) is used instead. - """ - - if a is None: - a = long(time.time() * 256) # use fractional seconds - super(Random, self).seed(a) - self.gauss_next = None - - def getstate(self): - """Return internal state; can be passed to setstate() later.""" - return self.VERSION, super(Random, self).getstate(), self.gauss_next - - def setstate(self, state): - """Restore internal state from object returned by getstate().""" - version = state[0] - if version == 2: - version, internalstate, self.gauss_next = state - super(Random, self).setstate(internalstate) - else: - raise ValueError("state with version %s passed to " - "Random.setstate() of version %s" % - (version, self.VERSION)) - -## ---- Methods below this point do not need to be overridden when -## ---- subclassing for the purpose of using a different core generator. - -## -------------------- pickle support ------------------- - - def __getstate__(self): # for pickle - return self.getstate() - - def __setstate__(self, state): # for pickle - self.setstate(state) - - def __reduce__(self): - return self.__class__, (), self.getstate() - -## -------------------- integer methods ------------------- - - def randrange(self, start, stop=None, step=1, int=int, default=None, - maxwidth=1L<<BPF, _BuiltinMethod=_BuiltinMethodType): - """Choose a random item from range(start, stop[, step]). - - This fixes the problem with randint() which includes the - endpoint; in Python this is usually not what you want. - Do not supply the 'int', 'default', and 'maxwidth' arguments. - """ - - # This code is a bit messy to make it fast for the - # common case while still doing adequate error checking. - istart = int(start) - if istart != start: - raise ValueError, "non-integer arg 1 for randrange()" - if stop is default: - if istart > 0: - if istart >= maxwidth and type(self.random) is _BuiltinMethod: - return self._randbelow(istart) - return int(self.random() * istart) - raise ValueError, "empty range for randrange()" - - # stop argument supplied. - istop = int(stop) - if istop != stop: - raise ValueError, "non-integer stop for randrange()" - width = istop - istart - if step == 1 and width > 0: - # Note that - # int(istart + self.random()*(istop - istart)) - # instead would be incorrect. For example, consider istart - # = -2 and istop = 0. Then the guts would be in - # -2.0 to 0.0 exclusive on both ends (ignoring that random() - # might return 0.0), and because int() truncates toward 0, the - # final result would be -1 or 0 (instead of -2 or -1). - # istart + int(self.random()*(istop - istart)) - # would also be incorrect, for a subtler reason: the RHS - # can return a long, and then randrange() would also return - # a long, but we're supposed to return an int (for backward - # compatibility). - if width >= maxwidth and type(self.random) is _BuiltinMethod: - return int(istart + self._randbelow(width)) - return int(istart + int(self.random()*width)) - if step == 1: - raise ValueError, "empty range for randrange()" - - # Non-unit step argument supplied. - istep = int(step) - if istep != step: - raise ValueError, "non-integer step for randrange()" - if istep > 0: - n = (width + istep - 1) / istep - elif istep < 0: - n = (width + istep + 1) / istep - else: - raise ValueError, "zero step for randrange()" - - if n <= 0: - raise ValueError, "empty range for randrange()" - - if n >= maxwidth and type(self.random) is _BuiltinMethod: - return istart + self._randbelow(n) - return istart + istep*int(self.random() * n) - - def randint(self, a, b): - """Return random integer in range [a, b], including both end points. - """ - - return self.randrange(a, b+1) - - def _randbelow(self, n, bpf=BPF, maxwidth=1L<<BPF, - long=long, _log=_log, int=int): - """Return a random int in the range [0,n) - - Handles the case where n has more bits than returned - by a single call to the underlying generator. - """ - - # k is a sometimes over but never under estimate of the bits in n - k = int(1.00001 + _log(n-1, 2)) # 2**k > n-1 >= 2**(k-2) - - random = self.random - r = n - while r >= n: - # In Py2.4, this section becomes: r = self.getrandbits(k) - r = long(random() * maxwidth) - bits = bpf - while bits < k: - r = (r << bpf) | (long(random() * maxwidth)) - bits += bpf - r >>= (bits - k) - return r - -## -------------------- sequence methods ------------------- - - def choice(self, seq): - """Choose a random element from a non-empty sequence.""" - return seq[int(self.random() * len(seq))] - - def shuffle(self, x, random=None, int=int): - """x, random=random.random -> shuffle list x in place; return None. - - Optional arg random is a 0-argument function returning a random - float in [0.0, 1.0); by default, the standard random.random. - - Note that for even rather small len(x), the total number of - permutations of x is larger than the period of most random number - generators; this implies that "most" permutations of a long - sequence can never be generated. - """ - - if random is None: - random = self.random - for i in xrange(len(x)-1, 0, -1): - # pick an element in x[:i+1] with which to exchange x[i] - j = int(random() * (i+1)) - x[i], x[j] = x[j], x[i] - - def sample(self, population, k): - """Chooses k unique random elements from a population sequence. - - Returns a new list containing elements from the population while - leaving the original population unchanged. The resulting list is - in selection order so that all sub-slices will also be valid random - samples. This allows raffle winners (the sample) to be partitioned - into grand prize and second place winners (the subslices). - - Members of the population need not be hashable or unique. If the - population contains repeats, then each occurrence is a possible - selection in the sample. - - To choose a sample in a range of integers, use xrange as an argument. - This is especially fast and space efficient for sampling from a - large population: sample(xrange(10000000), 60) - """ - - # Sampling without replacement entails tracking either potential - # selections (the pool) in a list or previous selections in a - # dictionary. - - # When the number of selections is small compared to the population, - # then tracking selections is efficient, requiring only a small - # dictionary and an occasional reselection. For a larger number of - # selections, the pool tracking method is preferred since the list takes - # less space than the dictionary and it doesn't suffer from frequent - # reselections. - - n = len(population) - if not 0 <= k <= n: - raise ValueError, "sample larger than population" - random = self.random - _int = int - result = [None] * k - if n < 6 * k: # if n len list takes less space than a k len dict - pool = list(population) - for i in xrange(k): # invariant: non-selected at [0,n-i) - j = _int(random() * (n-i)) - result[i] = pool[j] - pool[j] = pool[n-i-1] # move non-selected item into vacancy - else: - try: - n > 0 and (population[0], population[n//2], population[n-1]) - except (TypeError, KeyError): # handle sets and dictionaries - population = tuple(population) - selected = {} - for i in xrange(k): - j = _int(random() * n) - while j in selected: - j = _int(random() * n) - result[i] = selected[j] = population[j] - return result - -## -------------------- real-valued distributions ------------------- - -## -------------------- uniform distribution ------------------- - - def uniform(self, a, b): - """Get a random number in the range [a, b).""" - return a + (b-a) * self.random() - -## -------------------- normal distribution -------------------- - - def normalvariate(self, mu, sigma): - """Normal distribution. - - mu is the mean, and sigma is the standard deviation. - - """ - # mu = mean, sigma = standard deviation - - # Uses Kinderman and Monahan method. Reference: Kinderman, - # A.J. and Monahan, J.F., "Computer generation of random - # variables using the ratio of uniform deviates", ACM Trans - # Math Software, 3, (1977), pp257-260. - - random = self.random - while True: - u1 = random() - u2 = 1.0 - random() - z = NV_MAGICCONST*(u1-0.5)/u2 - zz = z*z/4.0 - if zz <= -_log(u2): - break - return mu + z*sigma - -## -------------------- lognormal distribution -------------------- - - def lognormvariate(self, mu, sigma): - """Log normal distribution. - - If you take the natural logarithm of this distribution, you'll get a - normal distribution with mean mu and standard deviation sigma. - mu can have any value, and sigma must be greater than zero. - - """ - return _exp(self.normalvariate(mu, sigma)) - -## -------------------- circular uniform -------------------- - - def cunifvariate(self, mean, arc): - """Circular uniform distribution. - - mean is the mean angle, and arc is the range of the distribution, - centered around the mean angle. Both values must be expressed in - radians. Returned values range between mean - arc/2 and - mean + arc/2 and are normalized to between 0 and pi. - - Deprecated in version 2.3. Use: - (mean + arc * (Random.random() - 0.5)) % Math.pi - - """ - # mean: mean angle (in radians between 0 and pi) - # arc: range of distribution (in radians between 0 and pi) - import warnings - warnings.warn("The cunifvariate function is deprecated; Use (mean " - "+ arc * (Random.random() - 0.5)) % Math.pi instead.", - DeprecationWarning, 2) - - return (mean + arc * (self.random() - 0.5)) % _pi - -## -------------------- exponential distribution -------------------- - - def expovariate(self, lambd): - """Exponential distribution. - - lambd is 1.0 divided by the desired mean. (The parameter would be - called "lambda", but that is a reserved word in Python.) Returned - values range from 0 to positive infinity. - - """ - # lambd: rate lambd = 1/mean - # ('lambda' is a Python reserved word) - - random = self.random - u = random() - while u <= 1e-7: - u = random() - return -_log(u)/lambd - -## -------------------- von Mises distribution -------------------- - - def vonmisesvariate(self, mu, kappa): - """Circular data distribution. - - mu is the mean angle, expressed in radians between 0 and 2*pi, and - kappa is the concentration parameter, which must be greater than or - equal to zero. If kappa is equal to zero, this distribution reduces - to a uniform random angle over the range 0 to 2*pi. - - """ - # mu: mean angle (in radians between 0 and 2*pi) - # kappa: concentration parameter kappa (>= 0) - # if kappa = 0 generate uniform random angle - - # Based upon an algorithm published in: Fisher, N.I., - # "Statistical Analysis of Circular Data", Cambridge - # University Press, 1993. - - # Thanks to Magnus Kessler for a correction to the - # implementation of step 4. - - random = self.random - if kappa <= 1e-6: - return TWOPI * random() - - a = 1.0 + _sqrt(1.0 + 4.0 * kappa * kappa) - b = (a - _sqrt(2.0 * a))/(2.0 * kappa) - r = (1.0 + b * b)/(2.0 * b) - - while True: - u1 = random() - - z = _cos(_pi * u1) - f = (1.0 + r * z)/(r + z) - c = kappa * (r - f) - - u2 = random() - - if not (u2 >= c * (2.0 - c) and u2 > c * _exp(1.0 - c)): - break - - u3 = random() - if u3 > 0.5: - theta = (mu % TWOPI) + _acos(f) - else: - theta = (mu % TWOPI) - _acos(f) - - return theta - -## -------------------- gamma distribution -------------------- - - def gammavariate(self, alpha, beta): - """Gamma distribution. Not the gamma function! - - Conditions on the parameters are alpha > 0 and beta > 0. - - """ - - # alpha > 0, beta > 0, mean is alpha*beta, variance is alpha*beta**2 - - # Warning: a few older sources define the gamma distribution in terms - # of alpha > -1.0 - if alpha <= 0.0 or beta <= 0.0: - raise ValueError, 'gammavariate: alpha and beta must be > 0.0' - - random = self.random - if alpha > 1.0: - - # Uses R.C.H. Cheng, "The generation of Gamma - # variables with non-integral shape parameters", - # Applied Statistics, (1977), 26, No. 1, p71-74 - - ainv = _sqrt(2.0 * alpha - 1.0) - bbb = alpha - LOG4 - ccc = alpha + ainv - - while True: - u1 = random() - if not 1e-7 < u1 < .9999999: - continue - u2 = 1.0 - random() - v = _log(u1/(1.0-u1))/ainv - x = alpha*_exp(v) - z = u1*u1*u2 - r = bbb+ccc*v-x - if r + SG_MAGICCONST - 4.5*z >= 0.0 or r >= _log(z): - return x * beta - - elif alpha == 1.0: - # expovariate(1) - u = random() - while u <= 1e-7: - u = random() - return -_log(u) * beta - - else: # alpha is between 0 and 1 (exclusive) - - # Uses ALGORITHM GS of Statistical Computing - Kennedy & Gentle - - while True: - u = random() - b = (_e + alpha)/_e - p = b*u - if p <= 1.0: - x = pow(p, 1.0/alpha) - else: - # p > 1 - x = -_log((b-p)/alpha) - u1 = random() - if not (((p <= 1.0) and (u1 > _exp(-x))) or - ((p > 1) and (u1 > pow(x, alpha - 1.0)))): - break - return x * beta - - - def stdgamma(self, alpha, ainv, bbb, ccc): - # This method was (and shall remain) undocumented. - # This method is deprecated - # for the following reasons: - # 1. Returns same as .gammavariate(alpha, 1.0) - # 2. Requires caller to provide 3 extra arguments - # that are functions of alpha anyway - # 3. Can't be used for alpha < 0.5 - - # ainv = sqrt(2 * alpha - 1) - # bbb = alpha - log(4) - # ccc = alpha + ainv - import warnings - warnings.warn("The stdgamma function is deprecated; " - "use gammavariate() instead.", - DeprecationWarning, 2) - return self.gammavariate(alpha, 1.0) - - - -## -------------------- Gauss (faster alternative) -------------------- - - def gauss(self, mu, sigma): - """Gaussian distribution. - - mu is the mean, and sigma is the standard deviation. This is - slightly faster than the normalvariate() function. - - Not thread-safe without a lock around calls. - - """ - - # When x and y are two variables from [0, 1), uniformly - # distributed, then - # - # cos(2*pi*x)*sqrt(-2*log(1-y)) - # sin(2*pi*x)*sqrt(-2*log(1-y)) - # - # are two *independent* variables with normal distribution - # (mu = 0, sigma = 1). - # (Lambert Meertens) - # (corrected version; bug discovered by Mike Miller, fixed by LM) - - # Multithreading note: When two threads call this function - # simultaneously, it is possible that they will receive the - # same return value. The window is very small though. To - # avoid this, you have to use a lock around all calls. (I - # didn't want to slow this down in the serial case by using a - # lock here.) - - random = self.random - z = self.gauss_next - self.gauss_next = None - if z is None: - x2pi = random() * TWOPI - g2rad = _sqrt(-2.0 * _log(1.0 - random())) - z = _cos(x2pi) * g2rad - self.gauss_next = _sin(x2pi) * g2rad - - return mu + z*sigma - -## -------------------- beta -------------------- -## See -## http://sourceforge.net/bugs/?func=detailbug&bug_id=130030&group_id=5470 -## for Ivan Frohne's insightful analysis of why the original implementation: -## -## def betavariate(self, alpha, beta): -## # Discrete Event Simulation in C, pp 87-88. -## -## y = self.expovariate(alpha) -## z = self.expovariate(1.0/beta) -## return z/(y+z) -## -## was dead wrong, and how it probably got that way. - - def betavariate(self, alpha, beta): - """Beta distribution. - - Conditions on the parameters are alpha > -1 and beta} > -1. - Returned values range between 0 and 1. - - """ - - # This version due to Janne Sinkkonen, and matches all the std - # texts (e.g., Knuth Vol 2 Ed 3 pg 134 "the beta distribution"). - y = self.gammavariate(alpha, 1.) - if y == 0: - return 0.0 - else: - return y / (y + self.gammavariate(beta, 1.)) - -## -------------------- Pareto -------------------- - - def paretovariate(self, alpha): - """Pareto distribution. alpha is the shape parameter.""" - # Jain, pg. 495 - - u = 1.0 - self.random() - return 1.0 / pow(u, 1.0/alpha) - -## -------------------- Weibull -------------------- - - def weibullvariate(self, alpha, beta): - """Weibull distribution. - - alpha is the scale parameter and beta is the shape parameter. - - """ - # Jain, pg. 499; bug fix courtesy Bill Arms - - u = 1.0 - self.random() - return alpha * pow(-_log(u), 1.0/beta) - -## -------------------- Wichmann-Hill ------------------- - -class WichmannHill(Random): - - VERSION = 1 # used by getstate/setstate - - def seed(self, a=None): - """Initialize internal state from hashable object. - - None or no argument seeds from current time. - - If a is not None or an int or long, hash(a) is used instead. - - If a is an int or long, a is used directly. Distinct values between - 0 and 27814431486575L inclusive are guaranteed to yield distinct - internal states (this guarantee is specific to the default - Wichmann-Hill generator). - """ - - if a is None: - # Initialize from current time - import time - a = long(time.time() * 256) - - if not isinstance(a, (int, long)): - a = hash(a) - - a, x = divmod(a, 30268) - a, y = divmod(a, 30306) - a, z = divmod(a, 30322) - self._seed = int(x)+1, int(y)+1, int(z)+1 - - self.gauss_next = None - - def random(self): - """Get the next random number in the range [0.0, 1.0).""" - - # Wichman-Hill random number generator. - # - # Wichmann, B. A. & Hill, I. D. (1982) - # Algorithm AS 183: - # An efficient and portable pseudo-random number generator - # Applied Statistics 31 (1982) 188-190 - # - # see also: - # Correction to Algorithm AS 183 - # Applied Statistics 33 (1984) 123 - # - # McLeod, A. I. (1985) - # A remark on Algorithm AS 183 - # Applied Statistics 34 (1985),198-200 - - # This part is thread-unsafe: - # BEGIN CRITICAL SECTION - x, y, z = self._seed - x = (171 * x) % 30269 - y = (172 * y) % 30307 - z = (170 * z) % 30323 - self._seed = x, y, z - # END CRITICAL SECTION - - # Note: on a platform using IEEE-754 double arithmetic, this can - # never return 0.0 (asserted by Tim; proof too long for a comment). - return (x/30269.0 + y/30307.0 + z/30323.0) % 1.0 - - def getstate(self): - """Return internal state; can be passed to setstate() later.""" - return self.VERSION, self._seed, self.gauss_next - - def setstate(self, state): - """Restore internal state from object returned by getstate().""" - version = state[0] - if version == 1: - version, self._seed, self.gauss_next = state - else: - raise ValueError("state with version %s passed to " - "Random.setstate() of version %s" % - (version, self.VERSION)) - - def jumpahead(self, n): - """Act as if n calls to random() were made, but quickly. - - n is an int, greater than or equal to 0. - - Example use: If you have 2 threads and know that each will - consume no more than a million random numbers, create two Random - objects r1 and r2, then do - r2.setstate(r1.getstate()) - r2.jumpahead(1000000) - Then r1 and r2 will use guaranteed-disjoint segments of the full - period. - """ - - if not n >= 0: - raise ValueError("n must be >= 0") - x, y, z = self._seed - x = int(x * pow(171, n, 30269)) % 30269 - y = int(y * pow(172, n, 30307)) % 30307 - z = int(z * pow(170, n, 30323)) % 30323 - self._seed = x, y, z - - def __whseed(self, x=0, y=0, z=0): - """Set the Wichmann-Hill seed from (x, y, z). - - These must be integers in the range [0, 256). - """ - - if not type(x) == type(y) == type(z) == int: - raise TypeError('seeds must be integers') - if not (0 <= x < 256 and 0 <= y < 256 and 0 <= z < 256): - raise ValueError('seeds must be in range(0, 256)') - if 0 == x == y == z: - # Initialize from current time - import time - t = long(time.time() * 256) - t = int((t&0xffffff) ^ (t>>24)) - t, x = divmod(t, 256) - t, y = divmod(t, 256) - t, z = divmod(t, 256) - # Zero is a poor seed, so substitute 1 - self._seed = (x or 1, y or 1, z or 1) - - self.gauss_next = None - - def whseed(self, a=None): - """Seed from hashable object's hash code. - - None or no argument seeds from current time. It is not guaranteed - that objects with distinct hash codes lead to distinct internal - states. - - This is obsolete, provided for compatibility with the seed routine - used prior to Python 2.1. Use the .seed() method instead. - """ - - if a is None: - self.__whseed() - return - a = hash(a) - a, x = divmod(a, 256) - a, y = divmod(a, 256) - a, z = divmod(a, 256) - x = (x + a) % 256 or 1 - y = (y + a) % 256 or 1 - z = (z + a) % 256 or 1 - self.__whseed(x, y, z) -## --------------- Operating System Random Source ------------------ - -class SystemRandom(Random): - """Alternate random number generator using sources provided - by the operating system (such as /dev/urandom on Unix or - CryptGenRandom on Windows). - - Not available on all systems (see os.urandom() for details). - """ - - def random(self): - """Get the next random number in the range [0.0, 1.0).""" - return (long(_hexlify(_urandom(7)), 16) >> 3) * RECIP_BPF - - def getrandbits(self, k): - """getrandbits(k) -> x. Generates a long int with k random bits.""" - if k <= 0: - raise ValueError('number of bits must be greater than zero') - if k != int(k): - raise TypeError('number of bits should be an integer') - bytes = (k + 7) // 8 # bits / 8 and rounded up - x = long(_hexlify(_urandom(bytes)), 16) - return x >> (bytes * 8 - k) # trim excess bits - - def _stub(self, *args, **kwds): - "Stub method. Not used for a system random number generator." - return None - seed = jumpahead = _stub - - def _notimplemented(self, *args, **kwds): - "Method should not be called for a system random number generator." - raise NotImplementedError('System entropy source does not have state.') - getstate = setstate = _notimplemented - -## -------------------- test program -------------------- - -def _test_generator(n, funccall): - import time - print n, 'times', funccall - code = compile(funccall, funccall, 'eval') - total = 0.0 - sqsum = 0.0 - smallest = 1e10 - largest = -1e10 - t0 = time.time() - for i in range(n): - x = eval(code) - total += x - sqsum = sqsum + x*x - smallest = min(x, smallest) - largest = max(x, largest) - t1 = time.time() - print round(t1-t0, 3), 'sec,', - avg = total/n - stddev = _sqrt(sqsum/n - avg*avg) - print 'avg %g, stddev %g, min %g, max %g' % \ - (avg, stddev, smallest, largest) - - -def _test(N=2000): - _test_generator(N, 'random()') - _test_generator(N, 'normalvariate(0.0, 1.0)') - _test_generator(N, 'lognormvariate(0.0, 1.0)') - _test_generator(N, 'cunifvariate(0.0, 1.0)') - _test_generator(N, 'vonmisesvariate(0.0, 1.0)') - _test_generator(N, 'gammavariate(0.01, 1.0)') - _test_generator(N, 'gammavariate(0.1, 1.0)') - _test_generator(N, 'gammavariate(0.1, 2.0)') - _test_generator(N, 'gammavariate(0.5, 1.0)') - _test_generator(N, 'gammavariate(0.9, 1.0)') - _test_generator(N, 'gammavariate(1.0, 1.0)') - _test_generator(N, 'gammavariate(2.0, 1.0)') - _test_generator(N, 'gammavariate(20.0, 1.0)') - _test_generator(N, 'gammavariate(200.0, 1.0)') - _test_generator(N, 'gauss(0.0, 1.0)') - _test_generator(N, 'betavariate(3.0, 3.0)') - -# Create one instance, seeded from current time, and export its methods -# as module-level functions. The functions share state across all uses -#(both in the user's code and in the Python libraries), but that's fine -# for most programs and is easier for the casual user than making them -# instantiate their own Random() instance. - -_inst = Random() -seed = _inst.seed -random = _inst.random -uniform = _inst.uniform -randint = _inst.randint -choice = _inst.choice -randrange = _inst.randrange -sample = _inst.sample -shuffle = _inst.shuffle -normalvariate = _inst.normalvariate -lognormvariate = _inst.lognormvariate -cunifvariate = _inst.cunifvariate -expovariate = _inst.expovariate -vonmisesvariate = _inst.vonmisesvariate -gammavariate = _inst.gammavariate -stdgamma = _inst.stdgamma -gauss = _inst.gauss -betavariate = _inst.betavariate -paretovariate = _inst.paretovariate -weibullvariate = _inst.weibullvariate -getstate = _inst.getstate -setstate = _inst.setstate -jumpahead = _inst.jumpahead - -if __name__ == '__main__': - _test() Modified: trunk/jython/Lib/test/test_random.py =================================================================== --- trunk/jython/Lib/test/test_random.py 2008-10-06 03:02:29 UTC (rev 5359) +++ trunk/jython/Lib/test/test_random.py 2008-10-06 03:12:34 UTC (rev 5360) @@ -530,6 +530,12 @@ TestDistributions, TestModule] + if test_support.is_jython: + del MersenneTwister_TestBasicOps.test_genrandbits + del MersenneTwister_TestBasicOps.test_referenceImplementation + del MersenneTwister_TestBasicOps.test_setstate_middle_arg + del MersenneTwister_TestBasicOps.test_strong_reference_implementation + try: random.SystemRandom().random() except NotImplementedError: Modified: trunk/jython/src/org/python/modules/random/PyRandom.java =================================================================== --- trunk/jython/src/org/python/modules/random/PyRandom.java 2008-10-06 03:02:29 UTC (rev 5359) +++ trunk/jython/src/org/python/modules/random/PyRandom.java 2008-10-06 03:12:34 UTC (rev 5360) @@ -5,6 +5,7 @@ import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; +import java.math.BigInteger; import java.util.Random; import org.python.core.Py; @@ -45,7 +46,9 @@ seed = new PyLong(System.currentTimeMillis()); } if (seed instanceof PyLong) { - this.javaRandom.setSeed(((PyLong)seed).asLong(0)); + PyLong max = new PyLong(Long.MAX_VALUE); + PyLong seed_modulus = (PyLong)(seed.__mod__(max)); + this.javaRandom.setSeed(((PyLong)seed_modulus).asLong(0)); } else if (seed instanceof PyInteger) { this.javaRandom.setSeed(((PyInteger)seed).getValue()); } else { @@ -137,4 +140,9 @@ double ret=(a*67108864.0+b)*(1.0/9007199254740992.0); return new PyFloat(ret); } + + @ExposedMethod + public PyLong Random_getrandbits(int k) { + return new PyLong(new BigInteger(k, javaRandom)); + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <zy...@us...> - 2008-10-11 02:39:07
|
Revision: 5369 http://jython.svn.sourceforge.net/jython/?rev=5369&view=rev Author: zyasoft Date: 2008-10-11 02:38:55 +0000 (Sat, 11 Oct 2008) Log Message: ----------- Make "extended" builtin functions in __builtin__ (that is, functions like max which use a class like MaxFunction for their definition) copyable by copy.copy and return the correct type. This fixes test_copy, along with enabling reflexive structures to be compared, since we don't prohibit or otherwise detect them in the copying anyway. Modified Paths: -------------- trunk/jython/Lib/test/test_copy.py trunk/jython/src/org/python/core/__builtin__.java Modified: trunk/jython/Lib/test/test_copy.py =================================================================== --- trunk/jython/Lib/test/test_copy.py 2008-10-11 02:24:42 UTC (rev 5368) +++ trunk/jython/Lib/test/test_copy.py 2008-10-11 02:38:55 UTC (rev 5369) @@ -268,11 +268,12 @@ self.assert_(x is not y) self.assert_(x[0] is not y[0]) + # modified for Jython def test_deepcopy_reflexive_list(self): x = [] x.append(x) y = copy.deepcopy(x) - self.assertRaises(RuntimeError, cmp, y, x) + self.assertEqual(y, x) self.assert_(y is not x) self.assert_(y[0] is y) self.assertEqual(len(y), 1) @@ -284,11 +285,12 @@ self.assert_(x is not y) self.assert_(x[0] is not y[0]) + # modified for Jython def test_deepcopy_reflexive_tuple(self): x = ([],) x[0].append(x) y = copy.deepcopy(x) - self.assertRaises(RuntimeError, cmp, y, x) + self.assertEqual(y, x) self.assert_(y is not x) self.assert_(y[0] is not x[0]) self.assert_(y[0][0] is y) @@ -300,11 +302,12 @@ self.assert_(x is not y) self.assert_(x["foo"] is not y["foo"]) + # modified for Jython def test_deepcopy_reflexive_dict(self): x = {} x['foo'] = x y = copy.deepcopy(x) - self.assertRaises(RuntimeError, cmp, y, x) + self.assertEqual(y, x) self.assert_(y is not x) self.assert_(y['foo'] is y) self.assertEqual(len(y), 1) Modified: trunk/jython/src/org/python/core/__builtin__.java =================================================================== --- trunk/jython/src/org/python/core/__builtin__.java 2008-10-11 02:24:42 UTC (rev 5368) +++ trunk/jython/src/org/python/core/__builtin__.java 2008-10-11 02:38:55 UTC (rev 5369) @@ -8,6 +8,8 @@ import org.python.antlr.ast.modType; import org.python.core.util.RelativeFile; import org.python.expose.ExposedGet; +import org.python.expose.ExposedNew; +import org.python.expose.ExposedType; class BuiltinFunctions extends PyBuiltinFunctionSet { @@ -371,23 +373,23 @@ dict.__setitem__("iter", new BuiltinFunctions("iter", 27, 1, 2)); dict.__setitem__("locals", new BuiltinFunctions("locals", 28, 0)); dict.__setitem__("map", new BuiltinFunctions("map", 29, 2, -1)); - dict.__setitem__("max", new MaxFunction()); - dict.__setitem__("min", new MinFunction()); + dict.__setitem__("max", MaxFunction.INSTANCE); + dict.__setitem__("min", MinFunction.INSTANCE); dict.__setitem__("oct", new BuiltinFunctions("oct", 32, 1)); dict.__setitem__("pow", new BuiltinFunctions("pow", 33, 2, 3)); dict.__setitem__("raw_input", new BuiltinFunctions("raw_input", 34, 0, 1)); dict.__setitem__("reduce", new BuiltinFunctions("reduce", 35, 2, 3)); dict.__setitem__("reload", new BuiltinFunctions("reload", 36, 1)); dict.__setitem__("repr", new BuiltinFunctions("repr", 37, 1)); - dict.__setitem__("round", new RoundFunction()); + dict.__setitem__("round", RoundFunction.INSTANCE); dict.__setitem__("setattr", new BuiltinFunctions("setattr", 39, 3)); dict.__setitem__("vars", new BuiltinFunctions("vars", 41, 0, 1)); dict.__setitem__("zip", new BuiltinFunctions("zip", 43, 0, -1)); dict.__setitem__("reversed", new BuiltinFunctions("reversed", 45, 1)); - dict.__setitem__("__import__", new ImportFunction()); - dict.__setitem__("sorted", new SortedFunction()); - dict.__setitem__("all", new AllFunction()); - dict.__setitem__("any", new AnyFunction()); + dict.__setitem__("__import__", ImportFunction.INSTANCE); + dict.__setitem__("sorted", SortedFunction.INSTANCE); + dict.__setitem__("all", AllFunction.INSTANCE); + dict.__setitem__("any", AnyFunction.INSTANCE); } public static PyObject abs(PyObject o) { @@ -1227,8 +1229,25 @@ } } -class ImportFunction extends PyObject { +// simulates a PyBuiltinFunction for functions not using the PyBuiltinFunctionSet approach of above +abstract class ExtendedBuiltinFunction extends PyObject { + public static final PyType TYPE = PyType.fromClass(PyBuiltinFunction.class); + @ExposedGet(name = "__class__") + public PyType getType() { + return TYPE; + } +} + +class ImportFunction extends ExtendedBuiltinFunction { + static final ImportFunction INSTANCE = new ImportFunction(); + + private ImportFunction() {} + @ExposedNew + public static PyObject __new__(PyObject[] args, String[] keyword) { + return INSTANCE; + } + @ExposedGet(name = "__doc__") public PyObject getDoc() { return new PyString("__import__(name, globals={}, locals={}, fromlist=[], level=-1) -> module\n\n" + @@ -1276,8 +1295,16 @@ } -class SortedFunction extends PyObject { +class SortedFunction extends ExtendedBuiltinFunction { + static final SortedFunction INSTANCE = new SortedFunction(); + private SortedFunction() {} + + @ExposedNew + public static PyObject __new__(PyObject[] args, String[] keyword) { + return INSTANCE; + } + @ExposedGet(name = "__doc__") @Override public PyObject getDoc() { @@ -1317,8 +1344,16 @@ } } -class AllFunction extends PyObject { +class AllFunction extends ExtendedBuiltinFunction { + static final AllFunction INSTANCE = new AllFunction(); + private AllFunction() {} + + @ExposedNew + public static PyObject __new__(PyObject[] args, String[] keyword) { + return INSTANCE; + } + @ExposedGet(name = "__doc__") @Override public PyObject getDoc() { @@ -1348,8 +1383,16 @@ } } -class AnyFunction extends PyObject { +class AnyFunction extends ExtendedBuiltinFunction { + static final AnyFunction INSTANCE = new AnyFunction(); + private AnyFunction() {} + + @ExposedNew + public static PyObject __new__(PyObject[] args, String[] keyword) { + return INSTANCE; + } + @ExposedGet(name = "__doc__") @Override public PyObject getDoc() { @@ -1379,10 +1422,16 @@ } } +class MaxFunction extends ExtendedBuiltinFunction { + static final MaxFunction INSTANCE = new MaxFunction(); + + private MaxFunction() {} + + @ExposedNew + public static PyObject __new__(PyObject[] args, String[] keyword) { + return INSTANCE; + } - -class MaxFunction extends PyObject { - @ExposedGet(name = "__doc__") @Override public PyObject getDoc() { @@ -1418,7 +1467,7 @@ else { return max(args[0], key); } - } + } @Override public String toString() { @@ -1446,10 +1495,20 @@ } return max; } + } -class MinFunction extends PyObject { - +class MinFunction extends ExtendedBuiltinFunction { + static final MinFunction INSTANCE = new MinFunction(); + + private MinFunction() {} + + @ExposedNew + public static PyObject __new__(PyObject[] args, String[] keyword) { + return INSTANCE; + } + + @ExposedGet(name = "__doc__") @Override public PyObject getDoc() { @@ -1515,9 +1574,15 @@ } } - -class RoundFunction extends PyObject { - +class RoundFunction extends ExtendedBuiltinFunction { + static final RoundFunction INSTANCE = new RoundFunction(); + private RoundFunction() {} + + @ExposedNew + public static PyObject __new__(PyObject[] args, String[] keyword) { + return INSTANCE; + } + @ExposedGet(name = "__doc__") @Override public PyObject getDoc() { @@ -1526,8 +1591,13 @@ "Round a number to a given precision in decimal digits (default 0 digits).\n" + "This always returns a floating point number. Precision may be negative."); } - + @Override + public String toString() { + return "<built-in function round>"; + } + + @Override public PyObject __call__(PyObject args[], String kwds[]) { ArgParser ap = new ArgParser("round", args, kwds, new String[]{"number", "ndigits"}, 0); PyObject number = ap.getPyObject(0); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |