gccrs icon indicating copy to clipboard operation
gccrs copied to clipboard

Add AST dump visitor

Open philberty opened this issue 3 years ago • 1 comments

Lets create a new visitor to do an AST dump this dump will output any AST item to be as close to real rust formatted code as possible.

So for example we can send in an AST::Function and get back:

fn function_name() ... { ... }

This visitor should keep a context for indentation, and be used to take over our current AST dump which is abusing as_string which is not the right place to do this as it loses the context information of the indentation levels.

We should give the visitor an output stream (std::ofstream - yes one of the few times streams in C++ are good) to write the dump to. This lets us give any kind of stream so we are not tied to abusing std::string which will not scale very well.

NOTE this issue will super seed the old: #7

philberty avatar May 19 '22 13:05 philberty

Since the goal is to dump valid rust code, we should also think of a way to test that we produce valid rust code. I think this might be something for the testing project as it might be a little hard to do with dejagnu?

CohenArthur avatar May 30 '22 08:05 CohenArthur

This is already done within the compiler and simply needs to cover more cases as with go

CohenArthur avatar Aug 16 '22 10:08 CohenArthur