Comments (10)
Sorry--I don't currently have time to look at or help with this. But I'd be happy to take a patch.
from pycparserext.
I have the same issue. I need pycparserext to parse a real-world C source code (QEMU) with uses GNU extensions. It chokes on function prototypes containing pointer to pointer params like this:
typedef struct Error {
int dummy;
} Error;
void func_with_pp_param(const char *, Error **);
Adding a name to the last param, i.e.
void func_with_pp_param(const char *, Error **p);
makes the parsing magically work. Vanilla CParser works as well.
Any chances to get a support for such constructs in pycparserext?
from pycparserext.
Sure, I'd be happy to review a patch.
from pycparserext.
After spending several evenings learning PLY basics, I suspect some conflict in the pycparser/pycparserext grammar. Pycparserext:state107 behaves differently compared to pycparser:state77. That's where the things actually go wrong. My bet is that commenting out p_xxx_declarator_2 resolves that conflict.
To be able to spot the issue, one need to analyze low-level PLY parsing tables which is beyond my current knowledge level. Anyway, I'll continue to investigate.
BTW, enabling debug output with the following code:
gnu_parser = GnuCParser(yacc_debug=True)
dumps a lot of conflict warnings:
Generating LALR tables
WARNING: 121 shift/reduce conflicts
WARNING: 8 reduce/reduce conflicts
WARNING: reduce/reduce conflict in state 224 resolved using rule (primary_expression -> gnu_statement_expression)
WARNING: rejected rule (statement -> gnu_statement_expression) in state 224
I'm not sure how serious they are and whether the original parser has them too...
from pycparserext.
Those do look significant. Also, thanks for pointing out yacc_debug=True
--I did not know about this. I don't have a lot of time to debug this myself, but I welcome any progress you might be able to make. One aspect of this is that pycparser
is a moving target, so these may have crept in as the code kept changing out from under pycparserext
.
from pycparserext.
I should have a fix ready in PR #37
from pycparserext.
@jackrosenthal Thank you for fixing that! This issue was a major roadblock in a project I'm working on. I'll test your fix later today and report the result.
from pycparserext.
@jackrosenthal I just tested your fix - it works like a charm, even for complex sources like QEMU. Unit tests (python -m pytest
) do pass as well. Thank you very much!
@inducer Andreas, would you kindly merge the PR #37? I'll in turn contribute an appropriate unit test covering this corner case.
from pycparserext.
@maximumspatium Done. I would much appreciate a PR with a unit test for this. Thanks for offering.
from pycparserext.
Closing via merge of #37.
from pycparserext.
Related Issues (20)
- generator.visit of pycparser displaying wrong output in Ubuntu 16.04.3 HOT 2
- Symbol 'id_init_declarator_list_opt' used, but not defined as a token or a rule HOT 3
- Support for register type xxx __asm__(yyy) HOT 4
- error while importing from pycparser.plyparser import parameterized HOT 3
- Add an open source license to this repository HOT 1
- Coord.line is always set to 0 for Asm nodes HOT 1
- struct in a struct with __attribute__((packed)) HOT 1
- pycparser.ply.yacc.YaccError: Unable to build parser HOT 7
- installation error pycparserext HOT 5
- Cannot traverse nodes using NodeVisitor, FuncDeclExt is not iterable HOT 4
- TypeError: _generate_type() got an unexpected keyword argument 'emit_declname' HOT 2
- Parsing of Basic Blocks HOT 1
- test/test_pycparserext.py L244 test_array_attributes lost array dimension HOT 4
- Check the parsed AST in the tests HOT 1
- Support for case ranges HOT 2
- Next release roadmap HOT 2
- stddef.h include issue HOT 2
- NotImplementedError: cannot attach asm or attributes to nodes of type '<class 'pycparser.c_ast.PtrDecl'>'
- Support complex __attribute__ involving __alignof__ HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pycparserext.