Skip to content
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

Somehow whole statements are missing #30

Open
schveiguy opened this issue Jul 24, 2023 · 2 comments
Open

Somehow whole statements are missing #30

schveiguy opened this issue Jul 24, 2023 · 2 comments
Labels
preprocessor C macro / preprocessor related

Comments

@schveiguy
Copy link
Contributor

Not sure how this happened when converting this file: https://github.com/schveiguy/draylib/blob/acb0b099169d73ac2fc4c11ddf00776bdf0aaa40/raylibc/rtextures.c

Screenshot 2023-07-23 at 10 02 00 PM

All the function calls and the image code is just missing.

@dkorpel
Copy link
Owner

dkorpel commented Jul 24, 2023

tree-sitter can't parse half statements inside #if blocks, it interprets it as a declaration with tons of ERROR nodes, which get lost when converting to D declarations.

One thing I can do is simply not translate an #if block if it's inside a function and has errors.

@dkorpel dkorpel added the preprocessor C macro / preprocessor related label Jul 24, 2023
@schveiguy
Copy link
Contributor Author

Yeah, I don't know the right answer. But I do think lots of error nodes turning into lost code is going to eventually run into a problem where the truncated code compiles, and the user doesn't notice.

In general the worst thing that ctod can do is generate D code that compiles and does something completely different than the original.

So 2 possibilities are:

  1. Leave the code alone, and not worry about translating from C to D.
  2. just insert an #error to indicate the translation couldn't be done

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

No branches or pull requests

2 participants