New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Redeclared types #1
Conversation
|
In the description of alternatives, you've mentioned:
I'm not sure we care much about lookaheadstack here, as it seems to be only used for error recovery. Your code just asserts it anyway. Would this make the idea of using a custom tokenfunc more feasible? |
|
I'll look into it. |
|
In the description of alternatives, you've mentioned:
I'm not sure we care much about lookaheadstack here, as it seems to be only used for error recovery. Your code just asserts it anyway. Would this make the idea of using a custom tokenfunc more feasible? |
|
I'll be updating the pull request shortly to use tokenfunc rather than inspect. As for separating the struct field namespace to a separate patch: it's quite dependent on this change. "unsigned TT" looks very similar to the parser whether TT is being redeclared as a parameter, a variable, or a structure member. |
|
If separating struct field namespace lookups is too hard, then never mind - you can keep them combined. I'm looking forward to the new patch with tokenfunc. |
|
The pull request has been updated for tokenfunc: see 2f84c0d. |
|
Looks better, thanks. Can you now rebase the whole thing vs. tip so it's merge-able? |
|
It might take a few weeks to make that change, though. (Other priorities.) Is the current version sufficient for now? |
|
The current version with |
|
The squashed commit should be available now. |
Redeclared types
Reusing typedef names as structure/union member names
Reusing typedef names as variables names in inner scopes
Reusing typedef names as parameter names in declarations and definitions
Duplicated typedef declarations (non-standard, but apparently common and syntactically similar to the above)
|
Merged. Thanks! |
Redeclared types
Reusing typedef names as structure/union member names
Reusing typedef names as variables names in inner scopes
Reusing typedef names as parameter names in declarations and definitions
Duplicated typedef declarations (non-standard, but apparently common and syntactically similar to the above)
While using pycparser to parse a large, existing codebase, I immediately came upon the typedef-name problem. The changes in this pull request resolve and test for the issues encountered; in particular:
similar to the above)
There is a corner case regarding parameter name scoping that required access to yacc.py's lookahead token (see p_direct_declarator_5 in c_parser.py for details). There are three solutions as I see it:
inspection of Python frames and local dictionaries is pretty evil)
For the purpose of this change I decided to use the inspect module, as it is the least error-prone (it can inspect lookaheadstack to ensure it's empty) and the least invasive to the codebase. I can instead make lookahead/lookaheadstack attributes, if you're willing to support the merging of PLY.