-
Notifications
You must be signed in to change notification settings - Fork 8
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
Prettyprinter #554
Prettyprinter #554
Conversation
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.
This PR is waiting on a refactor, leveraging the existing pretty printer for s-expressions.
214c313
to
53a35fd
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.
This is promising, but we should simplify it before we merge
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 close now!
804bd57
to
74639d9
Compare
} | ||
} | ||
|
||
pub fn map_expr_children<F>(self: &RcExpr, mut map_child: F) -> RcExpr |
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.
Maybe leaving a note saying that these functions may violate the invariant that RcExpr
is interned (as mentioned in RcExpr
's doc.
let single_v7 = single(getat(2)); | ||
let single_v8 = single(getat(3)); | ||
let sub_v9 = sub(getat(2), | ||
getat(1)); |
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.
Could you check if this getat(1)
has a different context as single_v6
. Also, could you document what is the current behavior of sharing for the pretty printer? My understanding is that it's not perfect (although pretty usable).
action items for this PR after a discussion:
|
all the review comments should have been addressed now
Add a pretty printer which either output to rust macro or let-binded egglog.
Pretty printer could take a string of egglog output and parse it under current schema to RcExpr, or an RcExpr of program, output the rust macro or let-binded egglog.
Add runmode PrettyPrint and OptimizedPrettyPrint, which output the rust macro form of original program or optimized program.
To make rust macro look better copy it to rust file and "cargo fmt". Though you need to add ".with_arg_types(..)" and "add_ctx()" to make it runnable.