I have my parse tree with me, now I have traversed in order on the parse tree and a Symbol table is generated too. But how do I build the AST for this?
Here is what I have gathered (some unreliable resources):
- In your parse tree you go inOrder I.e Take the leftmost child, The parent then, and then the list of other children.
- If you come across anything like SEMICOL, Parenthesis, do not add it to AST, if there is only one child to a node, remove that node, and use child instead.
Is this all I need to do?