Dumping a program’s AST and compiling it in a single invocation

When we call the compiler to dump a program’s AST (i.e. swiftc -dump-ast *.swift) it does the parsing, typechecking, etc and then dumps the AST, but stops there. If we also wanted to compile those files, we’d have to call the compiler again, and it would perform the parsing and typechecking steps again, which can be time-consuming.

I wanted to try to add a new flag or something to allow dumping the AST sort of as a side product of the compilation process (rather than just the end result). Would this be a hard thing to do? Are there similar flags already (maybe -emit-sil or something)? Would it be disruptive to the rest of the compiler’s architecture? I really have no idea so I’d appreciate any input.

(c.c. @jrose who helped me with similar problems before)


Terms of Service

Privacy Policy

Cookie Policy