Skip to content
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

Merged
merged 2 commits into from
Jul 26, 2022
Merged

Add visualization of ASTs to CLI & REPL #158

merged 2 commits into from
Jul 26, 2022

Conversation

jpschorr
Copy link
Contributor

@jpschorr jpschorr commented Jul 25, 2022

Add visualization of ASTs to CLI & REPL

  • Make modules for existing functionality of error and repl
  • 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

NOTE: 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

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.

@codecov
Copy link

codecov bot commented Jul 25, 2022

Codecov Report

Merging #158 (7cef2ba) into main (62a2159) will increase coverage by 0.50%.
The diff coverage is n/a.

@@            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     
Impacted Files Coverage Δ
partiql-parser/src/error.rs 84.21% <0.00%> (+16.60%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 62a2159...7cef2ba. Read the comment docs.

@github-actions
Copy link

github-actions bot commented Jul 25, 2022

Conformance comparison report

main (62a2159) a4b16e0 +/-
% Passing 75.85% 75.85% 0.00%
✅ Passing 333 333 0
❌ Failing 47 47 0
🔶 Ignored 59 59 0
Total Tests 439 439 0

Number passing in both: 333

Number failing in both: 47

Number passing in main but now fail: 0

Number failing in main but now pass: 0

- 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
Copy link
Member

@alancai98 alancai98 left a 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).

partiql-cli/src/error.rs Outdated Show resolved Hide resolved
partiql-cli/src/main.rs Outdated Show resolved Hide resolved
partiql-cli/src/repl.rs Show resolved Hide resolved
partiql-cli/src/visualize/render.rs Show resolved Hide resolved
partiql-cli/Cargo.toml Show resolved Hide resolved
partiql-cli/Cargo.toml Show resolved Hide resolved
partiql-cli/src/visualize/ast_to_dot.rs Show resolved Hide resolved
@jpschorr jpschorr requested a review from alancai98 July 26, 2022 20:05
@jpschorr jpschorr merged commit 033ad63 into main Jul 26, 2022
@am357 am357 deleted the feat-cli-visualize branch July 26, 2022 21:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants