You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
cannot attach attributes to nodes of type '<class 'pycparser.c_ast.PtrDecl'>' #17
python example.py test1.c
WARNING: /usr/lib/python2.7/dist-packages/pycparser/plyparser.py:41: Rule 'initializer_list_opt' defined, but not used
WARNING: There is 1 unused rule
WARNING: Symbol 'initializer_list_opt' is unreachable
Traceback (most recent call last):
File "example.py", line 12, in <module>
ast = p.parse(text)
File "/home/jamesmikedupont/py/pycparserext/pycparserext/ext_c_parser.py", line 64, in parse
return self.cparser.parse(text, lexer=self.clex, debug=debuglevel)
File "/usr/lib/python2.7/dist-packages/ply/yacc.py", line 269, in parse
return self.parseopt_notrack(input,lexer,debug,tracking,tokenfunc)
File "/usr/lib/python2.7/dist-packages/ply/yacc.py", line 975, in parseopt_notrack
p.callable(pslice)
File "/home/jamesmikedupont/py/pycparserext/pycparserext/ext_c_parser.py", line 282, in p_declarator_2
% type(p[1]))
NotImplementedError: cannot attach attributes to nodes of type '<class 'pycparser.c_ast.PtrDecl'>'
Did you try this with the git version? @vijunag contributed code recently that might do what you want. At any rate, I've gone ahead and released 2016.1. Let me know if that fixes your issue.
Did you try this with the git version? @vijunag https://github.com/vijunag contributed code recently that might do what
you want. At any rate, I've gone ahead and released 2016.1. Let me know if
that fixes your issue.
—
You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub #17 (comment)
@inducer He doesn't seem to be having my patch looks like since the code at the backtrace is at a different line.
File "/home/jamesmikedupont/py/pycparserext/pycparserext/ext_c_parser.py", line 282, in p_declarator_2
% type(p[1]))
NotImplementedError: cannot attach attributes to nodes of type '<class 'pycparser.c_ast.PtrDecl'>'
I just checked all the versions. my branch is up to date with my tests.
But look, I am on the latest version of ply and of the pycparser maybe that causes a problem.
it says
WARNING: /usr/lib/python2.7/dist-packages/pycparser/plyparser.py:41: Rule 'initializer_list_opt' defined, but not used
WARNING: There is 1 unused rule
WARNING: Symbol 'initializer_list_opt' is unreachable
ply$ git log -1
commit d776a2ece6c12bf8f8b6a0e65b48546ac6078765
Author: David Beazley dave@dabeaz.com
Date: Fri Oct 2 13:07:25 2015 -0500
Bumped version number
pycparser$ git log -1
commit 843362984323854f2ee81b529faa20e148915481
Author: Eli Bendersky eliben@gmail.com
Date: Sat Mar 19 05:48:10 2016 -0700
WARNING: /usr/lib/python2.7/dist-packages/pycparser/plyparser.py:41: Rule 'initializer_list_opt' defined, but not used
WARNING: There is 1 unused rule
WARNING: Symbol 'initializer_list_opt' is unreachable
Traceback (most recent call last):
File "test.py", line 9, in <module>
p.parse(src).show()
File "/home/jamesmikedupont/py/pycparserext/pycparserext/ext_c_parser.py", line 64, in parse
return self.cparser.parse(text, lexer=self.clex, debug=debuglevel)
File "/usr/lib/python2.7/dist-packages/ply/yacc.py", line 269, in parse
return self.parseopt_notrack(input,lexer,debug,tracking,tokenfunc)
File "/usr/lib/python2.7/dist-packages/ply/yacc.py", line 975, in parseopt_notrack
p.callable(pslice)
File "/home/jamesmikedupont/py/pycparserext/pycparserext/ext_c_parser.py", line 279, in p_declarator_2
% type(p[1]))
NotImplementedError: cannot attach attributes to nodes of type '<class 'pycparser.c_ast.PtrDecl'>'
Interesting. I just did a clone of latest pycparser and below are the yacc_debug logs and I didn't notice any "unreachable production error"
p = GnuCParser(yacc_debug=1)
Generating LALR tables
WARNING: 87 shift/reduce conflicts
WARNING: 88 reduce/reduce conflicts
WARNING: reduce/reduce conflict in state 295 resolved using rule (direct_declarator -> direct_declarator LPAREN identifier_list_opt RPAREN)
WARNING: rejected rule (empty -> ) in state 295
WARNING: reduce/reduce conflict in state 296 resolved using rule (direct_declarator -> direct_declarator LPAREN parameter_type_list RPAREN)
WARNING: rejected rule (empty -> ) in state 296
WARNING: reduce/reduce conflict in state 341 resolved using rule (primary_expression -> gnu_statement_expression)
WARNING: rejected rule (statement -> gnu_statement_expression) in state 341
Also, I suggest you to use the ply/lex tha came along with cparser.
cat pycparserext/ext_c_parser.py
from __future__ import division
import pycparser.c_parser
import pycparser.c_ast as c_ast
try:
import pycparser.ply.yacc as yacc # use this version of ply
except ImportError:
import ply.yacc as yacc
from future import division import pycparser.c_parser import
pycparser.c_ast as c_ast try: import pycparser.ply.yacc as yacc # use this
version of ply except ImportError: import ply.yacc as yacc
Hi, I dont need this right now, I am reporting what I found. Please give it
a try. I will circle back to this in a while.
from future import division import pycparser.c_parser import
pycparser.c_ast as c_ast try: import pycparser.ply.yacc as yacc # use this
version of ply except ImportError: import ply.yacc as yacc
Hi, I dont need this right now, I am reporting what I found. Please give it a try. I will circle back to this in a while.
Activity
inducer commentedon Apr 2, 2016
Did you try this with the git version? @vijunag contributed code recently that might do what you want. At any rate, I've gone ahead and released 2016.1. Let me know if that fixes your issue.
h4ck3rm1k3 commentedon Apr 2, 2016
this is git master latest .
On Sat, Apr 2, 2016 at 11:49 AM, Andreas Klöckner notifications@github.com
wrote:
James Michael DuPont
Kansas Linux Fest http://kansaslinuxfest.us
Free/Libre Open Source and Open Knowledge Association of Kansas
http://openkansas.us
Member of Free Libre Open Source Software Kosova http://www.flossk.org
Saving Wikipedia(tm) articles from deletion http://SpeedyDeletion.wikia.com
inducer commentedon Apr 2, 2016
Thanks for the report. I'd be happy to consider a patch.
vijunag commentedon Apr 3, 2016
The latest master seems to be working fine for me.
vijunag commentedon Apr 3, 2016
@inducer He doesn't seem to be having my patch looks like since the code at the backtrace is at a different line.
File "/home/jamesmikedupont/py/pycparserext/pycparserext/ext_c_parser.py", line 282, in p_declarator_2
% type(p[1]))
NotImplementedError: cannot attach attributes to nodes of type '<class 'pycparser.c_ast.PtrDecl'>'
h4ck3rm1k3 commentedon Apr 3, 2016
I just checked all the versions. my branch is up to date with my tests.
But look, I am on the latest version of ply and of the pycparser maybe that causes a problem.
it says
WARNING: /usr/lib/python2.7/dist-packages/pycparser/plyparser.py:41: Rule 'initializer_list_opt' defined, but not used
WARNING: There is 1 unused rule
WARNING: Symbol 'initializer_list_opt' is unreachable
ply$ git log -1
commit d776a2ece6c12bf8f8b6a0e65b48546ac6078765
Author: David Beazley dave@dabeaz.com
Date: Fri Oct 2 13:07:25 2015 -0500
pycparser$ git log -1
commit 843362984323854f2ee81b529faa20e148915481
Author: Eli Bendersky eliben@gmail.com
Date: Sat Mar 19 05:48:10 2016 -0700
jamesmikedupont@instance-3:~/py/pycparserext$ python test.py
vijunag commentedon Apr 3, 2016
Interesting. I just did a clone of latest pycparser and below are the yacc_debug logs and I didn't notice any "unreachable production error"
Also, I suggest you to use the ply/lex tha came along with cparser.
h4ck3rm1k3 commentedon Apr 3, 2016
On Sun, Apr 3, 2016 at 1:35 AM, vijunag notifications@github.com wrote:
Hi, I dont need this right now, I am reporting what I found. Please give it
a try. I will circle back to this in a while.
James Michael DuPont
Kansas Linux Fest http://kansaslinuxfest.us
Free/Libre Open Source and Open Knowledge Association of Kansas
http://openkansas.us
Member of Free Libre Open Source Software Kosova http://www.flossk.org
Saving Wikipedia(tm) articles from deletion http://SpeedyDeletion.wikia.com
vijunag commentedon Apr 3, 2016
Cool. Thanks much for the report anyway.
MaggieCwj commentedon May 9, 2022
May I know how you solve this problem? thank u