What are the general strategies for reducing a parse tree (ie. concrete syntax tree) into an abstract syntax tree?
For example, I have the following grammar rule:
statement_list : statement
| statement_list statement
which, if left as a parse tree, will generate fanning output that looks like
program
statement_list
statement_list
statement
definition
p_type
assignment
statement
definition
statement
assign
assignment
If I concatenate the children of each node (since a statement list has no inherent meaning after parsing), I can achieve the following
program
definition
p_type
assignment
definition
assign
assignment
This worked well - however, I'm unaware of any "rules" for doing this. Are there specific grammar rules I should be looking to simplify? Is it a matter of feel, or is there a more mechanistic process?