-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add visualization of ASTs to CLI & REPL #158
Conversation
0b9ba6d
to
e773e5a
Compare
Codecov Report
@@ Coverage Diff @@
## main partiql/partiql-lang-rust#158 +/- ##
==========================================
+ Coverage 84.03% 84.54% +0.50%
==========================================
Files 20 20
Lines 2362 2348 -14
==========================================
Hits 1985 1985
+ Misses 377 363 -14
Continue to review full report at Codecov.
|
- Add actual arg parsing to CLI - Make REPL a sub-mode initiated by a CLI command - Add partial (lots of `todo!()`s) translation of AST into graphviz - Add FFI to graphviz to layout & render - Add `display` mode which prints image to console
e773e5a
to
d99cbde
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very cool work here. The visualization makes the AST (and future IR) much more comprehensible and easier to view the parser's output. Left mostly minor comments and a possible parser bug (related to path expressions).
Add visualization of ASTs to CLI & REPL
error
andrepl
todo!()
s) translation of AST into graphvizdisplay
mode which prints image to consoleNOTE: You will need to
brew install graphviz
or system-equivalent prior to the following.For example, running:
cargo run --release --features visualize -- ast -Tpng "SELECT num.*, num BETWEEN 2 AND 15 FROM (SELECT tbl.a[8] + ((4/-2)+(7*sin(7))-2.0) - xform(1,position('x' in 'yxz')), NULL FROM tbl WHERE tbl.b LIKE 'foo%') as num" > /tmp/ast.png
shows
![ast](https://user-images.githubusercontent.com/36067/180839153-eba2f644-12ce-4f48-8ab6-cca12661dd68.png)
Or, run
cargo run --release --features visualize -- ast -Tdisplay "SELECT num.*, num BETWEEN 2 AND 15 FROM (SELECT tbl.a[8] + ((4/-2)+(7*sin(7))-2.0) - xform(1,position('x' in 'yxz')), NULL FROM tbl WHERE tbl.b LIKE 'foo%') as num"
to display the image directly in the terminal (for any terminal supported by viuer)
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.