inducer / pycparserext

Extensions for Eli Bendersky's pycparser
http://pypi.python.org/pypi/pycparserext
Other
83 stars 28 forks source link

ParseError on uint type #8

Closed aksiazek closed 9 years ago

aksiazek commented 9 years ago

There are issues to parse opencl types: uint, ushort, ulong etc. Specifcally the scalar (non-vector) unsigned types. To test this simply add a declaration uint a = 1; to any test, e.g.: def test_opencl(): from pycparserext.ext_c_parser import OpenCLCParser src = """ kernel void zeroMatrix(global float _A, int n, __global float * B) { uint a = 1; int i = get_global_id(0); for (int k=0; k<n; k++) A[i_n+k] = 0; } """ Expected: test passed, got a parse error. Note that changing it to int immediately fixes the error. Edit: vector types parse fine.

Tested on newest version, installed by pip.

aksiazek commented 9 years ago

Proposition for a patch: in OpenCLCParser simply change first set of initial_type_symbols to match the OpenCl Spec better (incl. bool, uchar, ushort, ulong and possible half type combinations) initial_type_symbols = ( set([ "%s%s" % (base_name, count) for base_name in [ 'bool', 'char', 'uchar', 'short', 'ushort', 'int', 'uint', 'long', 'ulong', 'float', 'double'] for count in ["","2", "3", "4","8", "16"] ])

inducer commented 9 years ago

Thanks for the report!