I tried to use the OpenCL parser but there were some small mistakes in the code.
In ext_c_parser.py in the class OpenCLCParser, the first line reads
from pycparserext.ext_c_lexer import GnuCLexer as lexer_class
it should be ---------------------------------------------v v
from pycparserext.ext_c_lexer import OpenCLCLexer as lexer_class
After this it complains about not having the 'ASM' token so I added 'asm' to the lexer keywords in ext_c_lexer.py. That is:
--------------------------------------------------------- v v
add_lexer_keywords(GnuCLexer, [
'attribute', 'asm', 'asm', 'asm', '__typeof',
'real', 'imag', 'builtin_types_compatible_p',
'const', 'restrict', 'inline', 'inline',
'extension', 'asm'])
Hello,
I tried to use the OpenCL parser but there were some small mistakes in the code. In ext_c_parser.py in the class OpenCLCParser, the first line reads from pycparserext.ext_c_lexer import GnuCLexer as lexer_class
it should be ---------------------------------------------v v from pycparserext.ext_c_lexer import OpenCLCLexer as lexer_class
After this it complains about not having the 'ASM' token so I added 'asm' to the lexer keywords in ext_c_lexer.py. That is: --------------------------------------------------------- v v add_lexer_keywords(GnuCLexer, [ 'attribute', 'asm', 'asm', 'asm', '__typeof', 'real', 'imag', 'builtin_types_compatible_p', 'const', 'restrict', 'inline', 'inline', 'extension', 'asm'])
_CL_KEYWORDS = ['kernel', 'constant', 'global', 'local', 'private', "read_only", "write_only", "read_write"] add_lexer_keywords(OpenCLCLexer, [ 'attribute', 'asm', '**asm', 'asm']
Also, I wrote a small OpenCL test program:
def test_OpenCL(): from pycparserext.ext_c_parser import OpenCLCParser, c_ast src = """ kernel void zeroMatrix(global float _A, int n, __global float * B) { int i = get_global_id(0); for (int k=0; k<n; k++) A[i_n+k] = 0; } """
test_OpenCL()
Perhaps you could incorporate these changes.
Best Regards, Jacob