vmware-archive / cascade

A Just-In-Time Compiler for Verilog from VMware Research
Other
435 stars 44 forks source link

Add AST Builder class #158

Closed eschkufz closed 5 years ago

eschkufz commented 5 years ago

Overview

In preparation for some of the more ambitious code generation we've been talking about, it would be nice to have a class for building AST nodes from text, rather than extremely verbose calls to the new operator.

So rather than this:

auto* md = new ModuleDeclaration(new Attributes(), new Identifier("m"));

You could just do this:

AstBuilder() << "module m(); endmodule";

While we're at it, we'll probably want to pass exisiting ast nodes to operator<<, which means we'll finally want to wrap TextPrinter and TermPrinter in something more user friendly like this:

cout << text << md << endl; // Invokes TextPrinter
cout << color << md << endl; // Invokes TermPrinter

Deliverables