https://github.com/datacamp/ast-viewer
app to visualize antlr parse tree ast
https://github.com/datacamp/ast-viewer
fs le
Last synced: over 1 year ago
JSON representation
app to visualize antlr parse tree ast
- Host: GitHub
- URL: https://github.com/datacamp/ast-viewer
- Owner: datacamp
- License: agpl-3.0
- Created: 2017-02-23T14:23:27.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2023-02-27T23:22:19.000Z (over 3 years ago)
- Last Synced: 2025-01-15T22:24:53.489Z (over 1 year ago)
- Topics: fs, le
- Language: Vue
- Homepage: https://ast-viewer.datacamp.com
- Size: 1.66 MB
- Stars: 27
- Watchers: 19
- Forks: 10
- Open Issues: 24
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ast-viewer
[](https://circleci.com/gh/datacamp/ast-viewer)
[](https://app.fossa.io/projects/git%2Bgithub.com%2Fdatacamp%2Fast-viewer?ref=badge_shield)
Hosted at https://ast-viewer.datacamp.com, the ast viewer allows users to quickly parse Python, SQL (Postgres + Transact) and Shell code and inspect the resulting parse trees and abstract syntax trees. This makes development of parsing grammars ([example]) easier, but can also help when writing SCTs to figure out which ASTs are being generated for different submissions.
The AST viewer features 2 modes:
- Editor, where you can add commands in the editor. When clicking 'Submit', your code will be parsed and the corresponding trees are displayed. Mostly for interactive usage and figuring out how to write SCTs.
- Gallery, where you can drop in YAML files with a format like [this one](https://github.com/datacamp/antlr-plsql/blob/master/tests/v0.2.yml). The app will parse all the commands in the YAML file with the specified parser, and generate and display all trees. Mostly for development purposes (visually verify that all parsing still happens correctly after a change is made).
## Run locally
The `ast-viewer` has a front-end in JS (Vue) and a back-end in Python. Both use the grammars generated by [antlr-plsql](https://github.com/datacamp/antlr-plsql) and [antlr-tsql](https://github.com/datacamp/antlr-tsql); the back-end also depends on Osh and `shellwhat`. Because of the myriad dependencies and intricacies with grammar files needing to be in certain places, it is advised to use Docker to run the app.
```bash
docker build -t ast-viewer .
docker run -p 3000:3000 ast-viewer python3 run.py
```
You can now visit http://localhost:3000.
## Deployment
The app is deployed to CircleCI on DataCamp's ECS cluster. The `master` branch builds and deploys to https://ast-viewer.datacamp-staging.com. If you tag the master with tags that start with `v`, the app will be deployed to https://ast-viewer.datacamp.com.
## License
[](https://app.fossa.io/projects/git%2Bgithub.com%2Fdatacamp%2Fast-viewer?ref=badge_large)