[swift-dev] Question about dump-ast and logging the output to file

Dmitri Gribenko gribozavr at gmail.com
Sun Aug 28 20:23:56 CDT 2016


On Wed, Aug 24, 2016 at 10:27 AM, Marcel Rebou├žas <swift-dev at swift.org> wrote:
> Hello everybody,
>
> I am planning in doing some research and analysis with the ASTs of swift
> programs and, for that reason, I am trying to modify the compiler to always
> generate a file with the contents of the -dump-ast flag when building a
> project.

Hi Marcel,

dump-ast format is not machine-parseable.  It was never designed to be
such (so it is irregular), and it will change in incompatible ways in
future.  And of course '-dump-ast' is not a publicly documented
compiler flag, so it can go away at any point, for example, it can be
removed from compilers built as public releases to save code size.

If you want to (eventually) use your tool in a production environment,
you should consider building your tool on top of SourceKit, possibly
extending SourceKit along the way.

Dmitri

-- 
main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if
(j){printf("%d\n",i);}}} /*Dmitri Gribenko <gribozavr at gmail.com>*/


More information about the swift-dev mailing list