8000 Write a C parser · Issue #12 · lrs-lang/lib · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Write a C parser #12

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

Open
mahkoh opened this issue Nov 13, 2015 · 2 comments
Open

Write a C parser #12

mahkoh opened this issue Nov 13, 2015 · 2 comments
Labels

Comments

@mahkoh
Copy link
Collaborator
mahkoh commented Nov 13, 2015

One of the major problems when using rust or lrs is that bindings have to be written manually. There have been some efforts that used libclang to generate bindings, but libclang doesn't expose enough details to do this properly. Iirc, you cannot access C macros properly with libclang.

To tackle this problem, I wrote a C preprocessor some time ago (in rust). This preprocessor understands all GCC extensions. What's missing is an actual C parser. Note that this C parser doesn't have to be able to parse all C code. It's enough to parse the function definitions and skip the function body.

I'll try to clean the preprocessor up and port it to lrs soonish.

@mahkoh mahkoh added the todo label Nov 13, 2015
@briansmith
Copy link

Why not do this using Clang's parser?

@mahkoh
Copy link
Collaborator Author
mahkoh commented Mar 25, 2016

Last time I checked, libclang doesn't give you access to the pre-processor state after the parsing. For example:

#define X 1

If this is the file you're parsing libclang gives you nothing.

I also like writing parsers so I don't think I'm going to use libclang even if it has improved in the meantime. I'm not working on this at the moment though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants
0