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

[C2AST] Generate AST from C code #38

Open
felixpk opened this issue Jan 20, 2022 · 3 comments · May be fixed by #261
Open

[C2AST] Generate AST from C code #38

felixpk opened this issue Jan 20, 2022 · 3 comments · May be fixed by #261
Assignees
Labels
feature-request New feature or request

Comments

@felixpk
Copy link
Collaborator

felixpk commented Jan 20, 2022

Proposal

Writing AST tests can be quite verbose, therefore I propose to implement a converter which translates c code to dewolfs AST implementation.

Approach

  1. Use pycparser to generate an intermediate AST representation
  2. Translate each AST node to dewolfs AST representation
@felixpk felixpk added the feature-request New feature or request label Jan 20, 2022
@felixpk
Copy link
Collaborator Author

felixpk commented Jan 20, 2022

/cib

@github-actions
Copy link
Contributor

Branch issue-38-_C2AST_Generate_AST_from_C_code created!

@felixpk
Copy link
Collaborator Author

felixpk commented Jan 20, 2022

What does currently work?

  • AbstractSyntaxTreeNode
  • Expression
  • Instruction
  • Operation
  • Distinction between Function and Imported Function Symbols
  • Compound operators

What does currently not work?

  • printf("i is %d\n", i); becomes printf("i is %d\\n", i); (encoding problem)

  • comments are ignored (pycparser limitation)

  • If the input code contains an array like int numbers[10]; we need to convert it to int *numbers = malloc(sizeof(int) * 10); this implies that we also have to free the allocated memory after the last usage of numbers.

  • Structs are not implemented in dewolf

    struct {
      int age;
      char* name;
    } p1;
    
    p1.age = 18;
    p1.name = "Peter";

    (Not sure how to convert it)

@NeoQuix NeoQuix linked a pull request Jun 27, 2023 that will close this issue
@NeoQuix NeoQuix linked a pull request Jun 27, 2023 that will close this issue
@NeoQuix NeoQuix self-assigned this Jun 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants