This script creates Abstract Syntax Tree (AST) of all .swift files in JSON format. The AST is created by using SwiftSyntax.
Language | Tool used | Notes |
---|---|---|
Swift | SwiftSyntax | no types / call full names etc. |
> swift build
> swift test
> SwiftAstGen -h
USAGE: swift-ast-gen [--src <src>] [--output <output>] [--prettyPrint] [--scalaAstOnly]
OPTIONS:
-i, --src <src> Source directory (default: `.`).
-o, --output <output> Output directory for generated AST json files (default: `./ast_out`).
-p, --prettyPrint Pretty print the generated AST json files.
-s, --scalaAstOnly Only print the generated Scala SwiftSyntax AST nodes.
-h, --help Show help information.
Navigate to the project and run SwiftAstGen
.
> cd <path to project>
> SwiftAstGen
To specify the path to the project or the output directory.
> SwiftAstGen -i <path to project>
> SwiftAstGen -i <path to project> -o <path to output directory>