In My Assignment It Asks To Print Out The Constants Identifiers Operators Etc In

In my assignment it asks to print out the constants, identifiers, operators etc instead of counting them. Also it does not double count the same one. How can I do that? It is the same assignment as previous one.