Parsing c header file
Consider using existing parser generators and existing grammar. This may get you started: stackoverflow. I'm just trying to compare the contents of a header file with a spreadsheet which lists the functions including return type and parameters that should be present in that header file.
I cant seem to find any : — stackPusher. I'd expect at least C grammar to be available as sample somewhere Add a comment. Active Oldest Votes.
Community Bot 1 1 1 silver badge. Ira Baxter Ira Baxter Sign up or log in Sign up using Google. Sign up using Facebook. Sign up using Email and Password. Post as a guest Name. Email Required, but never shown. The Overflow Blog. Podcast Helping communities build their own LTE networks. Thanks for testing and correction.
This can be fixed more like this Jazzthedog over 6 years ago. Thank you 01MDM! It worked fine. Now, I just have to unravel you regex to understand the "magic".. I just to figure out the regex stuff! The deciding factor between the two approaches would be the need for implementing pre- and or post- answer functioniality.
If each handler is atomic, a simple list of parsers will suffice. If handlers have to prepare for or postprocess each other's results then the linked-list method applies. In your case it looks like all of your code paths are mutually eclusive so I'd stick with the simpler list-of-handler's method.
From the looks of your code above this could also be implemented without classes by just creating a list of parsing functions.
However you'd then have to retype the signature check logic in all of the functions and if future requirements change to something where state was relevant, you'd have a harder time refactoring.
Sign up to join this community. The best answers are voted up and rise to the top. Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams?
Learn more. Using pycparser to parse C header files Ask Question. Asked 8 years, 1 month ago. Active 7 years, 9 months ago. Viewed 12k times. UnknownIdentifier id regular fields, i.
TODO -- very similar to code above Improve this question. Ben Osment Ben Osment 63 1 1 gold badge 1 1 silver badge 3 3 bronze badges. Add a comment. Asked 10 years, 6 months ago. Active 10 years, 6 months ago. Viewed 1k times. Thus as you parse the file you need to build up your type list in the parser in a way that is accessible for further processing in the lexer. I am not what are you trying to do.
In most cases, where I had to take data out of the code, I have created a special table with the data and included it into the code. Add a comment. Active Oldest Votes. Martin York Martin York k 80 80 gold badges silver badges bronze badges.
0コメント