https://github.com/gekorm/astprinter
A command line tool that prints the AST of a dart file.
https://github.com/gekorm/astprinter
Last synced: 12 months ago
JSON representation
A command line tool that prints the AST of a dart file.
- Host: GitHub
- URL: https://github.com/gekorm/astprinter
- Owner: GeKorm
- License: other
- Created: 2015-04-13T14:47:38.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2015-11-07T16:17:58.000Z (over 10 years ago)
- Last Synced: 2025-04-05T01:11:17.452Z (about 1 year ago)
- Language: Dart
- Size: 121 KB
- Stars: 5
- Watchers: 1
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# AstPrinter
A command line tool that prints the expanded AST (Abstract Syntax Tree) of a dart file.

The above image was created using ```ast > output.txt```, then
opening output.txt in Sublime Text and adding Dart syntax highlighting.
## Usage
First, activate the package with pub global
pub global activate astprinter
You must manually add the pub cache bin directory to your PATH.
Pub will warn you if you haven't already.
To print the AST in the console, run ```ast <"absolutePathToDartFile"> <-n(OPTIONAL)>```
ast "C:\Path\web\main.dart" Declaration
The optional argument ```Type``` will print all AST nodes that are subtypes of ```Type```.
Multiple types can be entered as arguments.
To print Types without their subtypes append -n.
For example
ast "C:\Path\web\main.dart" Token
will print all tokens, including ```StringToken```, ```BeginToken```, ```KeywordToken```
and ```Token```. However,
ast "C:\Path\web\main.dart" Token -n
will only print ```Token ``` nodes, such as ```@```, ```=```, ```;``` etc.
## Features and bugs
Please file feature requests and bugs on [GitHub][tracker].
[tracker]: https://github.com/GeKorm/astprinter/issues/new