-
Notifications
You must be signed in to change notification settings - Fork 5
feat(pp): pretty print implementation draft #351
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
base: master
Are you sure you want to change the base?
Conversation
Compiles without warnings
|
|
||
| #include "./cst.hpp" | ||
|
|
||
| std::string pretty_print(CST::CST&); |
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.
should be inside namespace CST to match with the definition in pretty_print.cpp
|
|
||
| #include "./cst.hpp" | ||
|
|
||
| std::string pretty_print(CST::CST&); |
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.
Looks like you implemented pretty-printing over std::ostream, so I would expose the slightly more efficient pretty_print(Cst&, ostream&) (while also keeping the string-returning pretty_print(Cst&) for convenience)
I think
Round-tripping between pretty-printing and parsing (CST -> text -> same CST) is a good way to gain confidence in the printer, but it might be kind of arduous to write. I'll be pragmatic and say that checking some specific input-output (cst, text) pairs is good enough. We can add regression tests if we find any bugs.
I think we could use it in the
You mean limiting the number of columns per line of code? It's famously pretty difficult. There is a famous paper by Philip Wadler outlining a pretty decent and simple approach. Tbh I am happy with the printer in this PR (no column limit), but if you want to add that, a separate PR would be welcome. |
| #include <sstream> | ||
|
|
||
| #include "log/log.hpp" | ||
| #include "pretty_print.hpp" |
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.
| #include <sstream> | |
| #include "log/log.hpp" | |
| #include "pretty_print.hpp" | |
| #include "pretty_print.hpp" | |
| #include "log/log.hpp" | |
| #include <sstream> |
as a general rule I try to always include the .hpp corresponding to the current .cpp as the first line
Also, stdlib includes after project includes
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.
There are some minor style thingies but generally LGTM -- feel free to merge when you're happy with it
Compiles without warnings for now...
I will draft this because I need some suggestions:
pretty_printfunction?Closes #136.