Construct dependency graph GIf G is acyclic, perform topological sort;Otherwise, the grammar has issues and may need a redesign