The current function for extracting the concrete syntax from a syntax tree and printing it lp_tree_print:
|
void lp_tree_print(TreeNode *node) |
prints a lot of superfluous parenthesis (every operator and its operand(s) are explicitly surrounded by parenthesis to highlight precedence as given in the syntax tree). This is great for debugging the parser and checking whether it got the precedence of operators right, but not very pleasing to the end user's eye.
Implementing a prettier function that does not print explicit parenthesis every time might be in order.
Implementation idea: For each node (operator) in the tree, only print parenthesis if the parent node (operator) has higher precedence.
Might work like this, might not; to be explored.