Skip to content

Conversation

foxever
Copy link
Contributor

@foxever foxever commented Mar 7, 2019

Add pretty print option, default is non pretty print, the second argument is pretty print flag.
Ref #2490

tree->toStringTree(&parser, true);

Here's the demo output

(main 
        (stat 
            (expr 
                (id 🍴)) = 
            (expr 
                (expr 
                    (id 🍐)) + 
                (expr "😎")) ;) 
        (stat 
            (expr 
                (expr 
                    (expr ( 
                        (expr ( 
                            (expr ( 
                                (expr 
                                    (expr 
                                        (id x)) * 
                                    (expr 
                                        (id π))) )) )) )) * 
                    (expr 
                        (id µ))) + 
                (expr 
                    (id ∰))) ;) 
        (stat 
            (expr 
                (expr 
                    (id a)) + 
                (expr ( 
                    (expr 
                        (expr 
                            (expr 
                                (id x)) * 
                            (expr ( 
                                (expr 
                                    (expr 
                                        (id y)) ? 
                                    (expr 0) : 
                                    (expr 1)) ))) + 
                        (expr 
                            (id z))) ))) ;) <EOF>)

Copy link
Member

@mike-lischke mike-lischke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice patch, thanks. Please update your branch to solve the conflict.


/// <summary>
/// Print out a whole tree, not just a node, in LISP format
/// (root child1 .. childN). Print just a node if this is a leaf.
/// </summary>
virtual std::string toStringTree(std::vector<std::string> &ruleNames);
virtual std::string toStringTree(std::vector<std::string> &ruleNames, bool pretty=false);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use a space on each side of the equal sign (do this for all occurences in this patch).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Copy link
Member

@mike-lischke mike-lischke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, thanks.

@parrt ready to merge (C++ only changes)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants