Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9104821
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T01:57:10+00:00 2026-06-17T01:57:10+00:00

I have been able to use CDT’s AST API for parsing source code successfully.

  • 0

I have been able to use CDT’s AST API for parsing source code successfully. My question involves the reverse: How can I build an C AST programmatically, and then tell it to write itself to a file? I have seen the class ASTWriter (but that is internal) and can’t find any tutorials or documentation on building the actual AST.

I have found a paper that goes over the idea of what I want to do: Generating Rewritable Abstract Syntax Trees which makes it seem like generating code would be easy if I could construct the tree and say ‘write yourself’. Is this possible in CDT and how might I get started (preferably without deprecated/internal methods?)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T01:57:11+00:00Added an answer on June 17, 2026 at 1:57 am

    I would recommend you to start with exploring CRefactoring and its subclasses (e.g. ExtractFunctionRefactoring).

    There are many problems that CDT refactoring framework tries to address:

    1. Let the user preview the changes before actually committing them to the source code.
    2. Operate on unsaved file bug (e.g. restructure the code in the unsaved source editor)
    3. Honour the user code formatting settings in a newly generated code.
    4. Undoable transactions spanning several source files.

    I am pretty sure that even if you don’t need all those features, these two classes should be a good starting point.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been able to use OpenGL's glVertexPointer function using the following C++ code:
What I have been able to grasp from reading the source and documentation from
I have been able to use logman with some success to dump some kernel
I have been able to use datepicker in textbox but I can't figure out
I have been able to use SetFilePointerEx just fine, when setting the position only.
Until today, I have been able to use bzr pull server:path/to/trunk , but today
I have been able to use the algorithm to encrypt and decrypt files ,
I have been able to use Jquery with ASP.NET because I know where to
I have been able to use MapActivity and ItemizedOverlay to draw overlays on google
I have been able to use gnuplot to plot graphs as I run my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.