generate rules LHS then RHS then parent.